mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 04:22:13 +08:00
DataSourceMeta: add an option to get hidden queries (#17124)
* add an option to get hidden queries * make sure you have meta * supportsHiddenQueries * remove spaces * DataSources: hidden queries flag
This commit is contained in:

committed by
Torkel Ödegaard

parent
73e4178aef
commit
1033f0f905
@ -85,6 +85,13 @@ export interface DataSourcePluginMeta extends PluginMeta {
|
|||||||
queryOptions?: PluginMetaQueryOptions;
|
queryOptions?: PluginMetaQueryOptions;
|
||||||
sort?: number;
|
sort?: number;
|
||||||
supportsStreaming?: boolean;
|
supportsStreaming?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, hidden queries are not passed to the datasource
|
||||||
|
* Set this to true in plugin.json to have hidden queries passed to the
|
||||||
|
* DataSource query method
|
||||||
|
*/
|
||||||
|
hiddenQueries?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PluginMetaQueryOptions {
|
interface PluginMetaQueryOptions {
|
||||||
|
@ -23,6 +23,7 @@ type DataSourcePlugin struct {
|
|||||||
Alerting bool `json:"alerting"`
|
Alerting bool `json:"alerting"`
|
||||||
Explore bool `json:"explore"`
|
Explore bool `json:"explore"`
|
||||||
Table bool `json:"tables"`
|
Table bool `json:"tables"`
|
||||||
|
HiddenQueries bool `json:"hiddenQueries"`
|
||||||
Logs bool `json:"logs"`
|
Logs bool `json:"logs"`
|
||||||
QueryOptions map[string]bool `json:"queryOptions,omitempty"`
|
QueryOptions map[string]bool `json:"queryOptions,omitempty"`
|
||||||
BuiltIn bool `json:"builtIn,omitempty"`
|
BuiltIn bool `json:"builtIn,omitempty"`
|
||||||
|
@ -108,9 +108,6 @@ export class PanelQueryRunner {
|
|||||||
delayStateNotification,
|
delayStateNotification,
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
// filter out hidden queries & deep clone them
|
|
||||||
const clonedAndFilteredQueries = cloneDeep(queries.filter(q => !q.hide));
|
|
||||||
|
|
||||||
const request: DataQueryRequest = {
|
const request: DataQueryRequest = {
|
||||||
requestId: getNextRequestId(),
|
requestId: getNextRequestId(),
|
||||||
timezone,
|
timezone,
|
||||||
@ -120,7 +117,7 @@ export class PanelQueryRunner {
|
|||||||
timeInfo,
|
timeInfo,
|
||||||
interval: '',
|
interval: '',
|
||||||
intervalMs: 0,
|
intervalMs: 0,
|
||||||
targets: clonedAndFilteredQueries,
|
targets: cloneDeep(queries),
|
||||||
maxDataPoints: maxDataPoints || widthPixels,
|
maxDataPoints: maxDataPoints || widthPixels,
|
||||||
scopedVars: scopedVars || {},
|
scopedVars: scopedVars || {},
|
||||||
cacheTimeout,
|
cacheTimeout,
|
||||||
@ -135,6 +132,10 @@ export class PanelQueryRunner {
|
|||||||
try {
|
try {
|
||||||
const ds = await getDataSource(datasource, request.scopedVars);
|
const ds = await getDataSource(datasource, request.scopedVars);
|
||||||
|
|
||||||
|
if (ds.meta && !ds.meta.hiddenQueries) {
|
||||||
|
request.targets = request.targets.filter(q => !q.hide);
|
||||||
|
}
|
||||||
|
|
||||||
// Attach the datasource name to each query
|
// Attach the datasource name to each query
|
||||||
request.targets = request.targets.map(query => {
|
request.targets = request.targets.map(query => {
|
||||||
if (!query.datasource) {
|
if (!query.datasource) {
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
"id": "cloudwatch",
|
"id": "cloudwatch",
|
||||||
"category": "cloud",
|
"category": "cloud",
|
||||||
|
|
||||||
|
"hiddenQueries": true,
|
||||||
"metrics": true,
|
"metrics": true,
|
||||||
"alerting": true,
|
"alerting": true,
|
||||||
"annotations": true,
|
"annotations": true,
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
"includes": [{ "type": "dashboard", "name": "Graphite Carbon Metrics", "path": "dashboards/carbon_metrics.json" }],
|
"includes": [{ "type": "dashboard", "name": "Graphite Carbon Metrics", "path": "dashboards/carbon_metrics.json" }],
|
||||||
|
|
||||||
|
"hiddenQueries": true,
|
||||||
"metrics": true,
|
"metrics": true,
|
||||||
"alerting": true,
|
"alerting": true,
|
||||||
"annotations": true,
|
"annotations": true,
|
||||||
|
Reference in New Issue
Block a user