@perses-dev/prometheus-plugin 0.0.0-snapshot-time-range-height-80d08fc
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/LICENSE +201 -0
- package/dist/cjs/index.js +34 -0
- package/dist/cjs/model/api-types.js +16 -0
- package/dist/cjs/model/index.js +34 -0
- package/dist/cjs/model/parse-sample-values.js +50 -0
- package/dist/cjs/model/prometheus-client.js +87 -0
- package/dist/cjs/model/prometheus-selectors.js +37 -0
- package/dist/cjs/model/templating.js +27 -0
- package/dist/cjs/model/time.js +54 -0
- package/dist/cjs/model/utils.js +69 -0
- package/dist/cjs/model/utils.test.js +126 -0
- package/dist/cjs/plugins/MatcherEditor.js +75 -0
- package/dist/cjs/plugins/prometheus-datasource.js +54 -0
- package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +36 -0
- package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +81 -0
- package/dist/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +84 -0
- package/dist/cjs/plugins/prometheus-time-series-query/index.js +28 -0
- package/dist/cjs/plugins/prometheus-time-series-query/query-editor-model.js +83 -0
- package/dist/cjs/plugins/prometheus-time-series-query/time-series-query-model.js +16 -0
- package/dist/cjs/plugins/prometheus-variables.js +218 -0
- package/dist/cjs/plugins/types.js +16 -0
- package/dist/cjs/plugins/variable.js +103 -0
- package/dist/cjs/test/setup-tests.js +17 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/model/api-types.d.ts +80 -0
- package/dist/model/api-types.d.ts.map +1 -0
- package/dist/model/api-types.js +15 -0
- package/dist/model/api-types.js.map +1 -0
- package/dist/model/index.d.ts +8 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +21 -0
- package/dist/model/index.js.map +1 -0
- package/dist/model/parse-sample-values.d.ts +16 -0
- package/dist/model/parse-sample-values.d.ts.map +1 -0
- package/dist/model/parse-sample-values.js +44 -0
- package/dist/model/parse-sample-values.js.map +1 -0
- package/dist/model/prometheus-client.d.ts +27 -0
- package/dist/model/prometheus-client.d.ts.map +1 -0
- package/dist/model/prometheus-client.js +81 -0
- package/dist/model/prometheus-client.js.map +1 -0
- package/dist/model/prometheus-selectors.d.ts +22 -0
- package/dist/model/prometheus-selectors.d.ts.map +1 -0
- package/dist/model/prometheus-selectors.js +30 -0
- package/dist/model/prometheus-selectors.js.map +1 -0
- package/dist/model/templating.d.ts +6 -0
- package/dist/model/templating.d.ts.map +1 -0
- package/dist/model/templating.js +21 -0
- package/dist/model/templating.js.map +1 -0
- package/dist/model/time.d.ts +24 -0
- package/dist/model/time.d.ts.map +1 -0
- package/dist/model/time.js +49 -0
- package/dist/model/time.js.map +1 -0
- package/dist/model/utils.d.ts +14 -0
- package/dist/model/utils.d.ts.map +1 -0
- package/dist/model/utils.js +60 -0
- package/dist/model/utils.js.map +1 -0
- package/dist/model/utils.test.d.ts +2 -0
- package/dist/model/utils.test.d.ts.map +1 -0
- package/dist/model/utils.test.js +124 -0
- package/dist/model/utils.test.js.map +1 -0
- package/dist/plugins/MatcherEditor.d.ts +8 -0
- package/dist/plugins/MatcherEditor.d.ts.map +1 -0
- package/dist/plugins/MatcherEditor.js +64 -0
- package/dist/plugins/MatcherEditor.js.map +1 -0
- package/dist/plugins/prometheus-datasource.d.ts +7 -0
- package/dist/plugins/prometheus-datasource.d.ts.map +1 -0
- package/dist/plugins/prometheus-datasource.js +48 -0
- package/dist/plugins/prometheus-datasource.js.map +1 -0
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.d.ts +7 -0
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.d.ts.map +1 -0
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +32 -0
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js.map +1 -0
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts +7 -0
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -0
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +77 -0
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -0
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.d.ts +4 -0
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.d.ts.map +1 -0
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.js +78 -0
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -0
- package/dist/plugins/prometheus-time-series-query/index.d.ts +2 -0
- package/dist/plugins/prometheus-time-series-query/index.d.ts.map +1 -0
- package/dist/plugins/prometheus-time-series-query/index.js +15 -0
- package/dist/plugins/prometheus-time-series-query/index.js.map +1 -0
- package/dist/plugins/prometheus-time-series-query/query-editor-model.d.ts +24 -0
- package/dist/plugins/prometheus-time-series-query/query-editor-model.d.ts.map +1 -0
- package/dist/plugins/prometheus-time-series-query/query-editor-model.js +78 -0
- package/dist/plugins/prometheus-time-series-query/query-editor-model.js.map +1 -0
- package/dist/plugins/prometheus-time-series-query/time-series-query-model.d.ts +13 -0
- package/dist/plugins/prometheus-time-series-query/time-series-query-model.d.ts.map +1 -0
- package/dist/plugins/prometheus-time-series-query/time-series-query-model.js +15 -0
- package/dist/plugins/prometheus-time-series-query/time-series-query-model.js.map +1 -0
- package/dist/plugins/prometheus-variables.d.ts +6 -0
- package/dist/plugins/prometheus-variables.d.ts.map +1 -0
- package/dist/plugins/prometheus-variables.js +205 -0
- package/dist/plugins/prometheus-variables.js.map +1 -0
- package/dist/plugins/types.d.ts +16 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +15 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/plugins/variable.d.ts +8 -0
- package/dist/plugins/variable.d.ts.map +1 -0
- package/dist/plugins/variable.js +97 -0
- package/dist/plugins/variable.js.map +1 -0
- package/dist/test/setup-tests.d.ts +2 -0
- package/dist/test/setup-tests.d.ts.map +1 -0
- package/dist/test/setup-tests.js +15 -0
- package/dist/test/setup-tests.js.map +1 -0
- package/package.json +46 -0
- package/plugin.json +58 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/MatcherEditor.tsx"],"sourcesContent":["// Copyright 2022 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 { Stack, TextField, Button, Box, IconButton } from '@mui/material';\nimport { produce } from 'immer';\nimport TrashIcon from 'mdi-material-ui/TrashCan';\n\ntype MatcherEditorProps = {\n matchers: string[];\n onChange: (matchers: string[]) => void;\n};\n\nexport function MatcherEditor({ matchers, onChange }: MatcherEditorProps) {\n return (\n <Stack spacing={1}>\n {matchers.map((matcher, index) => (\n <Box key={index} display=\"flex\">\n <TextField\n fullWidth\n label=\"Series Selector\"\n value={matcher}\n onChange={(e) => {\n const newMatchers = produce(matchers, (draft) => {\n draft[index] = e.target.value;\n });\n onChange(newMatchers);\n }}\n />\n <IconButton\n onClick={() => {\n const newMatchers = produce(matchers, (draft) => {\n draft.splice(index, 1);\n });\n onChange(newMatchers);\n }}\n >\n <TrashIcon />\n </IconButton>\n </Box>\n ))}\n <Box>\n <Button\n fullWidth={false}\n color=\"secondary\"\n variant=\"outlined\"\n onClick={() => {\n const newMatchers = produce(matchers, (draft) => {\n draft.push('');\n });\n onChange(newMatchers);\n }}\n >\n Add Series Selector\n </Button>\n </Box>\n </Stack>\n );\n}\n"],"names":["Stack","TextField","Button","Box","IconButton","produce","TrashIcon","MatcherEditor","matchers","onChange","spacing","map","matcher","index","display","fullWidth","label","value","e","newMatchers","draft","target","onClick","splice","color","variant","push"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,KAAK,EAAEC,SAAS,EAAEC,MAAM,EAAEC,GAAG,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAC1E,SAASC,OAAO,QAAQ,OAAO,CAAC;AAChC,OAAOC,SAAS,MAAM,0BAA0B,CAAC;AAOjD,OAAO,SAASC,aAAa,CAAC,EAAEC,QAAQ,CAAA,EAAEC,QAAQ,CAAA,EAAsB,EAAE;IACxE,qBACE,MAACT,KAAK;QAACU,OAAO,EAAE,CAAC;;YACdF,QAAQ,CAACG,GAAG,CAAC,CAACC,OAAO,EAAEC,KAAK,iBAC3B,MAACV,GAAG;oBAAaW,OAAO,EAAC,MAAM;;sCAC7B,KAACb,SAAS;4BACRc,SAAS;4BACTC,KAAK,EAAC,iBAAiB;4BACvBC,KAAK,EAAEL,OAAO;4BACdH,QAAQ,EAAE,CAACS,CAAC,GAAK;gCACf,MAAMC,WAAW,GAAGd,OAAO,CAACG,QAAQ,EAAE,CAACY,KAAK,GAAK;oCAC/CA,KAAK,CAACP,KAAK,CAAC,GAAGK,CAAC,CAACG,MAAM,CAACJ,KAAK,CAAC;gCAChC,CAAC,CAAC,AAAC;gCACHR,QAAQ,CAACU,WAAW,CAAC,CAAC;4BACxB,CAAC;0BACD;sCACF,KAACf,UAAU;4BACTkB,OAAO,EAAE,IAAM;gCACb,MAAMH,WAAW,GAAGd,OAAO,CAACG,QAAQ,EAAE,CAACY,KAAK,GAAK;oCAC/CA,KAAK,CAACG,MAAM,CAACV,KAAK,EAAE,CAAC,CAAC,CAAC;gCACzB,CAAC,CAAC,AAAC;gCACHJ,QAAQ,CAACU,WAAW,CAAC,CAAC;4BACxB,CAAC;sCAED,cAAA,KAACb,SAAS,KAAG;0BACF;;mBArBLO,KAAK,CAsBT,AACP,CAAC;0BACF,KAACV,GAAG;0BACF,cAAA,KAACD,MAAM;oBACLa,SAAS,EAAE,KAAK;oBAChBS,KAAK,EAAC,WAAW;oBACjBC,OAAO,EAAC,UAAU;oBAClBH,OAAO,EAAE,IAAM;wBACb,MAAMH,WAAW,GAAGd,OAAO,CAACG,QAAQ,EAAE,CAACY,KAAK,GAAK;4BAC/CA,KAAK,CAACM,IAAI,CAAC,EAAE,CAAC,CAAC;wBACjB,CAAC,CAAC,AAAC;wBACHjB,QAAQ,CAACU,WAAW,CAAC,CAAC;oBACxB,CAAC;8BACF,qBAED;kBAAS;cACL;;MACA,CACR;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DatasourcePlugin } from '@perses-dev/plugin-system';
|
|
2
|
+
import { PrometheusClient } from '../model';
|
|
3
|
+
export interface PrometheusDatasourceSpec {
|
|
4
|
+
direct_url?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const PrometheusDatasource: DatasourcePlugin<PrometheusDatasourceSpec, PrometheusClient>;
|
|
7
|
+
//# sourceMappingURL=prometheus-datasource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prometheus-datasource.d.ts","sourceRoot":"","sources":["../../src/plugins/prometheus-datasource.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAqD,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE/F,MAAM,WAAW,wBAAwB;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAwBD,eAAO,MAAM,oBAAoB,EAAE,gBAAgB,CAAC,wBAAwB,EAAE,gBAAgB,CAI7F,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { instantQuery, rangeQuery, labelNames, labelValues } from '../model';
|
|
14
|
+
/**
|
|
15
|
+
* Creates a PrometheusClient for a specific datasource spec.
|
|
16
|
+
*/ const createClient = (spec, options)=>{
|
|
17
|
+
const { direct_url } = spec;
|
|
18
|
+
const { proxyUrl } = options;
|
|
19
|
+
// Use the direct URL if specified, but fallback to the proxyUrl by default if not specified
|
|
20
|
+
const datasourceUrl = direct_url !== null && direct_url !== void 0 ? direct_url : proxyUrl;
|
|
21
|
+
if (datasourceUrl === undefined) {
|
|
22
|
+
throw new Error('No URL specified for Prometheus client. You can use direct_url in the spec to configure it.');
|
|
23
|
+
}
|
|
24
|
+
// Could think about this becoming a class, although it definitely doesn't have to be
|
|
25
|
+
return {
|
|
26
|
+
instantQuery: (params)=>instantQuery(params, {
|
|
27
|
+
datasourceUrl
|
|
28
|
+
}),
|
|
29
|
+
rangeQuery: (params)=>rangeQuery(params, {
|
|
30
|
+
datasourceUrl
|
|
31
|
+
}),
|
|
32
|
+
labelNames: (params)=>labelNames(params, {
|
|
33
|
+
datasourceUrl
|
|
34
|
+
}),
|
|
35
|
+
labelValues: (params)=>labelValues(params, {
|
|
36
|
+
datasourceUrl
|
|
37
|
+
})
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export const PrometheusDatasource = {
|
|
41
|
+
createClient,
|
|
42
|
+
OptionsEditorComponent: ()=>null,
|
|
43
|
+
createInitialOptions: ()=>({
|
|
44
|
+
direct_url: ''
|
|
45
|
+
})
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=prometheus-datasource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/prometheus-datasource.ts"],"sourcesContent":["// Copyright 2022 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 { DatasourcePlugin } from '@perses-dev/plugin-system';\nimport { instantQuery, rangeQuery, labelNames, labelValues, PrometheusClient } from '../model';\n\nexport interface PrometheusDatasourceSpec {\n direct_url?: string;\n}\n\n/**\n * Creates a PrometheusClient for a specific datasource spec.\n */\nconst createClient: DatasourcePlugin<PrometheusDatasourceSpec, PrometheusClient>['createClient'] = (spec, options) => {\n const { direct_url } = spec;\n const { proxyUrl } = options;\n\n // Use the direct URL if specified, but fallback to the proxyUrl by default if not specified\n const datasourceUrl = direct_url ?? proxyUrl;\n if (datasourceUrl === undefined) {\n throw new Error('No URL specified for Prometheus client. You can use direct_url in the spec to configure it.');\n }\n\n // Could think about this becoming a class, although it definitely doesn't have to be\n return {\n instantQuery: (params) => instantQuery(params, { datasourceUrl }),\n rangeQuery: (params) => rangeQuery(params, { datasourceUrl }),\n labelNames: (params) => labelNames(params, { datasourceUrl }),\n labelValues: (params) => labelValues(params, { datasourceUrl }),\n };\n};\n\nexport const PrometheusDatasource: DatasourcePlugin<PrometheusDatasourceSpec, PrometheusClient> = {\n createClient,\n OptionsEditorComponent: () => null,\n createInitialOptions: () => ({ direct_url: '' }),\n};\n"],"names":["instantQuery","rangeQuery","labelNames","labelValues","createClient","spec","options","direct_url","proxyUrl","datasourceUrl","undefined","Error","params","PrometheusDatasource","OptionsEditorComponent","createInitialOptions"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,YAAY,EAAEC,UAAU,EAAEC,UAAU,EAAEC,WAAW,QAA0B,UAAU,CAAC;AAM/F;;CAEC,GACD,MAAMC,YAAY,GAAiF,CAACC,IAAI,EAAEC,OAAO,GAAK;IACpH,MAAM,EAAEC,UAAU,CAAA,EAAE,GAAGF,IAAI,AAAC;IAC5B,MAAM,EAAEG,QAAQ,CAAA,EAAE,GAAGF,OAAO,AAAC;IAE7B,4FAA4F;IAC5F,MAAMG,aAAa,GAAGF,UAAU,aAAVA,UAAU,cAAVA,UAAU,GAAIC,QAAQ,AAAC;IAC7C,IAAIC,aAAa,KAAKC,SAAS,EAAE;QAC/B,MAAM,IAAIC,KAAK,CAAC,6FAA6F,CAAC,CAAC;IACjH,CAAC;IAED,qFAAqF;IACrF,OAAO;QACLX,YAAY,EAAE,CAACY,MAAM,GAAKZ,YAAY,CAACY,MAAM,EAAE;gBAAEH,aAAa;aAAE,CAAC;QACjER,UAAU,EAAE,CAACW,MAAM,GAAKX,UAAU,CAACW,MAAM,EAAE;gBAAEH,aAAa;aAAE,CAAC;QAC7DP,UAAU,EAAE,CAACU,MAAM,GAAKV,UAAU,CAACU,MAAM,EAAE;gBAAEH,aAAa;aAAE,CAAC;QAC7DN,WAAW,EAAE,CAACS,MAAM,GAAKT,WAAW,CAACS,MAAM,EAAE;gBAAEH,aAAa;aAAE,CAAC;KAChE,CAAC;AACJ,CAAC,AAAC;AAEF,OAAO,MAAMI,oBAAoB,GAAiE;IAChGT,YAAY;IACZU,sBAAsB,EAAE,IAAM,IAAI;IAClCC,oBAAoB,EAAE,IAAO,CAAA;YAAER,UAAU,EAAE,EAAE;SAAE,CAAA,AAAC;CACjD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TimeSeriesQueryPlugin } from '@perses-dev/plugin-system';
|
|
2
|
+
import { PrometheusTimeSeriesQuerySpec } from './time-series-query-model';
|
|
3
|
+
/**
|
|
4
|
+
* The core Prometheus TimeSeriesQuery plugin for Perses.
|
|
5
|
+
*/
|
|
6
|
+
export declare const PrometheusTimeSeriesQuery: TimeSeriesQueryPlugin<PrometheusTimeSeriesQuerySpec>;
|
|
7
|
+
//# sourceMappingURL=PrometheusTimeSeriesQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrometheusTimeSeriesQuery.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAIlE,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAE1E;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,qBAAqB,CAAC,6BAA6B,CAY1F,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { parseTemplateVariables } from '../../model';
|
|
14
|
+
import { getTimeSeriesData } from './get-time-series-data';
|
|
15
|
+
import { PrometheusTimeSeriesQueryEditor } from './PrometheusTimeSeriesQueryEditor';
|
|
16
|
+
/**
|
|
17
|
+
* The core Prometheus TimeSeriesQuery plugin for Perses.
|
|
18
|
+
*/ export const PrometheusTimeSeriesQuery = {
|
|
19
|
+
getTimeSeriesData,
|
|
20
|
+
OptionsEditorComponent: PrometheusTimeSeriesQueryEditor,
|
|
21
|
+
createInitialOptions: ()=>({
|
|
22
|
+
query: '',
|
|
23
|
+
datasource: undefined
|
|
24
|
+
}),
|
|
25
|
+
dependsOn: (spec)=>{
|
|
26
|
+
return {
|
|
27
|
+
variables: parseTemplateVariables(spec.query)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=PrometheusTimeSeriesQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.ts"],"sourcesContent":["// Copyright 2022 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 { TimeSeriesQueryPlugin } from '@perses-dev/plugin-system';\nimport { parseTemplateVariables } from '../../model';\nimport { getTimeSeriesData } from './get-time-series-data';\nimport { PrometheusTimeSeriesQueryEditor } from './PrometheusTimeSeriesQueryEditor';\nimport { PrometheusTimeSeriesQuerySpec } from './time-series-query-model';\n\n/**\n * The core Prometheus TimeSeriesQuery plugin for Perses.\n */\nexport const PrometheusTimeSeriesQuery: TimeSeriesQueryPlugin<PrometheusTimeSeriesQuerySpec> = {\n getTimeSeriesData,\n OptionsEditorComponent: PrometheusTimeSeriesQueryEditor,\n createInitialOptions: () => ({\n query: '',\n datasource: undefined,\n }),\n dependsOn: (spec) => {\n return {\n variables: parseTemplateVariables(spec.query),\n };\n },\n};\n"],"names":["parseTemplateVariables","getTimeSeriesData","PrometheusTimeSeriesQueryEditor","PrometheusTimeSeriesQuery","OptionsEditorComponent","createInitialOptions","query","datasource","undefined","dependsOn","spec","variables"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,sBAAsB,QAAQ,aAAa,CAAC;AACrD,SAASC,iBAAiB,QAAQ,wBAAwB,CAAC;AAC3D,SAASC,+BAA+B,QAAQ,mCAAmC,CAAC;AAGpF;;CAEC,GACD,OAAO,MAAMC,yBAAyB,GAAyD;IAC7FF,iBAAiB;IACjBG,sBAAsB,EAAEF,+BAA+B;IACvDG,oBAAoB,EAAE,IAAO,CAAA;YAC3BC,KAAK,EAAE,EAAE;YACTC,UAAU,EAAEC,SAAS;SACtB,CAAA,AAAC;IACFC,SAAS,EAAE,CAACC,IAAI,GAAK;QACnB,OAAO;YACLC,SAAS,EAAEX,sBAAsB,CAACU,IAAI,CAACJ,KAAK,CAAC;SAC9C,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PrometheusTimeSeriesQueryEditorProps } from './query-editor-model';
|
|
3
|
+
/**
|
|
4
|
+
* The options editor component for editing a PrometheusTimeSeriesQuery's spec.
|
|
5
|
+
*/
|
|
6
|
+
export declare function PrometheusTimeSeriesQueryEditor(props: PrometheusTimeSeriesQueryEditorProps): JSX.Element;
|
|
7
|
+
//# sourceMappingURL=PrometheusTimeSeriesQueryEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrometheusTimeSeriesQueryEditor.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,oCAAoC,EAAiC,MAAM,sBAAsB,CAAC;AAE3G;;GAEG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,oCAAoC,eAsD1F"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { produce } from 'immer';
|
|
15
|
+
import { Stack, TextField, FormControl, InputLabel } from '@mui/material';
|
|
16
|
+
import { DatasourceSelect } from '@perses-dev/plugin-system';
|
|
17
|
+
import { DEFAULT_PROM, isDefaultPromSelector, isPrometheusDatasourceSelector } from '../../model';
|
|
18
|
+
import { useQueryState, useFormatState } from './query-editor-model';
|
|
19
|
+
/**
|
|
20
|
+
* The options editor component for editing a PrometheusTimeSeriesQuery's spec.
|
|
21
|
+
*/ export function PrometheusTimeSeriesQueryEditor(props) {
|
|
22
|
+
const { onChange , value } = props;
|
|
23
|
+
const { datasource } = value;
|
|
24
|
+
const { query , handleQueryChange , handleQueryBlur } = useQueryState(props);
|
|
25
|
+
const { format , handleFormatChange , handleFormatBlur } = useFormatState(props);
|
|
26
|
+
const handleDatasourceChange = (next)=>{
|
|
27
|
+
if (isPrometheusDatasourceSelector(next)) {
|
|
28
|
+
onChange(produce(value, (draft)=>{
|
|
29
|
+
// If they're using the default, just omit the datasource prop (i.e. set to undefined)
|
|
30
|
+
const nextDatasource = isDefaultPromSelector(next) ? undefined : next;
|
|
31
|
+
draft.datasource = nextDatasource;
|
|
32
|
+
}));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
36
|
+
};
|
|
37
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
38
|
+
spacing: 2,
|
|
39
|
+
children: [
|
|
40
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
41
|
+
fullWidth: true,
|
|
42
|
+
label: "Query",
|
|
43
|
+
value: query,
|
|
44
|
+
onChange: handleQueryChange,
|
|
45
|
+
onBlur: handleQueryBlur,
|
|
46
|
+
margin: "dense"
|
|
47
|
+
}),
|
|
48
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
49
|
+
fullWidth: true,
|
|
50
|
+
label: "Series Name Format",
|
|
51
|
+
value: format !== null && format !== void 0 ? format : '',
|
|
52
|
+
onChange: handleFormatChange,
|
|
53
|
+
onBlur: handleFormatBlur,
|
|
54
|
+
margin: "dense"
|
|
55
|
+
}),
|
|
56
|
+
/*#__PURE__*/ _jsxs(FormControl, {
|
|
57
|
+
margin: "dense",
|
|
58
|
+
fullWidth: false,
|
|
59
|
+
children: [
|
|
60
|
+
/*#__PURE__*/ _jsx(InputLabel, {
|
|
61
|
+
id: "prom-datasource-label",
|
|
62
|
+
children: "Prometheus Datasource"
|
|
63
|
+
}),
|
|
64
|
+
/*#__PURE__*/ _jsx(DatasourceSelect, {
|
|
65
|
+
datasourcePluginKind: "PrometheusDatasource",
|
|
66
|
+
value: datasource !== null && datasource !== void 0 ? datasource : DEFAULT_PROM,
|
|
67
|
+
onChange: handleDatasourceChange,
|
|
68
|
+
labelId: "prom-datasource-label",
|
|
69
|
+
label: "Prometheus Datasource"
|
|
70
|
+
})
|
|
71
|
+
]
|
|
72
|
+
})
|
|
73
|
+
]
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=PrometheusTimeSeriesQueryEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.tsx"],"sourcesContent":["// Copyright 2022 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 { produce } from 'immer';\nimport { Stack, TextField, FormControl, InputLabel } from '@mui/material';\nimport { DatasourceSelect, DatasourceSelectProps } from '@perses-dev/plugin-system';\nimport { DEFAULT_PROM, isDefaultPromSelector, isPrometheusDatasourceSelector } from '../../model';\nimport { PrometheusTimeSeriesQueryEditorProps, useQueryState, useFormatState } from './query-editor-model';\n\n/**\n * The options editor component for editing a PrometheusTimeSeriesQuery's spec.\n */\nexport function PrometheusTimeSeriesQueryEditor(props: PrometheusTimeSeriesQueryEditorProps) {\n const { onChange, value } = props;\n const { datasource } = value;\n\n const { query, handleQueryChange, handleQueryBlur } = useQueryState(props);\n const { format, handleFormatChange, handleFormatBlur } = useFormatState(props);\n\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = (next) => {\n if (isPrometheusDatasourceSelector(next)) {\n onChange(\n produce(value, (draft) => {\n // If they're using the default, just omit the datasource prop (i.e. set to undefined)\n const nextDatasource = isDefaultPromSelector(next) ? undefined : next;\n draft.datasource = nextDatasource;\n })\n );\n return;\n }\n\n throw new Error('Got unexpected non-Prometheus datasource selector');\n };\n\n return (\n <Stack spacing={2}>\n <TextField\n fullWidth\n label=\"Query\"\n value={query}\n onChange={handleQueryChange}\n onBlur={handleQueryBlur}\n margin=\"dense\"\n />\n <TextField\n fullWidth\n label=\"Series Name Format\"\n value={format ?? ''}\n onChange={handleFormatChange}\n onBlur={handleFormatBlur}\n margin=\"dense\"\n />\n <FormControl margin=\"dense\" fullWidth={false}>\n {/* TODO: How do we ensure unique ID values if there are multiple of these? Can we use React 18 useId and\n maintain 17 compatibility somehow with a polyfill/shim? */}\n <InputLabel id=\"prom-datasource-label\">Prometheus Datasource</InputLabel>\n <DatasourceSelect\n datasourcePluginKind=\"PrometheusDatasource\"\n value={datasource ?? DEFAULT_PROM}\n onChange={handleDatasourceChange}\n labelId=\"prom-datasource-label\"\n label=\"Prometheus Datasource\"\n />\n </FormControl>\n </Stack>\n );\n}\n"],"names":["produce","Stack","TextField","FormControl","InputLabel","DatasourceSelect","DEFAULT_PROM","isDefaultPromSelector","isPrometheusDatasourceSelector","useQueryState","useFormatState","PrometheusTimeSeriesQueryEditor","props","onChange","value","datasource","query","handleQueryChange","handleQueryBlur","format","handleFormatChange","handleFormatBlur","handleDatasourceChange","next","draft","nextDatasource","undefined","Error","spacing","fullWidth","label","onBlur","margin","id","datasourcePluginKind","labelId"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,OAAO,QAAQ,OAAO,CAAC;AAChC,SAASC,KAAK,EAAEC,SAAS,EAAEC,WAAW,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAC1E,SAASC,gBAAgB,QAA+B,2BAA2B,CAA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AAS;gBACR2B,SAAS;gBACTC,KAAK,EAAC,oBAAoB;gBAC1BhB,KAAK,EAAEK,MAAM,aAANA,MAAM,cAANA,MAAM,GAAI,EAAE;gBACnBN,QAAQ,EAAEO,kBAAkB;gBAC5BW,MAAM,EAAEV,gBAAgB;gBACxBW,MAAM,EAAC,OAAO;cACd;0BACF,MAAC7B,WAAW;gBAAC6B,MAAM,EAAC,OAAO;gBAACH,SAAS,EAAE,KAAK;;kCAG1C,KAACzB,UAAU;wBAAC6B,EAAE,EAAC,uBAAuB;kCAAC,uBAAqB;sBAAa;kCACzE,KAAC5B,gBAAgB;wBACf6B,oBAAoB,EAAC,sBAAsB;wBAC3CpB,KAAK,EAAEC,UAAU,aAAVA,UAAU,cAAVA,UAAU,GAAIT,YAAY;wBACjCO,QAAQ,EAAES,sBAAsB;wBAChCa,OAAO,EAAC,uBAAuB;wBAC/BL,KAAK,EAAC,uBAAuB;sBAC7B;;cACU;;MACR,CACR;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TimeSeriesQueryPlugin } from '@perses-dev/plugin-system';
|
|
2
|
+
import { PrometheusTimeSeriesQuerySpec } from './time-series-query-model';
|
|
3
|
+
export declare const getTimeSeriesData: TimeSeriesQueryPlugin<PrometheusTimeSeriesQuerySpec>['getTimeSeriesData'];
|
|
4
|
+
//# sourceMappingURL=get-time-series-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-time-series-data.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-time-series-query/get-time-series-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAkB,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAYlF,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAE1E,eAAO,MAAM,iBAAiB,EAAE,qBAAqB,CAAC,6BAA6B,CAAC,CAAC,mBAAmB,CAuEvG,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { fromUnixTime } from 'date-fns';
|
|
14
|
+
import { parseValueTuple, getDurationStringSeconds, getPrometheusTimeRange, getRangeStep, replaceTemplateVariables, DEFAULT_PROM, formatSeriesName } from '../../model';
|
|
15
|
+
export const getTimeSeriesData = async (spec, context)=>{
|
|
16
|
+
var ref;
|
|
17
|
+
if (spec.query === undefined || spec.query === null || spec.query === '') {
|
|
18
|
+
// Do not make a request to the backend, instead return an empty TimeSeriesData
|
|
19
|
+
return {
|
|
20
|
+
series: []
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const minStep = getDurationStringSeconds(spec.min_step);
|
|
24
|
+
const timeRange = getPrometheusTimeRange(context.timeRange);
|
|
25
|
+
const step = getRangeStep(timeRange, minStep, undefined, context.suggestedStepMs);
|
|
26
|
+
// Align the time range so that it's a multiple of the step
|
|
27
|
+
let { start , end } = timeRange;
|
|
28
|
+
const utcOffsetSec = new Date().getTimezoneOffset() * 60;
|
|
29
|
+
const alignedEnd = Math.floor((end + utcOffsetSec) / step) * step - utcOffsetSec;
|
|
30
|
+
const alignedStart = Math.floor((start + utcOffsetSec) / step) * step - utcOffsetSec;
|
|
31
|
+
start = alignedStart;
|
|
32
|
+
end = alignedEnd;
|
|
33
|
+
// Replace template variable placeholders in PromQL query
|
|
34
|
+
let query = spec.query.replace('$__rate_interval', `15s`);
|
|
35
|
+
query = replaceTemplateVariables(query, context.variableState);
|
|
36
|
+
var _datasource;
|
|
37
|
+
// Get the datasource, using the default Prom Datasource if one isn't specified in the query
|
|
38
|
+
const client = await context.datasourceStore.getDatasourceClient((_datasource = spec.datasource) !== null && _datasource !== void 0 ? _datasource : DEFAULT_PROM);
|
|
39
|
+
// Make the request to Prom
|
|
40
|
+
const response = await client.rangeQuery({
|
|
41
|
+
query,
|
|
42
|
+
start,
|
|
43
|
+
end,
|
|
44
|
+
step
|
|
45
|
+
});
|
|
46
|
+
var ref1;
|
|
47
|
+
// TODO: What about error responses from Prom that have a response body?
|
|
48
|
+
const result = (ref1 = (ref = response.data) === null || ref === void 0 ? void 0 : ref.result) !== null && ref1 !== void 0 ? ref1 : [];
|
|
49
|
+
// Transform response
|
|
50
|
+
const chartData = {
|
|
51
|
+
// Return the time range and step we actually used for the query
|
|
52
|
+
timeRange: {
|
|
53
|
+
start: fromUnixTime(start),
|
|
54
|
+
end: fromUnixTime(end)
|
|
55
|
+
},
|
|
56
|
+
stepMs: step * 1000,
|
|
57
|
+
// TODO: Maybe do a proper Iterable implementation that defers some of this
|
|
58
|
+
// processing until its needed
|
|
59
|
+
series: result.map((value)=>{
|
|
60
|
+
const { metric , values } = value;
|
|
61
|
+
// Name the series after the metric labels or if no metric, just use the
|
|
62
|
+
// overall query
|
|
63
|
+
let name = Object.entries(metric).map(([labelName, labelValue])=>`${labelName}="${labelValue}"`).join(', ');
|
|
64
|
+
if (name === '') name = query;
|
|
65
|
+
// query editor allows you to define an optional series_name_format
|
|
66
|
+
// property to customize legend and tooltip display
|
|
67
|
+
const formattedName = spec.series_name_format ? formatSeriesName(spec.series_name_format, metric) : name;
|
|
68
|
+
return {
|
|
69
|
+
name,
|
|
70
|
+
values: values.map(parseValueTuple),
|
|
71
|
+
formattedName
|
|
72
|
+
};
|
|
73
|
+
})
|
|
74
|
+
};
|
|
75
|
+
return chartData;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=get-time-series-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/prometheus-time-series-query/get-time-series-data.ts"],"sourcesContent":["// Copyright 2022 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 { TimeSeriesData, TimeSeriesQueryPlugin } from '@perses-dev/plugin-system';\nimport { fromUnixTime } from 'date-fns';\nimport {\n parseValueTuple,\n PrometheusClient,\n getDurationStringSeconds,\n getPrometheusTimeRange,\n getRangeStep,\n replaceTemplateVariables,\n DEFAULT_PROM,\n formatSeriesName,\n} from '../../model';\nimport { PrometheusTimeSeriesQuerySpec } from './time-series-query-model';\n\nexport const getTimeSeriesData: TimeSeriesQueryPlugin<PrometheusTimeSeriesQuerySpec>['getTimeSeriesData'] = async (\n spec,\n context\n) => {\n if (spec.query === undefined || spec.query === null || spec.query === '') {\n // Do not make a request to the backend, instead return an empty TimeSeriesData\n return { series: [] };\n }\n\n const minStep = getDurationStringSeconds(spec.min_step);\n const timeRange = getPrometheusTimeRange(context.timeRange);\n const step = getRangeStep(timeRange, minStep, undefined, context.suggestedStepMs);\n\n // Align the time range so that it's a multiple of the step\n let { start, end } = timeRange;\n const utcOffsetSec = new Date().getTimezoneOffset() * 60;\n\n const alignedEnd = Math.floor((end + utcOffsetSec) / step) * step - utcOffsetSec;\n const alignedStart = Math.floor((start + utcOffsetSec) / step) * step - utcOffsetSec;\n start = alignedStart;\n end = alignedEnd;\n\n // Replace template variable placeholders in PromQL query\n let query = spec.query.replace('$__rate_interval', `15s`);\n query = replaceTemplateVariables(query, context.variableState);\n\n // Get the datasource, using the default Prom Datasource if one isn't specified in the query\n const client: PrometheusClient = await context.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);\n\n // Make the request to Prom\n const response = await client.rangeQuery({\n query,\n start,\n end,\n step,\n });\n\n // TODO: What about error responses from Prom that have a response body?\n const result = response.data?.result ?? [];\n\n // Transform response\n const chartData: TimeSeriesData = {\n // Return the time range and step we actually used for the query\n timeRange: { start: fromUnixTime(start), end: fromUnixTime(end) },\n stepMs: step * 1000,\n\n // TODO: Maybe do a proper Iterable implementation that defers some of this\n // processing until its needed\n series: result.map((value) => {\n const { metric, values } = value;\n\n // Name the series after the metric labels or if no metric, just use the\n // overall query\n let name = Object.entries(metric)\n .map(([labelName, labelValue]) => `${labelName}=\"${labelValue}\"`)\n .join(', ');\n if (name === '') name = query;\n\n // query editor allows you to define an optional series_name_format\n // property to customize legend and tooltip display\n const formattedName = spec.series_name_format ? formatSeriesName(spec.series_name_format, metric) : name;\n\n return {\n name,\n values: values.map(parseValueTuple),\n formattedName,\n };\n }),\n };\n\n return chartData;\n};\n"],"names":["fromUnixTime","parseValueTuple","getDurationStringSeconds","getPrometheusTimeRange","getRangeStep","replaceTemplateVariables","DEFAULT_PROM","formatSeriesName","getTimeSeriesData","spec","context","response","query","undefined","series","minStep","min_step","timeRange","step","suggestedStepMs","start","end","utcOffsetSec","Date","getTimezoneOffset","alignedEnd","Math","floor","alignedStart","replace","variableState","client","datasourceStore","getDatasourceClient","datasource","rangeQuery","result","data","chartData","stepMs","map","value","metric","values","name","Object","entries","labelName","labelValue","join","formattedName","series_name_format"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,YAAY,QAAQ,UAAU,CAAC;AACxC,SACEC,eAAe,EAEfC,wBAAwB,EACxBC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EAAEC,UAAU,CAAC,GAAK,CAAC,EAAED,SAAS,CAAC,EAAE,EAAEC,UAAU,CAAC,CAAC,CAAC,CAAC,CAChEC,IAAI,CAAC,IAAI,CAAC,AAAC;YACd,IAAIL,IAAI,KAAK,EAAE,EAAEA,IAAI,GAAGhC,KAAK,CAAC;YAE9B,mEAAmE;YACnE,mDAAmD;YACnD,MAAMsC,aAAa,GAAGzC,IAAI,CAAC0C,kBAAkB,GAAG5C,gBAAgB,CAACE,IAAI,CAAC0C,kBAAkB,EAAET,MAAM,CAAC,GAAGE,IAAI,AAAC;YAEzG,OAAO;gBACLA,IAAI;gBACJD,MAAM,EAAEA,MAAM,CAACH,GAAG,CAACvC,eAAe,CAAC;gBACnCiD,aAAa;aACd,CAAC;QACJ,CAAC,CAAC;KACH,AAAC;IAEF,OAAOZ,SAAS,CAAC;AACnB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-time-series-query/index.ts"],"names":[],"mappings":"AAaA,cAAc,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export * from './PrometheusTimeSeriesQuery';
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/prometheus-time-series-query/index.ts"],"sourcesContent":["// Copyright 2022 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\nexport * from './PrometheusTimeSeriesQuery';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { OptionsEditorProps } from '@perses-dev/plugin-system';
|
|
3
|
+
import { PrometheusTimeSeriesQuerySpec } from './time-series-query-model';
|
|
4
|
+
export declare type PrometheusTimeSeriesQueryEditorProps = OptionsEditorProps<PrometheusTimeSeriesQuerySpec>;
|
|
5
|
+
/**
|
|
6
|
+
* A hook for managing the `query` state in PrometheusTimeSeriesQuerySpec. Returns the `query` value, along with
|
|
7
|
+
* `onChange` and `onBlur` event handlers to the input. Keeps a local copy of the user's input and only syncs those
|
|
8
|
+
* changes with the overall spec value once the input is blurred to prevent re-running queries in the panel's preview
|
|
9
|
+
* every time the user types.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useQueryState(props: PrometheusTimeSeriesQueryEditorProps): {
|
|
12
|
+
query: string;
|
|
13
|
+
handleQueryChange: import("react").ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;
|
|
14
|
+
handleQueryBlur: import("react").FocusEventHandler<HTMLTextAreaElement | HTMLInputElement>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Hook to manage `series_name_format` state to ensure panel preview does not rerender until text input is blurred
|
|
18
|
+
*/
|
|
19
|
+
export declare function useFormatState(props: PrometheusTimeSeriesQueryEditorProps): {
|
|
20
|
+
format: string | undefined;
|
|
21
|
+
handleFormatChange: import("react").ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;
|
|
22
|
+
handleFormatBlur: import("react").FocusEventHandler<HTMLTextAreaElement | HTMLInputElement>;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=query-editor-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-editor-model.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-time-series-query/query-editor-model.ts"],"names":[],"mappings":";AAgBA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAE1E,oBAAY,oCAAoC,GAAG,kBAAkB,CAAC,6BAA6B,CAAC,CAAC;AAErG;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,oCAAoC;;;;EA+BxE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,oCAAoC;;;;EA2BzE"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { useState } from 'react';
|
|
14
|
+
import { produce } from 'immer';
|
|
15
|
+
/**
|
|
16
|
+
* A hook for managing the `query` state in PrometheusTimeSeriesQuerySpec. Returns the `query` value, along with
|
|
17
|
+
* `onChange` and `onBlur` event handlers to the input. Keeps a local copy of the user's input and only syncs those
|
|
18
|
+
* changes with the overall spec value once the input is blurred to prevent re-running queries in the panel's preview
|
|
19
|
+
* every time the user types.
|
|
20
|
+
*/ export function useQueryState(props) {
|
|
21
|
+
const { onChange , value } = props;
|
|
22
|
+
// Local copy of the query's value
|
|
23
|
+
const [query, setQuery] = useState(value.query);
|
|
24
|
+
// This is basically "getDerivedStateFromProps" to make sure if spec's value changes external to this component,
|
|
25
|
+
// we render with the latest value
|
|
26
|
+
const [lastSyncedQuery, setLastSyncedQuery] = useState(value.query);
|
|
27
|
+
if (value.query !== lastSyncedQuery) {
|
|
28
|
+
setQuery(value.query);
|
|
29
|
+
setLastSyncedQuery(value.query);
|
|
30
|
+
}
|
|
31
|
+
// Update our local state's copy as the user types
|
|
32
|
+
const handleQueryChange = (e)=>{
|
|
33
|
+
setQuery(e.target.value);
|
|
34
|
+
};
|
|
35
|
+
// Propagate changes to the query's value when the input is blurred to avoid constantly re-running queries in the
|
|
36
|
+
// PanelPreview
|
|
37
|
+
const handleQueryBlur = ()=>{
|
|
38
|
+
setLastSyncedQuery(query);
|
|
39
|
+
onChange(produce(value, (draft)=>{
|
|
40
|
+
draft.query = query;
|
|
41
|
+
}));
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
query,
|
|
45
|
+
handleQueryChange,
|
|
46
|
+
handleQueryBlur
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Hook to manage `series_name_format` state to ensure panel preview does not rerender until text input is blurred
|
|
51
|
+
*/ export function useFormatState(props) {
|
|
52
|
+
const { onChange , value } = props;
|
|
53
|
+
// TODO: reusable hook or helper util instead of duplicating from useQueryState
|
|
54
|
+
const [format, setFormat] = useState(value.series_name_format);
|
|
55
|
+
const [lastSyncedFormat, setLastSyncedFormat] = useState(value.series_name_format);
|
|
56
|
+
if (value.series_name_format !== lastSyncedFormat) {
|
|
57
|
+
setFormat(value.series_name_format);
|
|
58
|
+
setLastSyncedFormat(value.series_name_format);
|
|
59
|
+
}
|
|
60
|
+
// Update our local state as the user types
|
|
61
|
+
const handleFormatChange = (e)=>{
|
|
62
|
+
setFormat(e.target.value);
|
|
63
|
+
};
|
|
64
|
+
// Propagate changes to the panel preview component when series_name_format TextField is blurred
|
|
65
|
+
const handleFormatBlur = ()=>{
|
|
66
|
+
setLastSyncedFormat(format);
|
|
67
|
+
onChange(produce(value, (draft)=>{
|
|
68
|
+
draft.series_name_format = format;
|
|
69
|
+
}));
|
|
70
|
+
};
|
|
71
|
+
return {
|
|
72
|
+
format,
|
|
73
|
+
handleFormatChange,
|
|
74
|
+
handleFormatBlur
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=query-editor-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/prometheus-time-series-query/query-editor-model.ts"],"sourcesContent":["// Copyright 2022 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 { useState } from 'react';\nimport { TextFieldProps } from '@mui/material';\nimport { produce } from 'immer';\nimport { OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { PrometheusTimeSeriesQuerySpec } from './time-series-query-model';\n\nexport type PrometheusTimeSeriesQueryEditorProps = OptionsEditorProps<PrometheusTimeSeriesQuerySpec>;\n\n/**\n * A hook for managing the `query` state in PrometheusTimeSeriesQuerySpec. Returns the `query` value, along with\n * `onChange` and `onBlur` event handlers to the input. Keeps a local copy of the user's input and only syncs those\n * changes with the overall spec value once the input is blurred to prevent re-running queries in the panel's preview\n * every time the user types.\n */\nexport function useQueryState(props: PrometheusTimeSeriesQueryEditorProps) {\n const { onChange, value } = props;\n\n // Local copy of the query's value\n const [query, setQuery] = useState(value.query);\n\n // This is basically \"getDerivedStateFromProps\" to make sure if spec's value changes external to this component,\n // we render with the latest value\n const [lastSyncedQuery, setLastSyncedQuery] = useState(value.query);\n if (value.query !== lastSyncedQuery) {\n setQuery(value.query);\n setLastSyncedQuery(value.query);\n }\n\n // Update our local state's copy as the user types\n const handleQueryChange: TextFieldProps['onChange'] = (e) => {\n setQuery(e.target.value);\n };\n\n // Propagate changes to the query's value when the input is blurred to avoid constantly re-running queries in the\n // PanelPreview\n const handleQueryBlur: TextFieldProps['onBlur'] = () => {\n setLastSyncedQuery(query);\n onChange(\n produce(value, (draft) => {\n draft.query = query;\n })\n );\n };\n\n return { query, handleQueryChange, handleQueryBlur };\n}\n\n/**\n * Hook to manage `series_name_format` state to ensure panel preview does not rerender until text input is blurred\n */\nexport function useFormatState(props: PrometheusTimeSeriesQueryEditorProps) {\n const { onChange, value } = props;\n\n // TODO: reusable hook or helper util instead of duplicating from useQueryState\n const [format, setFormat] = useState(value.series_name_format);\n const [lastSyncedFormat, setLastSyncedFormat] = useState(value.series_name_format);\n if (value.series_name_format !== lastSyncedFormat) {\n setFormat(value.series_name_format);\n setLastSyncedFormat(value.series_name_format);\n }\n\n // Update our local state as the user types\n const handleFormatChange: TextFieldProps['onChange'] = (e) => {\n setFormat(e.target.value);\n };\n\n // Propagate changes to the panel preview component when series_name_format TextField is blurred\n const handleFormatBlur: TextFieldProps['onBlur'] = () => {\n setLastSyncedFormat(format);\n onChange(\n produce(value, (draft) => {\n draft.series_name_format = format;\n })\n );\n };\n\n return { format, handleFormatChange, handleFormatBlur };\n}\n"],"names":["useState","produce","useQueryState","props","onChange","value","query","setQuery","lastSyncedQuery","setLastSyncedQuery","handleQueryChange","e","target","handleQueryBlur","draft","useFormatState","format","setFormat","series_name_format","lastSyncedFormat","setLastSyncedFormat","handleFormatChange","handleFormatBlur"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,QAAQ,QAAQ,OAAO,CAAC;AAEjC,SAASC,OAAO,QAAQ,OAAO,CAAC;AAMhC;;;;;CAKC,GACD,OAAO,SAASC,aAAa,CAACC,KAA2C,EAAE;IACzE,MAAM,EAAEC,QAAQ,CAAA,EAAEC,KAAK,CAAA,EAAE,GAAGF,KAAK,AAAC;IAElC,kCAAkC;IAClC,MAAM,CAACG,KAAK,EAAEC,QAAQ,CAAC,GAAGP,QAAQ,CAACK,KAAK,CAACC,KAAK,CAAC,AAAC;IAEhD,gHAAgH;IAChH,kCAAkC;IAClC,MAAM,CAACE,eAAe,EAAEC,kBAAkB,CAAC,GAAGT,QAAQ,CAACK,KAAK,CAACC,KAAK,CAAC,AAAC;IACpE,IAAID,KAAK,CAACC,KAAK,KAAKE,eAAe,EAAE;QACnCD,QAAQ,CAACF,KAAK,CAACC,KAAK,CAAC,CAAC;QACtBG,kBAAkB,CAACJ,KAAK,CAACC,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,kDAAkD;IAClD,MAAMI,iBAAiB,GAA+B,CAACC,CAAC,GAAK;QAC3DJ,QAAQ,CAACI,CAAC,CAACC,MAAM,CAACP,KAAK,CAAC,CAAC;IAC3B,CAAC,AAAC;IAEF,iHAAiH;IACjH,eAAe;IACf,MAAMQ,eAAe,GAA6B,IAAM;QACtDJ,kBAAkB,CAACH,KAAK,CAAC,CAAC;QAC1BF,QAAQ,CACNH,O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 @@
|
|
|
1
|
+
import { DurationString } from '@perses-dev/core';
|
|
2
|
+
import { PrometheusDatasourceSelector, TemplateString } from '../../model';
|
|
3
|
+
/**
|
|
4
|
+
* The spec/options for the PrometheusTimeSeriesQuery plugin.
|
|
5
|
+
*/
|
|
6
|
+
export interface PrometheusTimeSeriesQuerySpec {
|
|
7
|
+
query: TemplateString;
|
|
8
|
+
series_name_format?: string;
|
|
9
|
+
min_step?: DurationString;
|
|
10
|
+
resolution?: number;
|
|
11
|
+
datasource?: PrometheusDatasourceSelector;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=time-series-query-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time-series-query-model.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-time-series-query/time-series-query-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,4BAA4B,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE3E;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,KAAK,EAAE,cAAc,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,4BAA4B,CAAC;CAC3C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export { };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=time-series-query-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/prometheus-time-series-query/time-series-query-model.ts"],"sourcesContent":["// Copyright 2022 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 { DurationString } from '@perses-dev/core';\nimport { PrometheusDatasourceSelector, TemplateString } from '../../model';\n\n/**\n * The spec/options for the PrometheusTimeSeriesQuery plugin.\n */\nexport interface PrometheusTimeSeriesQuerySpec {\n query: TemplateString;\n series_name_format?: string;\n min_step?: DurationString;\n resolution?: number;\n datasource?: PrometheusDatasourceSelector;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,WAYC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { VariablePlugin } from '@perses-dev/plugin-system';
|
|
2
|
+
import { PrometheusLabelNamesVariableOptions, PrometheusLabelValuesVariableOptions, PrometheusPromQLVariableOptions } from './types';
|
|
3
|
+
export declare const PrometheusLabelNamesVariable: VariablePlugin<PrometheusLabelNamesVariableOptions>;
|
|
4
|
+
export declare const PrometheusLabelValuesVariable: VariablePlugin<PrometheusLabelValuesVariableOptions>;
|
|
5
|
+
export declare const PrometheusPromQLVariable: VariablePlugin<PrometheusPromQLVariableOptions>;
|
|
6
|
+
//# sourceMappingURL=prometheus-variables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prometheus-variables.d.ts","sourceRoot":"","sources":["../../src/plugins/prometheus-variables.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,cAAc,EAAsC,MAAM,2BAA2B,CAAC;AAW/F,OAAO,EACL,mCAAmC,EACnC,oCAAoC,EACpC,+BAA+B,EAChC,MAAM,SAAS,CAAC;AA6FjB,eAAO,MAAM,4BAA4B,EAAE,cAAc,CAAC,mCAAmC,CAgB5F,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAE,cAAc,CAAC,oCAAoC,CA8B9F,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,cAAc,CAAC,+BAA+B,CAwBpF,CAAC"}
|