@perses-dev/prometheus-plugin 0.58.0-beta.1 → 0.58.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mf/js/Prometheus.e833859d.js +7 -0
- package/__mf/js/async/{1728.e8350fb6.js → 1728.11ee7ff9.js} +1 -1
- package/__mf/js/async/2177.a9ef2479.js +7 -0
- package/__mf/js/async/3075.08023434.js +1 -0
- package/__mf/js/async/3613.f0b10cb1.js +22 -0
- package/__mf/js/async/5440.9f33f7a9.js +2 -0
- package/__mf/js/async/{5440.52ec91ad.js.LICENSE.txt → 5440.9f33f7a9.js.LICENSE.txt} +3 -3
- package/__mf/js/async/8002.011a74d4.js +3 -0
- package/__mf/js/async/9020.311b6932.js +1 -0
- package/__mf/js/async/9537.d1466e1b.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusDatasource.534ca47d.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusExplorer.2c37dbd9.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.ffb9bbc3.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.a17f75cc.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.26f85fc6.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.6626e886.js +1 -0
- package/__mf/js/main.f4a1cbf1.js +7 -0
- package/lib/cjs/components/query.js +9 -2
- package/lib/cjs/explore/PrometheusMetricsFinder/utils.js +17 -4
- package/lib/cjs/plugins/PrometheusLabelValuesVariable.js +72 -6
- package/lib/cjs/plugins/interpolation.js +7 -0
- package/lib/components/query.d.ts.map +1 -1
- package/lib/components/query.js +10 -3
- package/lib/components/query.js.map +1 -1
- package/lib/explore/PrometheusMetricsFinder/utils.d.ts.map +1 -1
- package/lib/explore/PrometheusMetricsFinder/utils.js +18 -5
- package/lib/explore/PrometheusMetricsFinder/utils.js.map +1 -1
- package/lib/plugins/PrometheusLabelValuesVariable.d.ts.map +1 -1
- package/lib/plugins/PrometheusLabelValuesVariable.js +72 -6
- package/lib/plugins/PrometheusLabelValuesVariable.js.map +1 -1
- package/lib/plugins/interpolation.d.ts +1 -0
- package/lib/plugins/interpolation.d.ts.map +1 -1
- package/lib/plugins/interpolation.js +4 -0
- package/lib/plugins/interpolation.js.map +1 -1
- package/mf-manifest.json +84 -84
- package/mf-stats.json +86 -86
- package/package.json +8 -7
- package/__mf/js/Prometheus.d3a12aa6.js +0 -7
- package/__mf/js/async/1872.7a33d27d.js +0 -7
- package/__mf/js/async/2340.1f49ce2e.js +0 -1
- package/__mf/js/async/4402.2c6a54dd.js +0 -1
- package/__mf/js/async/5440.52ec91ad.js +0 -2
- package/__mf/js/async/7670.3e71874a.js +0 -1
- package/__mf/js/async/8750.7d02f3b6.js +0 -3
- package/__mf/js/async/9916.11d16715.js +0 -22
- package/__mf/js/async/__federation_expose_PrometheusDatasource.2d013450.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusExplorer.f82cdff6.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.c01296a1.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.e47f56d4.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.593376e2.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.ee2d94d2.js +0 -1
- package/__mf/js/main.31c60b65.js +0 -7
- /package/__mf/css/async/{1872.85c2cbf6.css → 2177.85c2cbf6.css} +0 -0
- /package/__mf/js/async/{1872.7a33d27d.js.LICENSE.txt → 2177.a9ef2479.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{9916.11d16715.js.LICENSE.txt → 3613.f0b10cb1.js.LICENSE.txt} +0 -0
|
@@ -30,8 +30,11 @@ _export(exports, {
|
|
|
30
30
|
});
|
|
31
31
|
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
32
32
|
const _reactquery = require("@tanstack/react-query");
|
|
33
|
+
const _interpolation = require("../plugins/interpolation");
|
|
33
34
|
function useParseQuery(content, datasource, enabled) {
|
|
34
35
|
const { data: client } = (0, _pluginsystem.useDatasourceClient)(datasource);
|
|
36
|
+
const datasourceStore = (0, _pluginsystem.useDatasourceStore)();
|
|
37
|
+
const variableState = (0, _pluginsystem.useVariableValues)();
|
|
35
38
|
return (0, _reactquery.useQuery)({
|
|
36
39
|
enabled: !!client && enabled,
|
|
37
40
|
queryKey: [
|
|
@@ -44,12 +47,15 @@ function useParseQuery(content, datasource, enabled) {
|
|
|
44
47
|
const params = {
|
|
45
48
|
query: content
|
|
46
49
|
};
|
|
47
|
-
|
|
50
|
+
const interpolatedOptions = await (0, _interpolation.getInterpolatedRequestOptions)(datasourceStore, datasource, variableState);
|
|
51
|
+
return await client.parseQuery(params, interpolatedOptions);
|
|
48
52
|
}
|
|
49
53
|
});
|
|
50
54
|
}
|
|
51
55
|
function useInstantQuery(content, datasource, enabled) {
|
|
52
56
|
const { data: client } = (0, _pluginsystem.useDatasourceClient)(datasource);
|
|
57
|
+
const datasourceStore = (0, _pluginsystem.useDatasourceStore)();
|
|
58
|
+
const variableState = (0, _pluginsystem.useVariableValues)();
|
|
53
59
|
return (0, _reactquery.useQuery)({
|
|
54
60
|
enabled: !!client && enabled,
|
|
55
61
|
// TODO: for some reason the caching is not working: identical nodes still fire their requests after each change made to the promQL
|
|
@@ -63,8 +69,9 @@ function useInstantQuery(content, datasource, enabled) {
|
|
|
63
69
|
const params = {
|
|
64
70
|
query: content
|
|
65
71
|
};
|
|
72
|
+
const interpolatedOptions = await (0, _interpolation.getInterpolatedRequestOptions)(datasourceStore, datasource, variableState);
|
|
66
73
|
const startTime = performance.now();
|
|
67
|
-
const response = await client.instantQuery(params);
|
|
74
|
+
const response = await client.instantQuery(params, interpolatedOptions);
|
|
68
75
|
const responseTime = performance.now() - startTime;
|
|
69
76
|
return {
|
|
70
77
|
...response,
|
|
@@ -37,9 +37,12 @@ _export(exports, {
|
|
|
37
37
|
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
38
38
|
const _reactquery = require("@tanstack/react-query");
|
|
39
39
|
const _react = require("react");
|
|
40
|
+
const _interpolation = require("../../plugins/interpolation");
|
|
40
41
|
const _types = require("./types");
|
|
41
42
|
function useMetricMetadata(metricName, datasource, enabled) {
|
|
42
43
|
const { data: client } = (0, _pluginsystem.useDatasourceClient)(datasource);
|
|
44
|
+
const datasourceStore = (0, _pluginsystem.useDatasourceStore)();
|
|
45
|
+
const variableState = (0, _pluginsystem.useVariableValues)();
|
|
43
46
|
// histograms and summaries timeseries desc are not always added to prefixed timeseries
|
|
44
47
|
const name = metricName.replace(/(_count|_sum|_bucket)$/, '');
|
|
45
48
|
const { data, isLoading, error } = (0, _reactquery.useQuery)({
|
|
@@ -52,7 +55,8 @@ function useMetricMetadata(metricName, datasource, enabled) {
|
|
|
52
55
|
const params = {
|
|
53
56
|
metric: name
|
|
54
57
|
};
|
|
55
|
-
|
|
58
|
+
const interpolatedOptions = await (0, _interpolation.getInterpolatedRequestOptions)(datasourceStore, datasource, variableState);
|
|
59
|
+
return await client.metricMetadata(params, interpolatedOptions);
|
|
56
60
|
}
|
|
57
61
|
});
|
|
58
62
|
// Find the first result with help text
|
|
@@ -76,6 +80,8 @@ function useMetricMetadata(metricName, datasource, enabled) {
|
|
|
76
80
|
function useLabels(filters, datasource) {
|
|
77
81
|
const { absoluteTimeRange: { start, end } } = (0, _pluginsystem.useTimeRange)();
|
|
78
82
|
const { data: client } = (0, _pluginsystem.useDatasourceClient)(datasource);
|
|
83
|
+
const datasourceStore = (0, _pluginsystem.useDatasourceStore)();
|
|
84
|
+
const variableState = (0, _pluginsystem.useVariableValues)();
|
|
79
85
|
return (0, _reactquery.useQuery)({
|
|
80
86
|
enabled: !!client,
|
|
81
87
|
queryKey: [
|
|
@@ -99,13 +105,16 @@ function useLabels(filters, datasource) {
|
|
|
99
105
|
`{${(0, _types.computeFilterExpr)(filters)}}`
|
|
100
106
|
];
|
|
101
107
|
}
|
|
102
|
-
|
|
108
|
+
const interpolatedOptions = await (0, _interpolation.getInterpolatedRequestOptions)(datasourceStore, datasource, variableState);
|
|
109
|
+
return await client.labelNames(params, interpolatedOptions);
|
|
103
110
|
}
|
|
104
111
|
});
|
|
105
112
|
}
|
|
106
113
|
function useLabelValues(labelName, filters, datasource) {
|
|
107
114
|
const { absoluteTimeRange: { start, end } } = (0, _pluginsystem.useTimeRange)();
|
|
108
115
|
const { data: client } = (0, _pluginsystem.useDatasourceClient)(datasource);
|
|
116
|
+
const datasourceStore = (0, _pluginsystem.useDatasourceStore)();
|
|
117
|
+
const variableState = (0, _pluginsystem.useVariableValues)();
|
|
109
118
|
return (0, _reactquery.useQuery)({
|
|
110
119
|
enabled: !!client,
|
|
111
120
|
queryKey: [
|
|
@@ -130,13 +139,16 @@ function useLabelValues(labelName, filters, datasource) {
|
|
|
130
139
|
`{${(0, _types.computeFilterExpr)(filters)}}`
|
|
131
140
|
];
|
|
132
141
|
}
|
|
133
|
-
|
|
142
|
+
const interpolatedOptions = await (0, _interpolation.getInterpolatedRequestOptions)(datasourceStore, datasource, variableState);
|
|
143
|
+
return await client.labelValues(params, interpolatedOptions);
|
|
134
144
|
}
|
|
135
145
|
});
|
|
136
146
|
}
|
|
137
147
|
function useSeriesStates(metricName, filters, datasource) {
|
|
138
148
|
const { absoluteTimeRange: { start, end } } = (0, _pluginsystem.useTimeRange)();
|
|
139
149
|
const { data: client } = (0, _pluginsystem.useDatasourceClient)(datasource);
|
|
150
|
+
const datasourceStore = (0, _pluginsystem.useDatasourceStore)();
|
|
151
|
+
const variableState = (0, _pluginsystem.useVariableValues)();
|
|
140
152
|
const { data: seriesData, isLoading, isError, error } = (0, _reactquery.useQuery)({
|
|
141
153
|
enabled: !!client,
|
|
142
154
|
queryKey: [
|
|
@@ -158,7 +170,8 @@ function useSeriesStates(metricName, filters, datasource) {
|
|
|
158
170
|
start: start.valueOf() / 1000,
|
|
159
171
|
end: end.valueOf() / 1000
|
|
160
172
|
};
|
|
161
|
-
|
|
173
|
+
const interpolatedOptions = await (0, _interpolation.getInterpolatedRequestOptions)(datasourceStore, datasource, variableState);
|
|
174
|
+
return await client.series(params, interpolatedOptions);
|
|
162
175
|
}
|
|
163
176
|
});
|
|
164
177
|
const labelValueCounters = (0, _react.useMemo)(()=>{
|
|
@@ -24,6 +24,60 @@ const _pluginsystem = require("@perses-dev/plugin-system");
|
|
|
24
24
|
const _model = require("../model");
|
|
25
25
|
const _prometheusvariables = require("./prometheus-variables");
|
|
26
26
|
const _interpolation = require("./interpolation");
|
|
27
|
+
function extractDatasourceVariables(datasourceSpec) {
|
|
28
|
+
try {
|
|
29
|
+
const spec = datasourceSpec.plugin.spec;
|
|
30
|
+
// Pure function to extract variables from string or array values
|
|
31
|
+
const extractFromValue = (value)=>{
|
|
32
|
+
if (typeof value === 'string') {
|
|
33
|
+
return (0, _pluginsystem.parseVariables)(value);
|
|
34
|
+
} else if (Array.isArray(value)) {
|
|
35
|
+
return value.flatMap((item)=>{
|
|
36
|
+
return typeof item === 'string' ? (0, _pluginsystem.parseVariables)(item) : [];
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return [];
|
|
40
|
+
};
|
|
41
|
+
const allVariables = [];
|
|
42
|
+
// Extract variables from queryParams
|
|
43
|
+
if (spec.queryParams) {
|
|
44
|
+
Object.values(spec.queryParams).forEach((value)=>{
|
|
45
|
+
allVariables.push(...extractFromValue(value));
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
// Extract variables from directUrl
|
|
49
|
+
if (spec.directUrl) {
|
|
50
|
+
allVariables.push(...extractFromValue(spec.directUrl));
|
|
51
|
+
}
|
|
52
|
+
// Extract variables from proxy configuration
|
|
53
|
+
if (spec.proxy?.spec) {
|
|
54
|
+
// Extract from proxy URL
|
|
55
|
+
if (spec.proxy.spec.url) {
|
|
56
|
+
allVariables.push(...extractFromValue(spec.proxy.spec.url));
|
|
57
|
+
}
|
|
58
|
+
// Extract from proxy headers
|
|
59
|
+
if (spec.proxy.spec.headers) {
|
|
60
|
+
Object.values(spec.proxy.spec.headers).forEach((value)=>{
|
|
61
|
+
if (typeof value === 'string') {
|
|
62
|
+
allVariables.push(...extractFromValue(value));
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return Array.from(new Set(allVariables)); // Remove duplicates
|
|
68
|
+
} catch {
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function getDatasourceVariablesFromCache(datasourceSelector, datasourceStore) {
|
|
73
|
+
try {
|
|
74
|
+
if (!datasourceStore.getDatasourceSpecSync) return [];
|
|
75
|
+
const datasourceSpec = datasourceStore.getDatasourceSpecSync(datasourceSelector);
|
|
76
|
+
return datasourceSpec ? extractDatasourceVariables(datasourceSpec) : [];
|
|
77
|
+
} catch {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
27
81
|
const PrometheusLabelValuesVariable = {
|
|
28
82
|
getVariableOptions: async (spec, ctx)=>{
|
|
29
83
|
const pluginDef = spec;
|
|
@@ -40,16 +94,28 @@ const PrometheusLabelValuesVariable = {
|
|
|
40
94
|
data: (0, _prometheusvariables.stringArrayToVariableOptions)(options)
|
|
41
95
|
};
|
|
42
96
|
},
|
|
43
|
-
dependsOn: (spec)=>{
|
|
97
|
+
dependsOn: (spec, ctx)=>{
|
|
44
98
|
const matcherVariables = spec.matchers?.map((m)=>(0, _pluginsystem.parseVariables)(m)).flat() || [];
|
|
45
99
|
const labelVariables = (0, _pluginsystem.parseVariables)(spec.labelName);
|
|
46
100
|
const datasourceVariables = spec.datasource && (0, _pluginsystem.isVariableDatasource)(spec.datasource) ? (0, _pluginsystem.parseVariables)(spec.datasource) : [];
|
|
101
|
+
let datasourceVariablesFromCache = [];
|
|
102
|
+
if (ctx?.datasourceStore && ctx?.variables) {
|
|
103
|
+
const datasourceValue = spec.datasource ?? _model.DEFAULT_PROM;
|
|
104
|
+
const datasourceSelector = typeof datasourceValue === 'string' ? {
|
|
105
|
+
kind: _model.PROM_DATASOURCE_KIND,
|
|
106
|
+
name: datasourceValue
|
|
107
|
+
} : datasourceValue;
|
|
108
|
+
datasourceVariablesFromCache = getDatasourceVariablesFromCache(datasourceSelector, ctx.datasourceStore);
|
|
109
|
+
}
|
|
110
|
+
const allDependencies = [
|
|
111
|
+
...matcherVariables,
|
|
112
|
+
...labelVariables,
|
|
113
|
+
...datasourceVariables,
|
|
114
|
+
...datasourceVariablesFromCache
|
|
115
|
+
];
|
|
116
|
+
const uniqueDependencies = Array.from(new Set(allDependencies));
|
|
47
117
|
return {
|
|
48
|
-
variables:
|
|
49
|
-
...matcherVariables,
|
|
50
|
-
...labelVariables,
|
|
51
|
-
...datasourceVariables
|
|
52
|
-
]
|
|
118
|
+
variables: uniqueDependencies
|
|
53
119
|
};
|
|
54
120
|
},
|
|
55
121
|
OptionsEditorComponent: _prometheusvariables.PrometheusLabelValuesVariableEditor,
|
|
@@ -21,6 +21,9 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
+
get getInterpolatedRequestOptions () {
|
|
25
|
+
return getInterpolatedRequestOptions;
|
|
26
|
+
},
|
|
24
27
|
get interpolateDatasourceProxyParams () {
|
|
25
28
|
return interpolateDatasourceProxyParams;
|
|
26
29
|
},
|
|
@@ -52,3 +55,7 @@ function interpolateDatasourceProxyParams(datasource, variableState) {
|
|
|
52
55
|
queryParams: rawQueryParams ? (0, _components.interpolateQueryParams)(rawQueryParams, variableState) : undefined
|
|
53
56
|
};
|
|
54
57
|
}
|
|
58
|
+
async function getInterpolatedRequestOptions(datasourceStore, datasource, variableState) {
|
|
59
|
+
const datasourceSpec = await datasourceStore.getDatasource(datasource);
|
|
60
|
+
return interpolateDatasourceProxyParams(datasourceSpec, variableState);
|
|
61
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/components/query.ts"],"names":[],"mappings":"AAcA,OAAO,EAAY,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAEL,6BAA6B,EAE7B,kBAAkB,EAEnB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/components/query.ts"],"names":[],"mappings":"AAcA,OAAO,EAAY,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAEL,6BAA6B,EAE7B,kBAAkB,EAEnB,MAAM,UAAU,CAAC;AAGlB,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,kBAAkB,EAC9B,OAAO,CAAC,EAAE,OAAO,GAChB,cAAc,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAgBjD;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,kBAAkB,EAC9B,OAAO,CAAC,EAAE,OAAO,GAChB,cAAc,CAAC,6BAA6B,EAAE,WAAW,CAAC,CAqB5D"}
|
package/lib/components/query.js
CHANGED
|
@@ -10,10 +10,13 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { useDatasourceClient } from '@perses-dev/plugin-system';
|
|
13
|
+
import { useDatasourceClient, useDatasourceStore, useVariableValues } from '@perses-dev/plugin-system';
|
|
14
14
|
import { useQuery } from '@tanstack/react-query';
|
|
15
|
+
import { getInterpolatedRequestOptions } from '../plugins/interpolation';
|
|
15
16
|
export function useParseQuery(content, datasource, enabled) {
|
|
16
17
|
const { data: client } = useDatasourceClient(datasource);
|
|
18
|
+
const datasourceStore = useDatasourceStore();
|
|
19
|
+
const variableState = useVariableValues();
|
|
17
20
|
return useQuery({
|
|
18
21
|
enabled: !!client && enabled,
|
|
19
22
|
queryKey: [
|
|
@@ -26,12 +29,15 @@ export function useParseQuery(content, datasource, enabled) {
|
|
|
26
29
|
const params = {
|
|
27
30
|
query: content
|
|
28
31
|
};
|
|
29
|
-
|
|
32
|
+
const interpolatedOptions = await getInterpolatedRequestOptions(datasourceStore, datasource, variableState);
|
|
33
|
+
return await client.parseQuery(params, interpolatedOptions);
|
|
30
34
|
}
|
|
31
35
|
});
|
|
32
36
|
}
|
|
33
37
|
export function useInstantQuery(content, datasource, enabled) {
|
|
34
38
|
const { data: client } = useDatasourceClient(datasource);
|
|
39
|
+
const datasourceStore = useDatasourceStore();
|
|
40
|
+
const variableState = useVariableValues();
|
|
35
41
|
return useQuery({
|
|
36
42
|
enabled: !!client && enabled,
|
|
37
43
|
// TODO: for some reason the caching is not working: identical nodes still fire their requests after each change made to the promQL
|
|
@@ -45,8 +51,9 @@ export function useInstantQuery(content, datasource, enabled) {
|
|
|
45
51
|
const params = {
|
|
46
52
|
query: content
|
|
47
53
|
};
|
|
54
|
+
const interpolatedOptions = await getInterpolatedRequestOptions(datasourceStore, datasource, variableState);
|
|
48
55
|
const startTime = performance.now();
|
|
49
|
-
const response = await client.instantQuery(params);
|
|
56
|
+
const response = await client.instantQuery(params, interpolatedOptions);
|
|
50
57
|
const responseTime = performance.now() - startTime;
|
|
51
58
|
return {
|
|
52
59
|
...response,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/query.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useDatasourceClient } from '@perses-dev/plugin-system';\nimport { useQuery, UseQueryResult } from '@tanstack/react-query';\nimport { DatasourceSelector } from '@perses-dev/spec';\nimport { StatusError } from '@perses-dev/client';\nimport {\n InstantQueryRequestParameters,\n MonitoredInstantQueryResponse,\n ParseQueryRequestParameters,\n ParseQueryResponse,\n PrometheusClient,\n} from '../model';\n\nexport function useParseQuery(\n content: string,\n datasource: DatasourceSelector,\n enabled?: boolean\n): UseQueryResult<ParseQueryResponse, StatusError> {\n const { data: client } = useDatasourceClient<PrometheusClient>(datasource);\n\n return useQuery<ParseQueryResponse, StatusError>({\n enabled: !!client && enabled,\n queryKey: ['parseQuery', content, 'datasource', datasource],\n queryFn: async () => {\n const params: ParseQueryRequestParameters = { query: content };\n\n return await client!.parseQuery(params);\n },\n });\n}\n\nexport function useInstantQuery(\n content: string,\n datasource: DatasourceSelector,\n enabled?: boolean\n): UseQueryResult<MonitoredInstantQueryResponse, StatusError> {\n const { data: client } = useDatasourceClient<PrometheusClient>(datasource);\n\n return useQuery<MonitoredInstantQueryResponse, StatusError>({\n enabled: !!client && enabled,\n // TODO: for some reason the caching is not working: identical nodes still fire their requests after each change made to the promQL\n queryKey: ['instantQuery', content, 'datasource', datasource.kind],\n queryFn: async () => {\n const params: InstantQueryRequestParameters = { query: content };\n const startTime = performance.now();\n const response = await client!.instantQuery(params);\n const responseTime = performance.now() - startTime;\n\n return { ...response, responseTime };\n },\n });\n}\n"],"names":["useDatasourceClient","useQuery","useParseQuery","content","datasource","enabled","data","client","queryKey","queryFn","params","query","parseQuery","useInstantQuery","kind","startTime","performance","now","response","instantQuery","responseTime"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,mBAAmB,QAAQ,4BAA4B;
|
|
1
|
+
{"version":3,"sources":["../../../src/components/query.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useDatasourceClient, useDatasourceStore, useVariableValues } from '@perses-dev/plugin-system';\nimport { useQuery, UseQueryResult } from '@tanstack/react-query';\nimport { DatasourceSelector } from '@perses-dev/spec';\nimport { StatusError } from '@perses-dev/client';\nimport {\n InstantQueryRequestParameters,\n MonitoredInstantQueryResponse,\n ParseQueryRequestParameters,\n ParseQueryResponse,\n PrometheusClient,\n} from '../model';\nimport { getInterpolatedRequestOptions } from '../plugins/interpolation';\n\nexport function useParseQuery(\n content: string,\n datasource: DatasourceSelector,\n enabled?: boolean\n): UseQueryResult<ParseQueryResponse, StatusError> {\n const { data: client } = useDatasourceClient<PrometheusClient>(datasource);\n const datasourceStore = useDatasourceStore();\n const variableState = useVariableValues();\n\n return useQuery<ParseQueryResponse, StatusError>({\n enabled: !!client && enabled,\n queryKey: ['parseQuery', content, 'datasource', datasource],\n queryFn: async () => {\n const params: ParseQueryRequestParameters = { query: content };\n\n const interpolatedOptions = await getInterpolatedRequestOptions(datasourceStore, datasource, variableState);\n\n return await client!.parseQuery(params, interpolatedOptions);\n },\n });\n}\n\nexport function useInstantQuery(\n content: string,\n datasource: DatasourceSelector,\n enabled?: boolean\n): UseQueryResult<MonitoredInstantQueryResponse, StatusError> {\n const { data: client } = useDatasourceClient<PrometheusClient>(datasource);\n const datasourceStore = useDatasourceStore();\n const variableState = useVariableValues();\n\n return useQuery<MonitoredInstantQueryResponse, StatusError>({\n enabled: !!client && enabled,\n // TODO: for some reason the caching is not working: identical nodes still fire their requests after each change made to the promQL\n queryKey: ['instantQuery', content, 'datasource', datasource.kind],\n queryFn: async () => {\n const params: InstantQueryRequestParameters = { query: content };\n\n const interpolatedOptions = await getInterpolatedRequestOptions(datasourceStore, datasource, variableState);\n\n const startTime = performance.now();\n const response = await client!.instantQuery(params, interpolatedOptions);\n const responseTime = performance.now() - startTime;\n\n return { ...response, responseTime };\n },\n });\n}\n"],"names":["useDatasourceClient","useDatasourceStore","useVariableValues","useQuery","getInterpolatedRequestOptions","useParseQuery","content","datasource","enabled","data","client","datasourceStore","variableState","queryKey","queryFn","params","query","interpolatedOptions","parseQuery","useInstantQuery","kind","startTime","performance","now","response","instantQuery","responseTime"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,mBAAmB,EAAEC,kBAAkB,EAAEC,iBAAiB,QAAQ,4BAA4B;AACvG,SAASC,QAAQ,QAAwB,wBAAwB;AAUjE,SAASC,6BAA6B,QAAQ,2BAA2B;AAEzE,OAAO,SAASC,cACdC,OAAe,EACfC,UAA8B,EAC9BC,OAAiB;IAEjB,MAAM,EAAEC,MAAMC,MAAM,EAAE,GAAGV,oBAAsCO;IAC/D,MAAMI,kBAAkBV;IACxB,MAAMW,gBAAgBV;IAEtB,OAAOC,SAA0C;QAC/CK,SAAS,CAAC,CAACE,UAAUF;QACrBK,UAAU;YAAC;YAAcP;YAAS;YAAcC;SAAW;QAC3DO,SAAS;YACP,MAAMC,SAAsC;gBAAEC,OAAOV;YAAQ;YAE7D,MAAMW,sBAAsB,MAAMb,8BAA8BO,iBAAiBJ,YAAYK;YAE7F,OAAO,MAAMF,OAAQQ,UAAU,CAACH,QAAQE;QAC1C;IACF;AACF;AAEA,OAAO,SAASE,gBACdb,OAAe,EACfC,UAA8B,EAC9BC,OAAiB;IAEjB,MAAM,EAAEC,MAAMC,MAAM,EAAE,GAAGV,oBAAsCO;IAC/D,MAAMI,kBAAkBV;IACxB,MAAMW,gBAAgBV;IAEtB,OAAOC,SAAqD;QAC1DK,SAAS,CAAC,CAACE,UAAUF;QACrB,mIAAmI;QACnIK,UAAU;YAAC;YAAgBP;YAAS;YAAcC,WAAWa,IAAI;SAAC;QAClEN,SAAS;YACP,MAAMC,SAAwC;gBAAEC,OAAOV;YAAQ;YAE/D,MAAMW,sBAAsB,MAAMb,8BAA8BO,iBAAiBJ,YAAYK;YAE7F,MAAMS,YAAYC,YAAYC,GAAG;YACjC,MAAMC,WAAW,MAAMd,OAAQe,YAAY,CAACV,QAAQE;YACpD,MAAMS,eAAeJ,YAAYC,GAAG,KAAKF;YAEzC,OAAO;gBAAE,GAAGG,QAAQ;gBAAEE;YAAa;QACrC;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/explore/PrometheusMetricsFinder/utils.ts"],"names":[],"mappings":"AAcA,OAAO,EAAY,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAGL,mBAAmB,EACnB,MAAM,EACN,cAAc,EAMf,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/explore/PrometheusMetricsFinder/utils.ts"],"names":[],"mappings":"AAcA,OAAO,EAAY,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAA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
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { useDatasourceClient, useTimeRange } from '@perses-dev/plugin-system';
|
|
13
|
+
import { useDatasourceClient, useTimeRange, useVariableValues, useDatasourceStore } from '@perses-dev/plugin-system';
|
|
14
14
|
import { useQuery } from '@tanstack/react-query';
|
|
15
15
|
import { useMemo } from 'react';
|
|
16
|
+
import { getInterpolatedRequestOptions } from '../../plugins/interpolation';
|
|
16
17
|
import { computeFilterExpr } from './types';
|
|
17
18
|
// Retrieve metric metadata from the Prometheus API
|
|
18
19
|
export function useMetricMetadata(metricName, datasource, enabled) {
|
|
19
20
|
const { data: client } = useDatasourceClient(datasource);
|
|
21
|
+
const datasourceStore = useDatasourceStore();
|
|
22
|
+
const variableState = useVariableValues();
|
|
20
23
|
// histograms and summaries timeseries desc are not always added to prefixed timeseries
|
|
21
24
|
const name = metricName.replace(/(_count|_sum|_bucket)$/, '');
|
|
22
25
|
const { data, isLoading, error } = useQuery({
|
|
@@ -29,7 +32,8 @@ export function useMetricMetadata(metricName, datasource, enabled) {
|
|
|
29
32
|
const params = {
|
|
30
33
|
metric: name
|
|
31
34
|
};
|
|
32
|
-
|
|
35
|
+
const interpolatedOptions = await getInterpolatedRequestOptions(datasourceStore, datasource, variableState);
|
|
36
|
+
return await client.metricMetadata(params, interpolatedOptions);
|
|
33
37
|
}
|
|
34
38
|
});
|
|
35
39
|
// Find the first result with help text
|
|
@@ -53,6 +57,8 @@ export function useMetricMetadata(metricName, datasource, enabled) {
|
|
|
53
57
|
export function useLabels(filters, datasource) {
|
|
54
58
|
const { absoluteTimeRange: { start, end } } = useTimeRange();
|
|
55
59
|
const { data: client } = useDatasourceClient(datasource);
|
|
60
|
+
const datasourceStore = useDatasourceStore();
|
|
61
|
+
const variableState = useVariableValues();
|
|
56
62
|
return useQuery({
|
|
57
63
|
enabled: !!client,
|
|
58
64
|
queryKey: [
|
|
@@ -76,7 +82,8 @@ export function useLabels(filters, datasource) {
|
|
|
76
82
|
`{${computeFilterExpr(filters)}}`
|
|
77
83
|
];
|
|
78
84
|
}
|
|
79
|
-
|
|
85
|
+
const interpolatedOptions = await getInterpolatedRequestOptions(datasourceStore, datasource, variableState);
|
|
86
|
+
return await client.labelNames(params, interpolatedOptions);
|
|
80
87
|
}
|
|
81
88
|
});
|
|
82
89
|
}
|
|
@@ -84,6 +91,8 @@ export function useLabels(filters, datasource) {
|
|
|
84
91
|
export function useLabelValues(labelName, filters, datasource) {
|
|
85
92
|
const { absoluteTimeRange: { start, end } } = useTimeRange();
|
|
86
93
|
const { data: client } = useDatasourceClient(datasource);
|
|
94
|
+
const datasourceStore = useDatasourceStore();
|
|
95
|
+
const variableState = useVariableValues();
|
|
87
96
|
return useQuery({
|
|
88
97
|
enabled: !!client,
|
|
89
98
|
queryKey: [
|
|
@@ -108,7 +117,8 @@ export function useLabelValues(labelName, filters, datasource) {
|
|
|
108
117
|
`{${computeFilterExpr(filters)}}`
|
|
109
118
|
];
|
|
110
119
|
}
|
|
111
|
-
|
|
120
|
+
const interpolatedOptions = await getInterpolatedRequestOptions(datasourceStore, datasource, variableState);
|
|
121
|
+
return await client.labelValues(params, interpolatedOptions);
|
|
112
122
|
}
|
|
113
123
|
});
|
|
114
124
|
}
|
|
@@ -117,6 +127,8 @@ export function useLabelValues(labelName, filters, datasource) {
|
|
|
117
127
|
export function useSeriesStates(metricName, filters, datasource) {
|
|
118
128
|
const { absoluteTimeRange: { start, end } } = useTimeRange();
|
|
119
129
|
const { data: client } = useDatasourceClient(datasource);
|
|
130
|
+
const datasourceStore = useDatasourceStore();
|
|
131
|
+
const variableState = useVariableValues();
|
|
120
132
|
const { data: seriesData, isLoading, isError, error } = useQuery({
|
|
121
133
|
enabled: !!client,
|
|
122
134
|
queryKey: [
|
|
@@ -138,7 +150,8 @@ export function useSeriesStates(metricName, filters, datasource) {
|
|
|
138
150
|
start: start.valueOf() / 1000,
|
|
139
151
|
end: end.valueOf() / 1000
|
|
140
152
|
};
|
|
141
|
-
|
|
153
|
+
const interpolatedOptions = await getInterpolatedRequestOptions(datasourceStore, datasource, variableState);
|
|
154
|
+
return await client.series(params, interpolatedOptions);
|
|
142
155
|
}
|
|
143
156
|
});
|
|
144
157
|
const labelValueCounters = useMemo(()=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/explore/PrometheusMetricsFinder/utils.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useDatasourceClient, useTimeRange } from '@perses-dev/plugin-system';\nimport { useQuery, UseQueryResult } from '@tanstack/react-query';\nimport { useMemo } from 'react';\nimport { DatasourceSelector } from '@perses-dev/spec';\nimport { StatusError } from '@perses-dev/client';\nimport {\n LabelNamesRequestParameters,\n LabelValuesRequestParameters,\n LabelValuesResponse,\n Metric,\n MetricMetadata,\n MetricMetadataRequestParameters,\n MetricMetadataResponse,\n PrometheusClient,\n SeriesRequestParameters,\n SeriesResponse,\n} from '../../model';\nimport { computeFilterExpr, LabelFilter, LabelValueCounter } from './types';\n\n// Retrieve metric metadata from the Prometheus API\nexport function useMetricMetadata(\n metricName: string,\n datasource: DatasourceSelector,\n enabled?: boolean\n): {\n isLoading: false | true;\n metadata: MetricMetadata | undefined;\n error: StatusError | null;\n} {\n const { data: client } = useDatasourceClient<PrometheusClient>(datasource);\n\n // histograms and summaries timeseries desc are not always added to prefixed timeseries\n const name = metricName.replace(/(_count|_sum|_bucket)$/, '');\n\n const { data, isLoading, error } = useQuery<MetricMetadataResponse, StatusError>({\n enabled: !!client && enabled,\n queryKey: ['metricMetadata', name], // Not indexed on datasource, assuming a metric metadata should be similar across datasources\n queryFn: async () => {\n const params: MetricMetadataRequestParameters = { metric: name };\n\n return await client!.metricMetadata(params);\n },\n });\n\n // Find the first result with help text\n const metadata: MetricMetadata | undefined = useMemo(() => {\n for (const metric of data?.data?.[name] ?? []) {\n if (metric.help.length > 0) {\n return metric;\n }\n }\n return undefined;\n }, [data, name]);\n\n return { metadata, isLoading, error };\n}\n\nexport function useLabels(\n filters: LabelFilter[],\n datasource: DatasourceSelector\n): UseQueryResult<LabelValuesResponse, StatusError> {\n const {\n absoluteTimeRange: { start, end },\n } = useTimeRange();\n const { data: client } = useDatasourceClient<PrometheusClient>(datasource);\n\n return useQuery<LabelValuesResponse, StatusError>({\n enabled: !!client,\n queryKey: ['labels', 'datasource', datasource.name, 'start', start, 'end', end, 'filters', ...filters],\n queryFn: async () => {\n const params: LabelNamesRequestParameters = {\n start: start.valueOf() / 1000,\n end: end.valueOf() / 1000,\n };\n if (filters.length) {\n params['match[]'] = [`{${computeFilterExpr(filters)}}`];\n }\n\n return await client!.labelNames(params);\n },\n });\n}\n\n// Retrieve label values from the Prometheus API for a given label name and filters\nexport function useLabelValues(\n labelName: string,\n filters: LabelFilter[],\n datasource: DatasourceSelector\n): UseQueryResult<LabelValuesResponse, StatusError> {\n const {\n absoluteTimeRange: { start, end },\n } = useTimeRange();\n const { data: client } = useDatasourceClient<PrometheusClient>(datasource);\n\n return useQuery<LabelValuesResponse, StatusError>({\n enabled: !!client,\n queryKey: ['labelValues', labelName, 'datasource', datasource.name, 'start', start, 'end', 'filters', ...filters],\n queryFn: async () => {\n const params: LabelValuesRequestParameters = {\n labelName: labelName,\n start: start.valueOf() / 1000,\n end: end.valueOf() / 1000,\n };\n if (filters.length) {\n params['match[]'] = [`{${computeFilterExpr(filters)}}`];\n }\n\n return await client!.labelValues(params);\n },\n });\n}\n\n// Retrieve series from the Prometheus API for a given metric name and filters\n// Also computes the number of times a label value appears for the given metric name and filters\nexport function useSeriesStates(\n metricName: string,\n filters: LabelFilter[],\n datasource: DatasourceSelector\n): {\n series: Metric[] | undefined;\n labelValueCounters: Map<string, Array<{ labelValue: string; counter: number }>>;\n isLoading: boolean;\n isError: boolean;\n error: StatusError | null;\n} {\n const {\n absoluteTimeRange: { start, end },\n } = useTimeRange();\n const { data: client } = useDatasourceClient<PrometheusClient>(datasource);\n\n const {\n data: seriesData,\n isLoading,\n isError,\n error,\n } = useQuery<SeriesResponse, StatusError>({\n enabled: !!client,\n queryKey: ['series', metricName, 'datasource', datasource, 'start', start, 'end', 'filters', ...filters],\n queryFn: async () => {\n const params: SeriesRequestParameters = {\n 'match[]': [`{${computeFilterExpr(filters)}}`],\n start: start.valueOf() / 1000,\n end: end.valueOf() / 1000,\n };\n\n return await client!.series(params);\n },\n });\n\n const labelValueCounters: Map<string, Array<{ labelValue: string; counter: number }>> = useMemo(() => {\n const result = new Map<string, LabelValueCounter[]>();\n if (seriesData?.data === undefined) {\n return result;\n }\n\n for (const series of seriesData.data) {\n for (const [label, value] of Object.entries(series)) {\n const labelCounters = result.get(label);\n if (labelCounters === undefined) {\n result.set(label, [{ labelValue: value, counter: 1 }]);\n continue;\n }\n\n const labelValueCounter = labelCounters.find((counter) => counter.labelValue === value);\n if (labelValueCounter === undefined) {\n labelCounters.push({ labelValue: value, counter: 1 });\n } else {\n labelValueCounter.counter += 1;\n }\n }\n }\n\n return result;\n }, [seriesData]);\n\n return { series: seriesData?.data, labelValueCounters, isLoading, isError, error };\n}\n"],"names":["useDatasourceClient","useTimeRange","useQuery","useMemo","computeFilterExpr","useMetricMetadata","metricName","datasource","enabled","data","client","name","replace","isLoading","error","queryKey","queryFn","params","metric","metricMetadata","metadata","help","length","undefined","useLabels","filters","absoluteTimeRange","start","end","valueOf","labelNames","useLabelValues","labelName","labelValues","useSeriesStates","seriesData","isError","series","labelValueCounters","result","Map","label","value","Object","entries","labelCounters","get","set","labelValue","counter","labelValueCounter","find","push"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE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zB;QAAWuB;QAAStB;IAAM;AACnF"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/explore/PrometheusMetricsFinder/utils.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useDatasourceClient, useTimeRange, useVariableValues, useDatasourceStore } from '@perses-dev/plugin-system';\nimport { useQuery, UseQueryResult } from '@tanstack/react-query';\nimport { useMemo } from 'react';\nimport { DatasourceSelector } from '@perses-dev/spec';\nimport { StatusError } from '@perses-dev/client';\nimport {\n LabelNamesRequestParameters,\n LabelValuesRequestParameters,\n LabelValuesResponse,\n Metric,\n MetricMetadata,\n MetricMetadataRequestParameters,\n MetricMetadataResponse,\n PrometheusClient,\n SeriesRequestParameters,\n SeriesResponse,\n} from '../../model';\nimport { getInterpolatedRequestOptions } from '../../plugins/interpolation';\nimport { computeFilterExpr, LabelFilter, LabelValueCounter } from './types';\n\n// Retrieve metric metadata from the Prometheus API\nexport function useMetricMetadata(\n metricName: string,\n datasource: DatasourceSelector,\n enabled?: boolean\n): {\n isLoading: false | true;\n metadata: MetricMetadata | undefined;\n error: StatusError | null;\n} {\n const { data: client } = useDatasourceClient<PrometheusClient>(datasource);\n const datasourceStore = useDatasourceStore();\n const variableState = useVariableValues();\n\n // histograms and summaries timeseries desc are not always added to prefixed timeseries\n const name = metricName.replace(/(_count|_sum|_bucket)$/, '');\n\n const { data, isLoading, error } = useQuery<MetricMetadataResponse, StatusError>({\n enabled: !!client && enabled,\n queryKey: ['metricMetadata', name], // Not indexed on datasource, assuming a metric metadata should be similar across datasources\n queryFn: async () => {\n const params: MetricMetadataRequestParameters = { metric: name };\n\n const interpolatedOptions = await getInterpolatedRequestOptions(datasourceStore, datasource, variableState);\n\n return await client!.metricMetadata(params, interpolatedOptions);\n },\n });\n\n // Find the first result with help text\n const metadata: MetricMetadata | undefined = useMemo(() => {\n for (const metric of data?.data?.[name] ?? []) {\n if (metric.help.length > 0) {\n return metric;\n }\n }\n return undefined;\n }, [data, name]);\n\n return { metadata, isLoading, error };\n}\n\nexport function useLabels(\n filters: LabelFilter[],\n datasource: DatasourceSelector\n): UseQueryResult<LabelValuesResponse, StatusError> {\n const {\n absoluteTimeRange: { start, end },\n } = useTimeRange();\n const { data: client } = useDatasourceClient<PrometheusClient>(datasource);\n const datasourceStore = useDatasourceStore();\n const variableState = useVariableValues();\n\n return useQuery<LabelValuesResponse, StatusError>({\n enabled: !!client,\n queryKey: ['labels', 'datasource', datasource.name, 'start', start, 'end', end, 'filters', ...filters],\n queryFn: async () => {\n const params: LabelNamesRequestParameters = {\n start: start.valueOf() / 1000,\n end: end.valueOf() / 1000,\n };\n if (filters.length) {\n params['match[]'] = [`{${computeFilterExpr(filters)}}`];\n }\n\n const interpolatedOptions = await getInterpolatedRequestOptions(datasourceStore, datasource, variableState);\n\n return await client!.labelNames(params, interpolatedOptions);\n },\n });\n}\n\n// Retrieve label values from the Prometheus API for a given label name and filters\nexport function useLabelValues(\n labelName: string,\n filters: LabelFilter[],\n datasource: DatasourceSelector\n): UseQueryResult<LabelValuesResponse, StatusError> {\n const {\n absoluteTimeRange: { start, end },\n } = useTimeRange();\n const { data: client } = useDatasourceClient<PrometheusClient>(datasource);\n const datasourceStore = useDatasourceStore();\n const variableState = useVariableValues();\n\n return useQuery<LabelValuesResponse, StatusError>({\n enabled: !!client,\n queryKey: ['labelValues', labelName, 'datasource', datasource.name, 'start', start, 'end', 'filters', ...filters],\n queryFn: async () => {\n const params: LabelValuesRequestParameters = {\n labelName: labelName,\n start: start.valueOf() / 1000,\n end: end.valueOf() / 1000,\n };\n if (filters.length) {\n params['match[]'] = [`{${computeFilterExpr(filters)}}`];\n }\n\n const interpolatedOptions = await getInterpolatedRequestOptions(datasourceStore, datasource, variableState);\n\n return await client!.labelValues(params, interpolatedOptions);\n },\n });\n}\n\n// Retrieve series from the Prometheus API for a given metric name and filters\n// Also computes the number of times a label value appears for the given metric name and filters\nexport function useSeriesStates(\n metricName: string,\n filters: LabelFilter[],\n datasource: DatasourceSelector\n): {\n series: Metric[] | undefined;\n labelValueCounters: Map<string, Array<{ labelValue: string; counter: number }>>;\n isLoading: boolean;\n isError: boolean;\n error: StatusError | null;\n} {\n const {\n absoluteTimeRange: { start, end },\n } = useTimeRange();\n const { data: client } = useDatasourceClient<PrometheusClient>(datasource);\n const datasourceStore = useDatasourceStore();\n const variableState = useVariableValues();\n\n const {\n data: seriesData,\n isLoading,\n isError,\n error,\n } = useQuery<SeriesResponse, StatusError>({\n enabled: !!client,\n queryKey: ['series', metricName, 'datasource', datasource, 'start', start, 'end', 'filters', ...filters],\n queryFn: async () => {\n const params: SeriesRequestParameters = {\n 'match[]': [`{${computeFilterExpr(filters)}}`],\n start: start.valueOf() / 1000,\n end: end.valueOf() / 1000,\n };\n\n const interpolatedOptions = await getInterpolatedRequestOptions(datasourceStore, datasource, variableState);\n\n return await client!.series(params, interpolatedOptions);\n },\n });\n\n const labelValueCounters: Map<string, Array<{ labelValue: string; counter: number }>> = useMemo(() => {\n const result = new Map<string, LabelValueCounter[]>();\n if (seriesData?.data === undefined) {\n return result;\n }\n\n for (const series of seriesData.data) {\n for (const [label, value] of Object.entries(series)) {\n const labelCounters = result.get(label);\n if (labelCounters === undefined) {\n result.set(label, [{ labelValue: value, counter: 1 }]);\n continue;\n }\n\n const labelValueCounter = labelCounters.find((counter) => counter.labelValue === value);\n if (labelValueCounter === undefined) {\n labelCounters.push({ labelValue: value, counter: 1 });\n } else {\n labelValueCounter.counter += 1;\n }\n }\n }\n\n return result;\n }, [seriesData]);\n\n return { series: seriesData?.data, labelValueCounters, isLoading, isError, error };\n}\n"],"names":["useDatasourceClient","useTimeRange","useVariableValues","useDatasourceStore","useQuery","useMemo","getInterpolatedRequestOptions","computeFilterExpr","useMetricMetadata","metricName","datasource","enabled","data","client","datasourceStore","variableState","name","replace","isLoading","error","queryKey","queryFn","params","metric","interpolatedOptions","metricMetadata","metadata","help","length","undefined","useLabels","filters","absoluteTimeRange","start","end","valueOf","labelNames","useLabelValues","labelName","labelValues","useSeriesStates","seriesData","isError","series","labelValueCounters","result","Map","label","value","Object","entries","labelCounters","get","set","labelValue","counter","labelValueCounter","find","push"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,mBAAmB,EAAEC,YAAY,EAAEC,iBAAiB,EAAEC,kBAAkB,QAAQ,4BAA4B;AACrH,SAASC,QAAQ,QAAwB,wBAAwB;AACjE,SAASC,OAAO,QAAQ,QAAQ;AAehC,SAASC,6BAA6B,QAAQ,8BAA8B;AAC5E,SAASC,iBAAiB,QAAwC,UAAU;AAE5E,mDAAmD;AACnD,OAAO,SAASC,kBACdC,UAAkB,EAClBC,UAA8B,EAC9BC,OAAiB;IAMjB,MAAM,EAAEC,MAAMC,MAAM,EAAE,GAAGb,oBAAsCU;IAC/D,MAAMI,kBAAkBX;IACxB,MAAMY,gBAAgBb;IAEtB,uFAAuF;IACvF,MAAMc,OAAOP,WAAWQ,OAAO,CAAC,0BAA0B;IAE1D,MAAM,EAAEL,IAAI,EAAEM,SAAS,EAAEC,KAAK,EAAE,GAAGf,SAA8C;QAC/EO,SAAS,CAAC,CAACE,UAAUF;QACrBS,UAAU;YAAC;YAAkBJ;SAAK;QAClCK,SAAS;YACP,MAAMC,SAA0C;gBAAEC,QAAQP;YAAK;YAE/D,MAAMQ,sBAAsB,MAAMlB,8BAA8BQ,iBAAiBJ,YAAYK;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ACzBD,KAAKA,IAAIC,OAAO,KAAK;YACvB;YAEA,MAAMX,sBAAsB,MAAMlB,8BAA8BQ,iBAAiBJ,YAAYK;YAE7F,OAAO,MAAMF,OAAQ8B,MAAM,CAACrB,QAAQE;QACtC;IACF;IAEA,MAAMoB,qBAAkFvC,QAAQ;QAC9F,MAAMwC,SAAS,IAAIC;QACnB,IAAIL,YAAY7B,SAASiB,WAAW;YAClC,OAAOgB;QACT;QAEA,KAAK,MAAMF,UAAUF,WAAW7B,IAAI,CAAE;YACpC,KAAK,MAAM,CAACmC,OAAOC,MAAM,IAAIC,OAAOC,OAAO,CAACP,QAAS;gBACnD,MAAMQ,gBAAgBN,OAAOO,GAAG,CAACL;gBACjC,IAAII,kBAAkBtB,WAAW;oBAC/BgB,OAAOQ,GAAG,CAACN,OAAO;wBAAC;4BAAEO,YAAYN;4BAAOO,SAAS;wBAAE;qBAAE;oBACrD;gBACF;gBAEA,MAAMC,oBAAoBL,cAAcM,IAAI,CAAC,CAACF,UAAYA,QAAQD,UAAU,KAAKN;gBACjF,IAAIQ,sBAAsB3B,WAAW;oBACnCsB,cAAcO,IAAI,CAAC;wBAAEJ,YAAYN;wBAAOO,SAAS;oBAAE;gBACrD,OAAO;oBACLC,kBAAkBD,OAAO,IAAI;gBAC/B;YACF;QACF;QAEA,OAAOV;IACT,GAAG;QAACJ;KAAW;IAEf,OAAO;QAAEE,QAAQF,YAAY7B;QAAMgC;QAAoB1B;QAAWwB;QAASvB;IAAM;AACnF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrometheusLabelValuesVariable.d.ts","sourceRoot":"","sources":["../../../src/plugins/PrometheusLabelValuesVariable.tsx"],"names":[],"mappings":"AAaA,OAAO,EACL,cAAc,
|
|
1
|
+
{"version":3,"file":"PrometheusLabelValuesVariable.d.ts","sourceRoot":"","sources":["../../../src/plugins/PrometheusLabelValuesVariable.tsx"],"names":[],"mappings":"AAaA,OAAO,EACL,cAAc,EAOf,MAAM,2BAA2B,CAAC;AAKnC,OAAO,EAAE,oCAAoC,EAA4B,MAAM,SAAS,CAAC;AAuEzF,eAAO,MAAM,6BAA6B,EAAE,cAAc,CAAC,oCAAoC,CA2D9F,CAAC"}
|
|
@@ -14,6 +14,60 @@ import { replaceVariables, parseVariables, datasourceSelectValueToSelector, isVa
|
|
|
14
14
|
import { DEFAULT_PROM, getPrometheusTimeRange, PROM_DATASOURCE_KIND } from '../model';
|
|
15
15
|
import { stringArrayToVariableOptions, PrometheusLabelValuesVariableEditor } from './prometheus-variables';
|
|
16
16
|
import { resolvePrometheusDatasource } from './interpolation';
|
|
17
|
+
function extractDatasourceVariables(datasourceSpec) {
|
|
18
|
+
try {
|
|
19
|
+
const spec = datasourceSpec.plugin.spec;
|
|
20
|
+
// Pure function to extract variables from string or array values
|
|
21
|
+
const extractFromValue = (value)=>{
|
|
22
|
+
if (typeof value === 'string') {
|
|
23
|
+
return parseVariables(value);
|
|
24
|
+
} else if (Array.isArray(value)) {
|
|
25
|
+
return value.flatMap((item)=>{
|
|
26
|
+
return typeof item === 'string' ? parseVariables(item) : [];
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return [];
|
|
30
|
+
};
|
|
31
|
+
const allVariables = [];
|
|
32
|
+
// Extract variables from queryParams
|
|
33
|
+
if (spec.queryParams) {
|
|
34
|
+
Object.values(spec.queryParams).forEach((value)=>{
|
|
35
|
+
allVariables.push(...extractFromValue(value));
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
// Extract variables from directUrl
|
|
39
|
+
if (spec.directUrl) {
|
|
40
|
+
allVariables.push(...extractFromValue(spec.directUrl));
|
|
41
|
+
}
|
|
42
|
+
// Extract variables from proxy configuration
|
|
43
|
+
if (spec.proxy?.spec) {
|
|
44
|
+
// Extract from proxy URL
|
|
45
|
+
if (spec.proxy.spec.url) {
|
|
46
|
+
allVariables.push(...extractFromValue(spec.proxy.spec.url));
|
|
47
|
+
}
|
|
48
|
+
// Extract from proxy headers
|
|
49
|
+
if (spec.proxy.spec.headers) {
|
|
50
|
+
Object.values(spec.proxy.spec.headers).forEach((value)=>{
|
|
51
|
+
if (typeof value === 'string') {
|
|
52
|
+
allVariables.push(...extractFromValue(value));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return Array.from(new Set(allVariables)); // Remove duplicates
|
|
58
|
+
} catch {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function getDatasourceVariablesFromCache(datasourceSelector, datasourceStore) {
|
|
63
|
+
try {
|
|
64
|
+
if (!datasourceStore.getDatasourceSpecSync) return [];
|
|
65
|
+
const datasourceSpec = datasourceStore.getDatasourceSpecSync(datasourceSelector);
|
|
66
|
+
return datasourceSpec ? extractDatasourceVariables(datasourceSpec) : [];
|
|
67
|
+
} catch {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
17
71
|
export const PrometheusLabelValuesVariable = {
|
|
18
72
|
getVariableOptions: async (spec, ctx)=>{
|
|
19
73
|
const pluginDef = spec;
|
|
@@ -30,16 +84,28 @@ export const PrometheusLabelValuesVariable = {
|
|
|
30
84
|
data: stringArrayToVariableOptions(options)
|
|
31
85
|
};
|
|
32
86
|
},
|
|
33
|
-
dependsOn: (spec)=>{
|
|
87
|
+
dependsOn: (spec, ctx)=>{
|
|
34
88
|
const matcherVariables = spec.matchers?.map((m)=>parseVariables(m)).flat() || [];
|
|
35
89
|
const labelVariables = parseVariables(spec.labelName);
|
|
36
90
|
const datasourceVariables = spec.datasource && isVariableDatasource(spec.datasource) ? parseVariables(spec.datasource) : [];
|
|
91
|
+
let datasourceVariablesFromCache = [];
|
|
92
|
+
if (ctx?.datasourceStore && ctx?.variables) {
|
|
93
|
+
const datasourceValue = spec.datasource ?? DEFAULT_PROM;
|
|
94
|
+
const datasourceSelector = typeof datasourceValue === 'string' ? {
|
|
95
|
+
kind: PROM_DATASOURCE_KIND,
|
|
96
|
+
name: datasourceValue
|
|
97
|
+
} : datasourceValue;
|
|
98
|
+
datasourceVariablesFromCache = getDatasourceVariablesFromCache(datasourceSelector, ctx.datasourceStore);
|
|
99
|
+
}
|
|
100
|
+
const allDependencies = [
|
|
101
|
+
...matcherVariables,
|
|
102
|
+
...labelVariables,
|
|
103
|
+
...datasourceVariables,
|
|
104
|
+
...datasourceVariablesFromCache
|
|
105
|
+
];
|
|
106
|
+
const uniqueDependencies = Array.from(new Set(allDependencies));
|
|
37
107
|
return {
|
|
38
|
-
variables:
|
|
39
|
-
...matcherVariables,
|
|
40
|
-
...labelVariables,
|
|
41
|
-
...datasourceVariables
|
|
42
|
-
]
|
|
108
|
+
variables: uniqueDependencies
|
|
43
109
|
};
|
|
44
110
|
},
|
|
45
111
|
OptionsEditorComponent: PrometheusLabelValuesVariableEditor,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugins/PrometheusLabelValuesVariable.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {\n VariablePlugin,\n GetVariableOptionsContext,\n replaceVariables,\n parseVariables,\n datasourceSelectValueToSelector,\n isVariableDatasource,\n} from '@perses-dev/plugin-system';\nimport { DEFAULT_PROM, getPrometheusTimeRange, PROM_DATASOURCE_KIND } from '../model';\nimport { stringArrayToVariableOptions, PrometheusLabelValuesVariableEditor } from './prometheus-variables';\nimport { resolvePrometheusDatasource } from './interpolation';\nimport { PrometheusLabelValuesVariableOptions } from './types';\n\nexport const PrometheusLabelValuesVariable: VariablePlugin<PrometheusLabelValuesVariableOptions> = {\n getVariableOptions: async (spec: PrometheusLabelValuesVariableOptions, ctx: GetVariableOptionsContext) => {\n const pluginDef = spec;\n const datasourceSelector =\n datasourceSelectValueToSelector(\n spec.datasource ?? DEFAULT_PROM,\n ctx.variables,\n await ctx.datasourceStore.listDatasourceSelectItems(PROM_DATASOURCE_KIND)\n ) ?? DEFAULT_PROM;\n const { client, requestOptions } = await resolvePrometheusDatasource(\n ctx.datasourceStore,\n datasourceSelector,\n ctx.variables\n );\n const match = pluginDef.matchers ? pluginDef.matchers.map((m) => replaceVariables(m, ctx.variables)) : undefined;\n\n const timeRange = getPrometheusTimeRange(ctx.timeRange);\n\n const { data: options } = await client.labelValues(\n {\n labelName: replaceVariables(pluginDef.labelName, ctx.variables),\n 'match[]': match,\n ...timeRange,\n },\n requestOptions\n );\n return {\n data: stringArrayToVariableOptions(options),\n };\n },\n dependsOn: (spec: PrometheusLabelValuesVariableOptions) => {\n const matcherVariables = spec.matchers?.map((m) => parseVariables(m)).flat() || [];\n const labelVariables = parseVariables(spec.labelName);\n const datasourceVariables =\n spec.datasource && isVariableDatasource(spec.datasource) ? parseVariables(spec.datasource) : [];\n
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/PrometheusLabelValuesVariable.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {\n VariablePlugin,\n GetVariableOptionsContext,\n replaceVariables,\n parseVariables,\n datasourceSelectValueToSelector,\n isVariableDatasource,\n DatasourceStore,\n} from '@perses-dev/plugin-system';\nimport { DatasourceSelector, DatasourceSpec } from '@perses-dev/spec';\nimport { DEFAULT_PROM, getPrometheusTimeRange, PROM_DATASOURCE_KIND } from '../model';\nimport { stringArrayToVariableOptions, PrometheusLabelValuesVariableEditor } from './prometheus-variables';\nimport { resolvePrometheusDatasource } from './interpolation';\nimport { PrometheusLabelValuesVariableOptions, PrometheusDatasourceSpec } from './types';\n\nfunction extractDatasourceVariables(datasourceSpec: DatasourceSpec<PrometheusDatasourceSpec>): string[] {\n try {\n const spec = datasourceSpec.plugin.spec;\n\n // Pure function to extract variables from string or array values\n const extractFromValue = (value: string | string[]): string[] => {\n if (typeof value === 'string') {\n return parseVariables(value);\n } else if (Array.isArray(value)) {\n return value.flatMap((item) => {\n return typeof item === 'string' ? parseVariables(item) : [];\n });\n }\n return [];\n };\n\n const allVariables: string[] = [];\n\n // Extract variables from queryParams\n if (spec.queryParams) {\n Object.values(spec.queryParams).forEach((value) => {\n allVariables.push(...extractFromValue(value));\n });\n }\n\n // Extract variables from directUrl\n if (spec.directUrl) {\n allVariables.push(...extractFromValue(spec.directUrl));\n }\n\n // Extract variables from proxy configuration\n if (spec.proxy?.spec) {\n // Extract from proxy URL\n if (spec.proxy.spec.url) {\n allVariables.push(...extractFromValue(spec.proxy.spec.url));\n }\n\n // Extract from proxy headers\n if (spec.proxy.spec.headers) {\n Object.values(spec.proxy.spec.headers).forEach((value) => {\n if (typeof value === 'string') {\n allVariables.push(...extractFromValue(value));\n }\n });\n }\n }\n\n return Array.from(new Set(allVariables)); // Remove duplicates\n } catch {\n return [];\n }\n}\n\nfunction getDatasourceVariablesFromCache(\n datasourceSelector: DatasourceSelector,\n datasourceStore: DatasourceStore\n): string[] {\n try {\n if (!datasourceStore.getDatasourceSpecSync) return [];\n\n const datasourceSpec = datasourceStore.getDatasourceSpecSync(datasourceSelector) as\n | DatasourceSpec<PrometheusDatasourceSpec>\n | undefined;\n return datasourceSpec ? extractDatasourceVariables(datasourceSpec) : [];\n } catch {\n return [];\n }\n}\n\nexport const PrometheusLabelValuesVariable: VariablePlugin<PrometheusLabelValuesVariableOptions> = {\n getVariableOptions: async (spec: PrometheusLabelValuesVariableOptions, ctx: GetVariableOptionsContext) => {\n const pluginDef = spec;\n const datasourceSelector =\n datasourceSelectValueToSelector(\n spec.datasource ?? DEFAULT_PROM,\n ctx.variables,\n await ctx.datasourceStore.listDatasourceSelectItems(PROM_DATASOURCE_KIND)\n ) ?? DEFAULT_PROM;\n\n const { client, requestOptions } = await resolvePrometheusDatasource(\n ctx.datasourceStore,\n datasourceSelector,\n ctx.variables\n );\n const match = pluginDef.matchers ? pluginDef.matchers.map((m) => replaceVariables(m, ctx.variables)) : undefined;\n\n const timeRange = getPrometheusTimeRange(ctx.timeRange);\n\n const { data: options } = await client.labelValues(\n {\n labelName: replaceVariables(pluginDef.labelName, ctx.variables),\n 'match[]': match,\n ...timeRange,\n },\n requestOptions\n );\n return {\n data: stringArrayToVariableOptions(options),\n };\n },\n dependsOn: (spec: PrometheusLabelValuesVariableOptions, ctx?: GetVariableOptionsContext) => {\n const matcherVariables = spec.matchers?.map((m) => parseVariables(m)).flat() || [];\n const labelVariables = parseVariables(spec.labelName);\n const datasourceVariables =\n spec.datasource && isVariableDatasource(spec.datasource) ? parseVariables(spec.datasource) : [];\n\n let datasourceVariablesFromCache: string[] = [];\n if (ctx?.datasourceStore && ctx?.variables) {\n const datasourceValue = spec.datasource ?? DEFAULT_PROM;\n const datasourceSelector: DatasourceSelector =\n typeof datasourceValue === 'string' ? { kind: PROM_DATASOURCE_KIND, name: datasourceValue } : datasourceValue;\n datasourceVariablesFromCache = getDatasourceVariablesFromCache(datasourceSelector, ctx.datasourceStore);\n }\n\n const allDependencies = [\n ...matcherVariables,\n ...labelVariables,\n ...datasourceVariables,\n ...datasourceVariablesFromCache,\n ];\n const uniqueDependencies = Array.from(new Set(allDependencies));\n\n return {\n variables: uniqueDependencies,\n };\n },\n OptionsEditorComponent: PrometheusLabelValuesVariableEditor,\n createInitialOptions: () => ({ labelName: '' }),\n};\n"],"names":["replaceVariables","parseVariables","datasourceSelectValueToSelector","isVariableDatasource","DEFAULT_PROM","getPrometheusTimeRange","PROM_DATASOURCE_KIND","stringArrayToVariableOptions","PrometheusLabelValuesVariableEditor","resolvePrometheusDatasource","extractDatasourceVariables","datasourceSpec","spec","plugin","extractFromValue","value","Array","isArray","flatMap","item","allVariables","queryParams","Object","values","forEach","push","directUrl","proxy","url","headers","from","Set","getDatasourceVariablesFromCache","datasourceSelector","datasourceStore","getDatasourceSpecSync","PrometheusLabelValuesVariable","getVariableOptions","ctx","pluginDef","datasource","variables","listDatasourceSelectItems","client","requestOptions","match","matchers","map","m","undefined","timeRange","data","options","labelValues","labelName","dependsOn","matcherVariables","flat","labelVariables","datasourceVariables","datasourceVariablesFromCache","datasourceValue","kind","name","allDependencies","uniqueDependencies","OptionsEditorComponent","createInitialOptions"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAGEA,gBAAgB,EAChBC,cAAc,EACdC,+BAA+B,EAC/BC,oBAAoB,QAEf,4BAA4B;AAEnC,SAASC,YAAY,EAAEC,sBAAsB,EAAEC,oBAAoB,QAAQ,WAAW;AACtF,SAASC,4BAA4B,EAAEC,mCAAmC,QAAQ,yBAAyB;AAC3G,SAASC,2BAA2B,QAAQ,kBAAkB;AAG9D,SAASC,2BAA2BC,cAAwD;IAC1F,IAAI;QACF,MAAMC,OAAOD,eAAeE,MAAM,CAACD,IAAI;QAEvC,iEAAiE;QACjE,MAAME,mBAAmB,CAACC;YACxB,IAAI,OAAOA,UAAU,UAAU;gBAC7B,OAAOd,eAAec;YACxB,OAAO,IAAIC,MAAMC,OAAO,CAACF,QAAQ;gBAC/B,OAAOA,MAAMG,OAAO,CAAC,CAACC;oBACpB,OAAO,OAAOA,SAAS,WAAWlB,eAAekB,QAAQ,EAAE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B,kBAAkB;eACnBR;eACAE;eACAC;eACAC;SACJ;QACD,MAAMK,qBAAqBjD,MAAMc,IAAI,CAAC,IAAIC,IAAIiC;QAE9C,OAAO;YACLvB,WAAWwB;QACb;IACF;IACAC,wBAAwB1D;IACxB2D,sBAAsB,IAAO,CAAA;YAAEb,WAAW;QAAG,CAAA;AAC/C,EAAE"}
|
|
@@ -9,4 +9,5 @@ export interface ResolvedPrometheusDatasource {
|
|
|
9
9
|
}
|
|
10
10
|
export declare function resolvePrometheusDatasource(datasourceStore: DatasourceStore, selector: DatasourceSelector, variableState: VariableStateMap): Promise<ResolvedPrometheusDatasource>;
|
|
11
11
|
export declare function interpolateDatasourceProxyParams(datasource: DatasourceSpec<PrometheusDatasourceSpec>, variableState: VariableStateMap): ClientRequestOptions;
|
|
12
|
+
export declare function getInterpolatedRequestOptions(datasourceStore: DatasourceStore, datasource: DatasourceSelector, variableState: VariableStateMap): Promise<ClientRequestOptions>;
|
|
12
13
|
//# sourceMappingURL=interpolation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interpolation.d.ts","sourceRoot":"","sources":["../../../src/plugins/interpolation.ts"],"names":[],"mappings":"AAaA,OAAO,EAA8C,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACtG,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,gBAAgB,CAAC;IACzB,cAAc,EAAE,oBAAoB,CAAC;CACtC;AAED,wBAAsB,2BAA2B,CAC/C,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,kBAAkB,EAC5B,aAAa,EAAE,gBAAgB,GAC9B,OAAO,CAAC,4BAA4B,CAAC,CAOvC;AAED,wBAAgB,gCAAgC,CAC9C,UAAU,EAAE,cAAc,CAAC,wBAAwB,CAAC,EACpD,aAAa,EAAE,gBAAgB,GAC9B,oBAAoB,CAStB"}
|
|
1
|
+
{"version":3,"file":"interpolation.d.ts","sourceRoot":"","sources":["../../../src/plugins/interpolation.ts"],"names":[],"mappings":"AAaA,OAAO,EAA8C,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACtG,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,gBAAgB,CAAC;IACzB,cAAc,EAAE,oBAAoB,CAAC;CACtC;AAED,wBAAsB,2BAA2B,CAC/C,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,kBAAkB,EAC5B,aAAa,EAAE,gBAAgB,GAC9B,OAAO,CAAC,4BAA4B,CAAC,CAOvC;AAED,wBAAgB,gCAAgC,CAC9C,UAAU,EAAE,cAAc,CAAC,wBAAwB,CAAC,EACpD,aAAa,EAAE,gBAAgB,GAC9B,oBAAoB,CAStB;AAED,wBAAsB,6BAA6B,CACjD,eAAe,EAAE,eAAe,EAChC,UAAU,EAAE,kBAAkB,EAC9B,aAAa,EAAE,gBAAgB,GAC9B,OAAO,CAAC,oBAAoB,CAAC,CAG/B"}
|
|
@@ -34,5 +34,9 @@ export function interpolateDatasourceProxyParams(datasource, variableState) {
|
|
|
34
34
|
queryParams: rawQueryParams ? interpolateQueryParams(rawQueryParams, variableState) : undefined
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
+
export async function getInterpolatedRequestOptions(datasourceStore, datasource, variableState) {
|
|
38
|
+
const datasourceSpec = await datasourceStore.getDatasource(datasource);
|
|
39
|
+
return interpolateDatasourceProxyParams(datasourceSpec, variableState);
|
|
40
|
+
}
|
|
37
41
|
|
|
38
42
|
//# sourceMappingURL=interpolation.js.map
|