@perses-dev/prometheus-plugin 0.51.0-rc.0 → 0.51.0-rc.2
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/{622.d75cbbb4.js → 622.f8d6828c.js} +1 -1
- package/__mf/js/{Prometheus.4ed45674.js → Prometheus.b8130f02.js} +3 -3
- package/__mf/js/async/2285.15378f70.js +1 -0
- package/__mf/js/async/2675.99cf926f.js +1 -0
- package/__mf/js/async/3057.e568f9b6.js +7 -0
- package/__mf/js/async/{4489.3361e7bc.js.LICENSE.txt → 3057.e568f9b6.js.LICENSE.txt} +1 -17
- package/__mf/js/async/3090.9fb5fe73.js +2 -0
- package/__mf/js/async/3980.7cea5715.js +2 -0
- package/__mf/js/async/{6333.865a46e0.js.LICENSE.txt → 3980.7cea5715.js.LICENSE.txt} +2 -2
- package/__mf/js/async/4062.3ab7f987.js +1 -0
- package/__mf/js/async/4421.42e889f6.js +1 -0
- package/__mf/js/async/528.d364bb0e.js +1 -0
- package/__mf/js/async/{5345.8c2e4b4a.js → 5345.2e531d76.js} +1 -1
- package/__mf/js/async/5503.7153681d.js +1 -0
- package/__mf/js/async/5769.f14c9663.js +1 -0
- package/__mf/js/async/5913.4e5abd09.js +73 -0
- package/__mf/js/async/7376.c7eb05b9.js +1 -0
- package/__mf/js/async/8980.afe002d4.js +28 -0
- package/__mf/js/async/9550.e19763f8.js +38 -0
- package/__mf/js/async/__federation_expose_PrometheusDatasource.f9c8cf41.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusExplorer.f3fe63da.js +1 -0
- package/__mf/js/async/{__federation_expose_PrometheusLabelNamesVariable.86d0ad5a.js → __federation_expose_PrometheusLabelNamesVariable.873e5f4d.js} +1 -1
- package/__mf/js/async/{__federation_expose_PrometheusLabelValuesVariable.b2893484.js → __federation_expose_PrometheusLabelValuesVariable.6696e340.js} +1 -1
- package/__mf/js/async/{__federation_expose_PrometheusPromQLVariable.cd16f6e8.js → __federation_expose_PrometheusPromQLVariable.ab45c7cc.js} +1 -1
- package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.66611c9d.js +1 -0
- package/__mf/js/main.855882c0.js +1 -0
- package/lib/cjs/explore/PrometheusMetricsFinder/filter/FinderFilters.js +5 -1
- package/lib/cjs/model/prometheus-selectors.js +5 -4
- package/lib/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +3 -1
- package/lib/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +3 -2
- package/lib/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +4 -2
- package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.d.ts.map +1 -1
- package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.js +6 -2
- package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.js.map +1 -1
- package/lib/model/prometheus-selectors.d.ts +5 -4
- package/lib/model/prometheus-selectors.d.ts.map +1 -1
- package/lib/model/prometheus-selectors.js +7 -6
- package/lib/model/prometheus-selectors.js.map +1 -1
- package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.d.ts.map +1 -1
- package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +4 -2
- package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js.map +1 -1
- package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
- package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +4 -3
- package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -1
- package/lib/plugins/prometheus-time-series-query/get-time-series-data.d.ts.map +1 -1
- package/lib/plugins/prometheus-time-series-query/get-time-series-data.js +6 -4
- package/lib/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -1
- package/lib/plugins/prometheus-time-series-query/time-series-query-model.d.ts +2 -1
- package/lib/plugins/prometheus-time-series-query/time-series-query-model.d.ts.map +1 -1
- package/lib/plugins/prometheus-time-series-query/time-series-query-model.js.map +1 -1
- package/mf-manifest.json +194 -207
- package/mf-stats.json +200 -213
- package/package.json +9 -8
- package/__mf/js/async/1495.6c8b8071.js +0 -1
- package/__mf/js/async/1864.df7c4beb.js +0 -1
- package/__mf/js/async/1950.704c331e.js +0 -1
- package/__mf/js/async/1996.01084c88.js +0 -2
- package/__mf/js/async/2316.fec4907a.js +0 -1
- package/__mf/js/async/232.f3523a60.js +0 -1
- package/__mf/js/async/2675.c3b73822.js +0 -1
- package/__mf/js/async/3436.97c926a4.js +0 -1
- package/__mf/js/async/4421.1bcc1637.js +0 -1
- package/__mf/js/async/4489.3361e7bc.js +0 -29
- package/__mf/js/async/5387.fd6e16d6.js +0 -1
- package/__mf/js/async/5654.ecb41aea.js +0 -38
- package/__mf/js/async/5913.9d30fd07.js +0 -73
- package/__mf/js/async/6333.865a46e0.js +0 -2
- package/__mf/js/async/8265.b9e2c31e.js +0 -1
- package/__mf/js/async/8610.90592927.js +0 -1
- package/__mf/js/async/87.fdc843ac.js +0 -1
- package/__mf/js/async/8997.18901f45.js +0 -28
- package/__mf/js/async/__federation_expose_PrometheusDatasource.f6f57299.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusExplorer.e5f23291.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.eb9eefa6.js +0 -1
- package/__mf/js/main.a79f60cc.js +0 -1
- /package/__mf/js/async/{1996.01084c88.js.LICENSE.txt → 3090.9fb5fe73.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{5913.9d30fd07.js.LICENSE.txt → 5913.4e5abd09.js.LICENSE.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/explore/PrometheusMetricsFinder/filter/FinderFilters.tsx"],"sourcesContent":["// Copyright 2024 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 { Button, FormControl, InputLabel, Stack, StackProps } from '@mui/material';\nimport { DatasourceSelector } from '@perses-dev/core';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../src/explore/PrometheusMetricsFinder/filter/FinderFilters.tsx"],"sourcesContent":["// Copyright 2024 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 { Button, FormControl, InputLabel, Stack, StackProps } from '@mui/material';\nimport { DatasourceSelector } from '@perses-dev/core';\nimport {\n DatasourceSelect,\n DatasourceSelectValue,\n datasourceSelectValueToSelector,\n useListDatasourceSelectItems,\n} from '@perses-dev/plugin-system';\nimport PlusIcon from 'mdi-material-ui/Plus';\nimport { ReactElement } from 'react';\nimport { PROM_DATASOURCE_KIND } from '../../../model/prometheus-selectors';\nimport { LabelFilter } from '../types';\nimport { LabelFilterInput } from './FilterInputs';\n\nexport interface ExplorerFiltersProps extends StackProps {\n datasource: DatasourceSelector;\n filters: LabelFilter[];\n filteredFilters: LabelFilter[];\n onDatasourceChange: (next: DatasourceSelector) => void;\n onFiltersChange: (next: LabelFilter[]) => void;\n}\n\nexport function FinderFilters({\n datasource,\n filters,\n filteredFilters,\n onDatasourceChange,\n onFiltersChange,\n ...props\n}: ExplorerFiltersProps): ReactElement {\n const { data } = useListDatasourceSelectItems(PROM_DATASOURCE_KIND);\n function handleDatasourceChange(next: DatasourceSelectValue): void {\n const datasourceSelector = datasourceSelectValueToSelector(next, {}, data) ?? { kind: PROM_DATASOURCE_KIND };\n onDatasourceChange(datasourceSelector);\n }\n\n return (\n <Stack {...props} direction=\"row\" alignItems=\"center\" flexWrap=\"wrap\" gap={1} sx={{ width: '100%' }}>\n <FormControl>\n <InputLabel>Prometheus Datasource</InputLabel>\n <DatasourceSelect\n datasourcePluginKind={PROM_DATASOURCE_KIND}\n value={datasource}\n onChange={handleDatasourceChange}\n label=\"Prometheus Datasource\"\n />\n </FormControl>\n {filters.map((filter, index) => (\n <LabelFilterInput\n key={index}\n datasource={datasource}\n filters={filteredFilters}\n value={filter}\n onChange={(next) => {\n const nextFilters = [...filters];\n nextFilters[index] = next;\n onFiltersChange(nextFilters);\n }}\n onDelete={() => {\n const nextFilters = [...filters];\n nextFilters.splice(index, 1);\n onFiltersChange(nextFilters);\n }}\n />\n ))}\n <Button\n startIcon={<PlusIcon />}\n aria-label=\"add filter\"\n onClick={() => {\n onFiltersChange([...filters, { label: '', labelValues: [], operator: '=~' }]);\n }}\n >\n Add filter\n </Button>\n </Stack>\n );\n}\n"],"names":["Button","FormControl","InputLabel","Stack","DatasourceSelect","datasourceSelectValueToSelector","useListDatasourceSelectItems","PlusIcon","PROM_DATASOURCE_KIND","LabelFilterInput","FinderFilters","datasource","filters","filteredFilters","onDatasourceChange","onFiltersChange","props","data","handleDatasourceChange","next","datasourceSelector","kind","direction","alignItems","flexWrap","gap","sx","width","datasourcePluginKind","value","onChange","label","map","filter","index","nextFilters","onDelete","splice","startIcon","aria-label","onClick","labelValues","operator"],"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,MAAM,EAAEC,WAAW,EAAEC,UAAU,EAAEC,KAAK,QAAoB,gB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BACD;;;;AAKP"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DatasourceSelector } from '@perses-dev/core';
|
|
2
|
+
import { DatasourceSelectValue } from '@perses-dev/plugin-system';
|
|
2
3
|
export declare const PROM_DATASOURCE_KIND: "PrometheusDatasource";
|
|
3
4
|
/**
|
|
4
5
|
* DatasourceSelector for Prom Datasources.
|
|
@@ -11,11 +12,11 @@ export interface PrometheusDatasourceSelector extends DatasourceSelector {
|
|
|
11
12
|
*/
|
|
12
13
|
export declare const DEFAULT_PROM: PrometheusDatasourceSelector;
|
|
13
14
|
/**
|
|
14
|
-
* Returns true if the provided
|
|
15
|
+
* Returns true if the provided datasourceSelectValue is the default PrometheusDatasourceSelector.
|
|
15
16
|
*/
|
|
16
|
-
export declare function isDefaultPromSelector(
|
|
17
|
+
export declare function isDefaultPromSelector(datasourceSelectValue: DatasourceSelectValue): boolean;
|
|
17
18
|
/**
|
|
18
|
-
* Type guard to make sure a
|
|
19
|
+
* Type guard to make sure a datasourceSelectValue is a Prometheus one.
|
|
19
20
|
*/
|
|
20
|
-
export declare function isPrometheusDatasourceSelector(
|
|
21
|
+
export declare function isPrometheusDatasourceSelector(datasourceSelectValue: DatasourceSelectValue): datasourceSelectValue is PrometheusDatasourceSelector;
|
|
21
22
|
//# sourceMappingURL=prometheus-selectors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prometheus-selectors.d.ts","sourceRoot":"","sources":["../../../src/model/prometheus-selectors.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"prometheus-selectors.d.ts","sourceRoot":"","sources":["../../../src/model/prometheus-selectors.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAwB,MAAM,2BAA2B,CAAC;AAExF,eAAO,MAAM,oBAAoB,EAAG,sBAA+B,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,kBAAkB;IACtE,IAAI,EAAE,OAAO,oBAAoB,CAAC;CACnC;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,4BAA6D,CAAC;AAEzF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,qBAAqB,EAAE,qBAAqB,GAAG,OAAO,CAE3F;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,qBAAqB,EAAE,qBAAqB,GAC3C,qBAAqB,IAAI,4BAA4B,CAEvD"}
|
|
@@ -10,6 +10,7 @@
|
|
|
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 { isVariableDatasource } from '@perses-dev/plugin-system';
|
|
13
14
|
export const PROM_DATASOURCE_KIND = 'PrometheusDatasource';
|
|
14
15
|
/**
|
|
15
16
|
* A default selector that asks for the default Prom Datasource.
|
|
@@ -17,14 +18,14 @@ export const PROM_DATASOURCE_KIND = 'PrometheusDatasource';
|
|
|
17
18
|
kind: PROM_DATASOURCE_KIND
|
|
18
19
|
};
|
|
19
20
|
/**
|
|
20
|
-
* Returns true if the provided
|
|
21
|
-
*/ export function isDefaultPromSelector(
|
|
22
|
-
return
|
|
21
|
+
* Returns true if the provided datasourceSelectValue is the default PrometheusDatasourceSelector.
|
|
22
|
+
*/ export function isDefaultPromSelector(datasourceSelectValue) {
|
|
23
|
+
return !isVariableDatasource(datasourceSelectValue) && datasourceSelectValue.name === undefined;
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
|
-
* Type guard to make sure a
|
|
26
|
-
*/ export function isPrometheusDatasourceSelector(
|
|
27
|
-
return
|
|
26
|
+
* Type guard to make sure a datasourceSelectValue is a Prometheus one.
|
|
27
|
+
*/ export function isPrometheusDatasourceSelector(datasourceSelectValue) {
|
|
28
|
+
return isVariableDatasource(datasourceSelectValue) || datasourceSelectValue.kind === PROM_DATASOURCE_KIND;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
//# sourceMappingURL=prometheus-selectors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/model/prometheus-selectors.ts"],"sourcesContent":["// Copyright 2023 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 { DatasourceSelector } from '@perses-dev/core';\n\nexport const PROM_DATASOURCE_KIND = 'PrometheusDatasource' as const;\n\n/**\n * DatasourceSelector for Prom Datasources.\n */\nexport interface PrometheusDatasourceSelector extends DatasourceSelector {\n kind: typeof PROM_DATASOURCE_KIND;\n}\n\n/**\n * A default selector that asks for the default Prom Datasource.\n */\nexport const DEFAULT_PROM: PrometheusDatasourceSelector = { kind: PROM_DATASOURCE_KIND };\n\n/**\n * Returns true if the provided
|
|
1
|
+
{"version":3,"sources":["../../../src/model/prometheus-selectors.ts"],"sourcesContent":["// Copyright 2023 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 { DatasourceSelector } from '@perses-dev/core';\nimport { DatasourceSelectValue, isVariableDatasource } from '@perses-dev/plugin-system';\n\nexport const PROM_DATASOURCE_KIND = 'PrometheusDatasource' as const;\n\n/**\n * DatasourceSelector for Prom Datasources.\n */\nexport interface PrometheusDatasourceSelector extends DatasourceSelector {\n kind: typeof PROM_DATASOURCE_KIND;\n}\n\n/**\n * A default selector that asks for the default Prom Datasource.\n */\nexport const DEFAULT_PROM: PrometheusDatasourceSelector = { kind: PROM_DATASOURCE_KIND };\n\n/**\n * Returns true if the provided datasourceSelectValue is the default PrometheusDatasourceSelector.\n */\nexport function isDefaultPromSelector(datasourceSelectValue: DatasourceSelectValue): boolean {\n return !isVariableDatasource(datasourceSelectValue) && datasourceSelectValue.name === undefined;\n}\n\n/**\n * Type guard to make sure a datasourceSelectValue is a Prometheus one.\n */\nexport function isPrometheusDatasourceSelector(\n datasourceSelectValue: DatasourceSelectValue\n): datasourceSelectValue is PrometheusDatasourceSelector {\n return isVariableDatasource(datasourceSelectValue) || datasourceSelectValue.kind === PROM_DATASOURCE_KIND;\n}\n"],"names":["isVariableDatasource","PROM_DATASOURCE_KIND","DEFAULT_PROM","kind","isDefaultPromSelector","datasourceSelectValue","name","undefined","isPrometheusDatasourceSelector"],"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,SAAgCA,oBAAoB,QAAQ,4BAA4B;AAExF,OAAO,MAAMC,uBAAuB,uBAAgC;AASpE;;CAEC,GACD,OAAO,MAAMC,eAA6C;IAAEC,MAAMF;AAAqB,EAAE;AAEzF;;CAEC,GACD,OAAO,SAASG,sBAAsBC,qBAA4C;IAChF,OAAO,CAACL,qBAAqBK,0BAA0BA,sBAAsBC,IAAI,KAAKC;AACxF;AAEA;;CAEC,GACD,OAAO,SAASC,+BACdH,qBAA4C;IAE5C,OAAOL,qBAAqBK,0BAA0BA,sBAAsBF,IAAI,KAAKF;AACvF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrometheusTimeSeriesQuery.d.ts","sourceRoot":"","sources":["../../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"PrometheusTimeSeriesQuery.d.ts","sourceRoot":"","sources":["../../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,qBAAqB,EAAwC,MAAM,2BAA2B,CAAC;AAGxG,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAE1E;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,qBAAqB,CAAC,6BAA6B,CAiB1F,CAAC"}
|
|
@@ -10,7 +10,7 @@
|
|
|
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 { parseVariables } from '@perses-dev/plugin-system';
|
|
13
|
+
import { isVariableDatasource, parseVariables } from '@perses-dev/plugin-system';
|
|
14
14
|
import { getTimeSeriesData } from './get-time-series-data';
|
|
15
15
|
import { PrometheusTimeSeriesQueryEditor } from './PrometheusTimeSeriesQueryEditor';
|
|
16
16
|
/**
|
|
@@ -26,10 +26,12 @@ import { PrometheusTimeSeriesQueryEditor } from './PrometheusTimeSeriesQueryEdit
|
|
|
26
26
|
// Variables can be used in the query and/or in the legend format string
|
|
27
27
|
const queryVariables = parseVariables(spec.query);
|
|
28
28
|
const legendVariables = parseVariables(spec.seriesNameFormat || '');
|
|
29
|
+
const datasourceVariable = isVariableDatasource(spec.datasource) ? parseVariables(spec.datasource ?? '') : [];
|
|
29
30
|
const allVariables = [
|
|
30
31
|
...new Set([
|
|
31
32
|
...queryVariables,
|
|
32
|
-
...legendVariables
|
|
33
|
+
...legendVariables,
|
|
34
|
+
...datasourceVariable
|
|
33
35
|
])
|
|
34
36
|
];
|
|
35
37
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.ts"],"sourcesContent":["// Copyright 2024 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, parseVariables } from '@perses-dev/plugin-system';\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 // Variables can be used in the query and/or in the legend format string\n const queryVariables = parseVariables(spec.query);\n const legendVariables = parseVariables(spec.seriesNameFormat || '');\n const allVariables = [...new Set([...queryVariables, ...legendVariables])];\n return {\n variables: allVariables,\n };\n },\n};\n"],"names":["parseVariables","getTimeSeriesData","PrometheusTimeSeriesQueryEditor","PrometheusTimeSeriesQuery","OptionsEditorComponent","createInitialOptions","query","datasource","undefined","dependsOn","spec","queryVariables","legendVariables","seriesNameFormat","allVariables","Set","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;AAEjC,SAAgCA,cAAc,QAAQ,4BAA4B;
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.ts"],"sourcesContent":["// Copyright 2024 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, isVariableDatasource, parseVariables } from '@perses-dev/plugin-system';\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 // Variables can be used in the query and/or in the legend format string\n const queryVariables = parseVariables(spec.query);\n const legendVariables = parseVariables(spec.seriesNameFormat || '');\n const datasourceVariable = isVariableDatasource(spec.datasource) ? parseVariables(spec.datasource ?? '') : [];\n const allVariables = [...new Set([...queryVariables, ...legendVariables, ...datasourceVariable])];\n return {\n variables: allVariables,\n };\n },\n};\n"],"names":["isVariableDatasource","parseVariables","getTimeSeriesData","PrometheusTimeSeriesQueryEditor","PrometheusTimeSeriesQuery","OptionsEditorComponent","createInitialOptions","query","datasource","undefined","dependsOn","spec","queryVariables","legendVariables","seriesNameFormat","datasourceVariable","allVariables","Set","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;AAEjC,SAAgCA,oBAAoB,EAAEC,cAAc,QAAQ,4BAA4B;AACxG,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,+BAA+B,QAAQ,oCAAoC;AAGpF;;CAEC,GACD,OAAO,MAAMC,4BAAkF;IAC7FF;IACAG,wBAAwBF;IACxBG,sBAAsB,IAAO,CAAA;YAC3BC,OAAO;YACPC,YAAYC;QACd,CAAA;IACAC,WAAW,CAACC;QACV,wEAAwE;QACxE,MAAMC,iBAAiBX,eAAeU,KAAKJ,KAAK;QAChD,MAAMM,kBAAkBZ,eAAeU,KAAKG,gBAAgB,IAAI;QAChE,MAAMC,qBAAqBf,qBAAqBW,KAAKH,UAAU,IAAIP,eAAeU,KAAKH,UAAU,IAAI,MAAM,EAAE;QAC7G,MAAMQ,eAAe;eAAI,IAAIC,IAAI;mBAAIL;mBAAmBC;mBAAoBE;aAAmB;SAAE;QACjG,OAAO;YACLG,WAAWF;QACb;IACF;AACF,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrometheusTimeSeriesQueryEditor.d.ts","sourceRoot":"","sources":["../../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PrometheusTimeSeriesQueryEditor.d.ts","sourceRoot":"","sources":["../../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.tsx"],"names":[],"mappings":"AAuBA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAYrC,OAAO,EACL,oCAAoC,EAIrC,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,oCAAoC,GAAG,YAAY,CAmFzG"}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { produce } from 'immer';
|
|
15
|
-
import { DatasourceSelect, useDatasource, useDatasourceClient } from '@perses-dev/plugin-system';
|
|
15
|
+
import { DatasourceSelect, useDatasource, useDatasourceClient, useDatasourceSelectValueToSelector } from '@perses-dev/plugin-system';
|
|
16
16
|
import { useId } from '@perses-dev/components';
|
|
17
17
|
import { FormControl, InputLabel, Stack, TextField } from '@mui/material';
|
|
18
18
|
import { DEFAULT_PROM, isDefaultPromSelector, isPrometheusDatasourceSelector, PROM_DATASOURCE_KIND } from '../../model';
|
|
@@ -24,8 +24,9 @@ import { useQueryState, useFormatState, useMinStepState } from './query-editor-m
|
|
|
24
24
|
*/ export function PrometheusTimeSeriesQueryEditor(props) {
|
|
25
25
|
const { onChange, value } = props;
|
|
26
26
|
const { datasource } = value;
|
|
27
|
-
const
|
|
27
|
+
const datasourceSelectValue = datasource ?? DEFAULT_PROM;
|
|
28
28
|
const datasourceSelectLabelID = useId('prom-datasource-label'); // for panels with multiple queries, this component is rendered multiple times on the same page
|
|
29
|
+
const selectedDatasource = useDatasourceSelectValueToSelector(datasourceSelectValue, PROM_DATASOURCE_KIND);
|
|
29
30
|
const { data: client } = useDatasourceClient(selectedDatasource);
|
|
30
31
|
const promURL = client?.options.datasourceUrl;
|
|
31
32
|
const { data: datasourceResource } = useDatasource(selectedDatasource);
|
|
@@ -58,7 +59,7 @@ import { useQueryState, useFormatState, useMinStepState } from './query-editor-m
|
|
|
58
59
|
}),
|
|
59
60
|
/*#__PURE__*/ _jsx(DatasourceSelect, {
|
|
60
61
|
datasourcePluginKind: PROM_DATASOURCE_KIND,
|
|
61
|
-
value:
|
|
62
|
+
value: datasourceSelectValue,
|
|
62
63
|
onChange: handleDatasourceChange,
|
|
63
64
|
labelId: datasourceSelectLabelID,
|
|
64
65
|
label: "Prometheus Datasource",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.tsx"],"sourcesContent":["// Copyright 2023 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 {
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.tsx"],"sourcesContent":["// Copyright 2023 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 {\n DatasourceSelect,\n DatasourceSelectProps,\n useDatasource,\n useDatasourceClient,\n useDatasourceSelectValueToSelector,\n} from '@perses-dev/plugin-system';\nimport { useId } from '@perses-dev/components';\nimport { FormControl, InputLabel, Stack, TextField } from '@mui/material';\nimport { ReactElement } from 'react';\nimport {\n DEFAULT_PROM,\n DurationString,\n isDefaultPromSelector,\n isPrometheusDatasourceSelector,\n PROM_DATASOURCE_KIND,\n PrometheusClient,\n PrometheusDatasourceSelector,\n} from '../../model';\nimport { DEFAULT_SCRAPE_INTERVAL, PrometheusDatasourceSpec } from '../types';\nimport { PromQLEditor } from '../../components';\nimport {\n PrometheusTimeSeriesQueryEditorProps,\n useQueryState,\n useFormatState,\n useMinStepState,\n} from './query-editor-model';\n\n/**\n * The options editor component for editing a PrometheusTimeSeriesQuery's spec.\n */\nexport function PrometheusTimeSeriesQueryEditor(props: PrometheusTimeSeriesQueryEditorProps): ReactElement {\n const { onChange, value } = props;\n const { datasource } = value;\n const datasourceSelectValue = datasource ?? DEFAULT_PROM;\n\n const datasourceSelectLabelID = useId('prom-datasource-label'); // for panels with multiple queries, this component is rendered multiple times on the same page\n\n const selectedDatasource = useDatasourceSelectValueToSelector(\n datasourceSelectValue,\n PROM_DATASOURCE_KIND\n ) as PrometheusDatasourceSelector;\n\n const { data: client } = useDatasourceClient<PrometheusClient>(selectedDatasource);\n const promURL = client?.options.datasourceUrl;\n const { data: datasourceResource } = useDatasource(selectedDatasource);\n\n const { handleQueryChange, handleQueryBlur } = useQueryState(props);\n const { format, handleFormatChange, handleFormatBlur } = useFormatState(props);\n const { minStep, handleMinStepChange, handleMinStepBlur } = useMinStepState(props);\n const minStepPlaceholder =\n minStep ??\n (datasourceResource && (datasourceResource?.plugin.spec as PrometheusDatasourceSpec).scrapeInterval) ??\n DEFAULT_SCRAPE_INTERVAL;\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 <FormControl margin=\"dense\" fullWidth={false}>\n <InputLabel id={datasourceSelectLabelID} shrink>\n Prometheus Datasource\n </InputLabel>\n <DatasourceSelect\n datasourcePluginKind={PROM_DATASOURCE_KIND}\n value={datasourceSelectValue}\n onChange={handleDatasourceChange}\n labelId={datasourceSelectLabelID}\n label=\"Prometheus Datasource\"\n notched\n />\n </FormControl>\n <PromQLEditor\n completeConfig={{ remote: { url: promURL } }}\n value={value.query} // here we are passing `value.query` and not `query` from useQueryState in order to get updates only on onBlur events\n datasource={selectedDatasource}\n onChange={handleQueryChange}\n onBlur={handleQueryBlur}\n />\n <Stack direction=\"row\" spacing={2}>\n <TextField\n fullWidth\n label=\"Legend\"\n placeholder=\"Example: '{{instance}}' will generate series names like 'webserver-123', 'webserver-456'...\"\n helperText=\"Text to be displayed in the legend and the tooltip. Use {{label_name}} to interpolate label values.\"\n value={format ?? ''}\n onChange={(e) => handleFormatChange(e.target.value)}\n onBlur={handleFormatBlur}\n />\n <TextField\n label=\"Min Step\"\n placeholder={minStepPlaceholder}\n helperText=\"Lower bound for the step. If not provided, the scrape interval of the datasource is used.\"\n value={minStep}\n onChange={(e) => handleMinStepChange(e.target.value as DurationString)}\n onBlur={handleMinStepBlur}\n sx={{ width: '250px' }}\n />\n </Stack>\n </Stack>\n );\n}\n"],"names":["produce","DatasourceSelect","useDatasource","useDatasourceClient","useDatasourceSelectValueToSelector","useId","FormControl","InputLabel","Stack","TextField","DEFAULT_PROM","isDefaultPromSelector","isPrometheusDatasourceSelector","PROM_DATASOURCE_KIND","DEFAULT_SCRAPE_INTERVAL","PromQLEditor","useQueryState","useFormatState","useMinStepState","PrometheusTimeSeriesQueryEditor","props","onChange","value","datasource","datasourceSelectValue","datasourceSelectLabelID","selectedDatasource","data","client","promURL","options","datasourceUrl","datasourceResource","handleQueryChange","handleQueryBlur","format","handleFormatChange","handleFormatBlur","minStep","handleMinStepChange","handleMinStepBlur","minStepPlaceholder","plugin","spec","scrapeInterval","handleDatasourceChange","next","draft","nextDatasource","undefined","Error","spacing","margin","fullWidth","id","shrink","datasourcePluginKind","labelId","label","notched","completeConfig","remote","url","query","onBlur","direction","placeholder","helperText","e","target","sx","width"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C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BC,cAAc,AAAD,KAClG9B;IAEF,MAAM+B,yBAA4D,CAACC;QACjE,IAAIlC,+BAA+BkC,OAAO;YACxCzB,SACErB,QAAQsB,OAAO,CAACyB;gBACd,sFAAsF;gBACtF,MAAMC,iBAAiBrC,sBAAsBmC,QAAQG,YAAYH;gBACjEC,MAAMxB,UAAU,GAAGyB;YACrB;YAEF;QACF;QAEA,MAAM,IAAIE,MAAM;IAClB;IAEA,qBACE,MAAC1C;QAAM2C,SAAS;;0BACd,MAAC7C;gBAAY8C,QAAO;gBAAQC,WAAW;;kCACrC,KAAC9C;wBAAW+C,IAAI7B;wBAAyB8B,MAAM;kCAAC;;kCAGhD,KAACtD;wBACCuD,sBAAsB3C;wBACtBS,OAAOE;wBACPH,UAAUwB;wBACVY,SAAShC;wBACTiC,OAAM;wBACNC,OAAO;;;;0BAGX,KAAC5C;gBACC6C,gBAAgB;oBAAEC,QAAQ;wBAAEC,KAAKjC;oBAAQ;gBAAE;gBAC3CP,OAAOA,MAAMyC,KAAK;gBAClBxC,YAAYG;gBACZL,UAAUY;gBACV+B,QAAQ9B;;0BAEV,MAAC1B;gBAAMyD,WAAU;gBAAMd,SAAS;;kCAC9B,KAAC1C;wBACC4C,SAAS;wBACTK,OAAM;wBACNQ,aAAY;wBACZC,YAAW;wBACX7C,OAAOa,UAAU;wBACjBd,UAAU,CAAC+C,IAAMhC,mBAAmBgC,EAAEC,MAAM,CAAC/C,KAAK;wBAClD0C,QAAQ3B;;kCAEV,KAAC5B;wBACCiD,OAAM;wBACNQ,aAAazB;wBACb0B,YAAW;wBACX7C,OAAOgB;wBACPjB,UAAU,CAAC+C,IAAM7B,oBAAoB6B,EAAEC,MAAM,CAAC/C,KAAK;wBACnD0C,QAAQxB;wBACR8B,IAAI;4BAAEC,OAAO;wBAAQ;;;;;;AAK/B"}
|
|
@@ -1 +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":"AAqBA,OAAO,EAAE,qBAAqB,
|
|
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":"AAqBA,OAAO,EAAE,qBAAqB,EAAqD,MAAM,2BAA2B,CAAC;AAiBrH,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAG1E,eAAO,MAAM,iBAAiB,EAAE,qBAAqB,CAAC,6BAA6B,CAAC,CAAC,mBAAmB,CA8GvG,CAAC"}
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { parseDurationString } from '@perses-dev/core';
|
|
14
|
-
import { replaceVariables } from '@perses-dev/plugin-system';
|
|
14
|
+
import { datasourceSelectValueToSelector, replaceVariables } from '@perses-dev/plugin-system';
|
|
15
15
|
import { fromUnixTime, milliseconds } from 'date-fns';
|
|
16
|
-
import { parseValueTuple, getDurationStringSeconds, getPrometheusTimeRange, getRangeStep, DEFAULT_PROM } from '../../model';
|
|
16
|
+
import { parseValueTuple, getDurationStringSeconds, getPrometheusTimeRange, getRangeStep, DEFAULT_PROM, PROM_DATASOURCE_KIND } from '../../model';
|
|
17
17
|
import { getFormattedPrometheusSeriesName } from '../../utils';
|
|
18
18
|
import { DEFAULT_SCRAPE_INTERVAL } from '../types';
|
|
19
19
|
import { replacePromBuiltinVariables } from './replace-prom-builtin-variables';
|
|
@@ -24,7 +24,9 @@ export const getTimeSeriesData = async (spec, context)=>{
|
|
|
24
24
|
series: []
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
const
|
|
27
|
+
const listDatasourceSelectItems = await context.datasourceStore.listDatasourceSelectItems(PROM_DATASOURCE_KIND);
|
|
28
|
+
const selectedDatasource = datasourceSelectValueToSelector(spec.datasource ?? DEFAULT_PROM, context.variableState, listDatasourceSelectItems) ?? DEFAULT_PROM;
|
|
29
|
+
const datasource = await context.datasourceStore.getDatasource(selectedDatasource);
|
|
28
30
|
const datasourceScrapeInterval = Math.trunc(milliseconds(parseDurationString(datasource.plugin.spec.scrapeInterval ?? DEFAULT_SCRAPE_INTERVAL)) / 1000);
|
|
29
31
|
// Min step is the lower bound of the interval between data points
|
|
30
32
|
// If no value is provided for it, it should default to the scrape interval of the datasource
|
|
@@ -51,7 +53,7 @@ export const getTimeSeriesData = async (spec, context)=>{
|
|
|
51
53
|
seriesNameFormat = replaceVariables(seriesNameFormat, context.variableState);
|
|
52
54
|
}
|
|
53
55
|
// Get the datasource, using the default Prom Datasource if one isn't specified in the query
|
|
54
|
-
const client = await context.datasourceStore.getDatasourceClient(
|
|
56
|
+
const client = await context.datasourceStore.getDatasourceClient(selectedDatasource);
|
|
55
57
|
// Make the request to Prom
|
|
56
58
|
let response;
|
|
57
59
|
switch(context.mode){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/plugins/prometheus-time-series-query/get-time-series-data.ts"],"sourcesContent":["// Copyright 2025 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 DatasourceSpec,\n DurationString,\n Notice,\n parseDurationString,\n TimeSeries,\n TimeSeriesData,\n} from '@perses-dev/core';\nimport { TimeSeriesQueryPlugin, replaceVariables } from '@perses-dev/plugin-system';\nimport { fromUnixTime, milliseconds } from 'date-fns';\nimport {\n parseValueTuple,\n PrometheusClient,\n getDurationStringSeconds,\n getPrometheusTimeRange,\n getRangeStep,\n DEFAULT_PROM,\n MatrixData,\n VectorData,\n ScalarData,\n InstantQueryResultType,\n} from '../../model';\nimport { getFormattedPrometheusSeriesName } from '../../utils';\nimport { DEFAULT_SCRAPE_INTERVAL, PrometheusDatasourceSpec } from '../types';\nimport { PrometheusTimeSeriesQuerySpec } from './time-series-query-model';\nimport { replacePromBuiltinVariables } from './replace-prom-builtin-variables';\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 datasource = (await context.datasourceStore.getDatasource(\n spec.datasource ?? DEFAULT_PROM\n )) as DatasourceSpec<PrometheusDatasourceSpec>;\n const datasourceScrapeInterval = Math.trunc(\n milliseconds(parseDurationString(datasource.plugin.spec.scrapeInterval ?? DEFAULT_SCRAPE_INTERVAL)) / 1000\n );\n\n // Min step is the lower bound of the interval between data points\n // If no value is provided for it, it should default to the scrape interval of the datasource\n const minStep =\n getDurationStringSeconds(\n // resolve any variable that may have been provided\n // TODO add a validation check to make sure the variable is a DurationString, to avoid the back & forth cast here\n replaceVariables(spec.minStep as string, context.variableState) as DurationString\n ) ?? datasourceScrapeInterval;\n const timeRange = getPrometheusTimeRange(context.timeRange);\n const step = getRangeStep(timeRange, minStep, undefined, context.suggestedStepMs); // TODO: resolution\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 variable placeholders in PromQL query\n const intervalMs = step * 1000;\n const minStepMs = minStep * 1000;\n let query = replacePromBuiltinVariables(spec.query, minStepMs, intervalMs);\n query = replaceVariables(query, context.variableState);\n\n let seriesNameFormat = spec.seriesNameFormat;\n // if series name format is defined, replace variable placeholders in series name format\n if (seriesNameFormat) {\n seriesNameFormat = replaceVariables(seriesNameFormat, context.variableState);\n }\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 let response;\n switch (context.mode) {\n case 'instant':\n response = await client.instantQuery({\n query,\n time: end,\n });\n break;\n case 'range':\n default:\n response = await client.rangeQuery({\n query,\n start,\n end,\n step,\n });\n break;\n }\n\n // TODO: What about error responses from Prom that have a response body?\n const result = response.data;\n\n // Custom display for response header warnings, configurable error responses display coming next\n const notices: Notice[] = [];\n if (response.status === 'success') {\n const warnings = response.warnings ?? [];\n const warningMessage = warnings[0] ?? '';\n if (warningMessage !== '') {\n notices.push({\n type: 'warning',\n message: warningMessage,\n });\n }\n }\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 series: buildTimeSeries(query, result, seriesNameFormat),\n metadata: {\n notices,\n executedQueryString: query,\n },\n };\n\n return chartData;\n};\n\nfunction buildVectorData(query: string, data: VectorData, seriesNameFormat: string | undefined): TimeSeries[] {\n return data.result.map((res) => {\n const { metric, value, histogram } = res;\n\n // Account for seriesNameFormat from query editor when determining name to show in legend, tooltip, etc.\n const { name, formattedName } = getFormattedPrometheusSeriesName(query, metric, seriesNameFormat);\n\n if (histogram) {\n return {\n name,\n formattedName,\n labels: metric,\n values: [parseValueTuple([histogram[0], histogram[1].sum])],\n histograms: [histogram],\n };\n }\n\n return {\n name,\n formattedName,\n labels: metric,\n values: [parseValueTuple(value)],\n };\n });\n}\n\nfunction buildMatrixData(query: string, data: MatrixData, seriesNameFormat: string | undefined): TimeSeries[] {\n return data.result.map((res) => {\n const { metric, values, histograms } = res;\n\n // Account for seriesNameFormat from query editor when determining name to show in legend, tooltip, etc.\n const { name, formattedName } = getFormattedPrometheusSeriesName(query, metric, seriesNameFormat);\n\n if (histograms) {\n return {\n name,\n formattedName,\n labels: metric,\n values: histograms.map((histogram) => parseValueTuple([histogram[0], histogram[1].sum])),\n histograms: histograms.map((histogram) => histogram),\n };\n }\n\n return {\n name,\n formattedName,\n labels: metric,\n values: values.map(parseValueTuple),\n };\n });\n}\n\nfunction buildScalarData(query: string, data: ScalarData, seriesNameFormat: string | undefined): TimeSeries[] {\n const { name, formattedName } = getFormattedPrometheusSeriesName(query, {}, seriesNameFormat);\n return [\n {\n name,\n values: [parseValueTuple(data.result)],\n formattedName,\n },\n ];\n}\n\nfunction buildTimeSeries(query: string, data?: InstantQueryResultType, seriesNameFormat?: string): TimeSeries[] {\n if (!data) {\n return [];\n }\n\n const resultType = data.resultType;\n switch (resultType) {\n case 'vector':\n return buildVectorData(query, data, seriesNameFormat);\n case 'matrix':\n return buildMatrixData(query, data, seriesNameFormat);\n case 'scalar':\n return buildScalarData(query, data, seriesNameFormat);\n default:\n console.warn('Unknown result type', resultType, data);\n return [];\n }\n}\n"],"names":["parseDurationString","replaceVariables","fromUnixTime","milliseconds","parseValueTuple","getDurationStringSeconds","getPrometheusTimeRange","getRangeStep","DEFAULT_PROM","getFormattedPrometheusSeriesName","DEFAULT_SCRAPE_INTERVAL","replacePromBuiltinVariables","getTimeSeriesData","spec","context","query","undefined","series","datasource","datasourceStore","getDatasource","datasourceScrapeInterval","Math","trunc","plugin","scrapeInterval","minStep","variableState","timeRange","step","suggestedStepMs","start","end","utcOffsetSec","Date","getTimezoneOffset","alignedEnd","floor","alignedStart","intervalMs","minStepMs","seriesNameFormat","client","getDatasourceClient","response","mode","instantQuery","time","rangeQuery","result","data","notices","status","warnings","warningMessage","push","type","message","chartData","stepMs","buildTimeSeries","metadata","executedQueryString","buildVectorData","map","res","metric","value","histogram","name","formattedName","labels","values","sum","histograms","buildMatrixData","buildScalarData","resultType","console","warn"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC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AAYA,WAAWV,GAAG,CAAC,CAACI,YAAcA;YAC5C;QACF;QAEA,OAAO;YACLC;YACAC;YACAC,QAAQL;YACRM,QAAQA,OAAOR,GAAG,CAAC5D;QACrB;IACF;AACF;AAEA,SAASwE,gBAAgB7D,KAAa,EAAEmC,IAAgB,EAAET,gBAAoC;IAC5F,MAAM,EAAE4B,IAAI,EAAEC,aAAa,EAAE,GAAG7D,iCAAiCM,OAAO,CAAC,GAAG0B;IAC5E,OAAO;QACL;YACE4B;YACAG,QAAQ;gBAACpE,gBAAgB8C,KAAKD,MAAM;aAAE;YACtCqB;QACF;KACD;AACH;AAEA,SAASV,gBAAgB7C,KAAa,EAAEmC,IAA6B,EAAET,gBAAyB;IAC9F,IAAI,CAACS,MAAM;QACT,OAAO,EAAE;IACX;IAEA,MAAM2B,aAAa3B,KAAK2B,UAAU;IAClC,OAAQA;QACN,KAAK;YACH,OAAOd,gBAAgBhD,OAAOmC,MAAMT;QACtC,KAAK;YACH,OAAOkC,gBAAgB5D,OAAOmC,MAAMT;QACtC,KAAK;YACH,OAAOmC,gBAAgB7D,OAAOmC,MAAMT;QACtC;YACEqC,QAAQC,IAAI,CAAC,uBAAuBF,YAAY3B;YAChD,OAAO,EAAE;IACb;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/prometheus-time-series-query/get-time-series-data.ts"],"sourcesContent":["// Copyright 2025 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 DatasourceSpec,\n DurationString,\n Notice,\n parseDurationString,\n TimeSeries,\n TimeSeriesData,\n} from '@perses-dev/core';\nimport { TimeSeriesQueryPlugin, datasourceSelectValueToSelector, replaceVariables } from '@perses-dev/plugin-system';\nimport { fromUnixTime, milliseconds } from 'date-fns';\nimport {\n parseValueTuple,\n PrometheusClient,\n getDurationStringSeconds,\n getPrometheusTimeRange,\n getRangeStep,\n DEFAULT_PROM,\n MatrixData,\n VectorData,\n ScalarData,\n InstantQueryResultType,\n PROM_DATASOURCE_KIND,\n} from '../../model';\nimport { getFormattedPrometheusSeriesName } from '../../utils';\nimport { DEFAULT_SCRAPE_INTERVAL, PrometheusDatasourceSpec } from '../types';\nimport { PrometheusTimeSeriesQuerySpec } from './time-series-query-model';\nimport { replacePromBuiltinVariables } from './replace-prom-builtin-variables';\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 listDatasourceSelectItems = await context.datasourceStore.listDatasourceSelectItems(PROM_DATASOURCE_KIND);\n\n const selectedDatasource =\n datasourceSelectValueToSelector(\n spec.datasource ?? DEFAULT_PROM,\n context.variableState,\n listDatasourceSelectItems\n ) ?? DEFAULT_PROM;\n\n const datasource = (await context.datasourceStore.getDatasource(\n selectedDatasource\n )) as DatasourceSpec<PrometheusDatasourceSpec>;\n const datasourceScrapeInterval = Math.trunc(\n milliseconds(parseDurationString(datasource.plugin.spec.scrapeInterval ?? DEFAULT_SCRAPE_INTERVAL)) / 1000\n );\n\n // Min step is the lower bound of the interval between data points\n // If no value is provided for it, it should default to the scrape interval of the datasource\n const minStep =\n getDurationStringSeconds(\n // resolve any variable that may have been provided\n // TODO add a validation check to make sure the variable is a DurationString, to avoid the back & forth cast here\n replaceVariables(spec.minStep as string, context.variableState) as DurationString\n ) ?? datasourceScrapeInterval;\n const timeRange = getPrometheusTimeRange(context.timeRange);\n const step = getRangeStep(timeRange, minStep, undefined, context.suggestedStepMs); // TODO: resolution\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 variable placeholders in PromQL query\n const intervalMs = step * 1000;\n const minStepMs = minStep * 1000;\n let query = replacePromBuiltinVariables(spec.query, minStepMs, intervalMs);\n query = replaceVariables(query, context.variableState);\n\n let seriesNameFormat = spec.seriesNameFormat;\n // if series name format is defined, replace variable placeholders in series name format\n if (seriesNameFormat) {\n seriesNameFormat = replaceVariables(seriesNameFormat, context.variableState);\n }\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(selectedDatasource);\n\n // Make the request to Prom\n let response;\n switch (context.mode) {\n case 'instant':\n response = await client.instantQuery({\n query,\n time: end,\n });\n break;\n case 'range':\n default:\n response = await client.rangeQuery({\n query,\n start,\n end,\n step,\n });\n break;\n }\n\n // TODO: What about error responses from Prom that have a response body?\n const result = response.data;\n\n // Custom display for response header warnings, configurable error responses display coming next\n const notices: Notice[] = [];\n if (response.status === 'success') {\n const warnings = response.warnings ?? [];\n const warningMessage = warnings[0] ?? '';\n if (warningMessage !== '') {\n notices.push({\n type: 'warning',\n message: warningMessage,\n });\n }\n }\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 series: buildTimeSeries(query, result, seriesNameFormat),\n metadata: {\n notices,\n executedQueryString: query,\n },\n };\n\n return chartData;\n};\n\nfunction buildVectorData(query: string, data: VectorData, seriesNameFormat: string | undefined): TimeSeries[] {\n return data.result.map((res) => {\n const { metric, value, histogram } = res;\n\n // Account for seriesNameFormat from query editor when determining name to show in legend, tooltip, etc.\n const { name, formattedName } = getFormattedPrometheusSeriesName(query, metric, seriesNameFormat);\n\n if (histogram) {\n return {\n name,\n formattedName,\n labels: metric,\n values: [parseValueTuple([histogram[0], histogram[1].sum])],\n histograms: [histogram],\n };\n }\n\n return {\n name,\n formattedName,\n labels: metric,\n values: [parseValueTuple(value)],\n };\n });\n}\n\nfunction buildMatrixData(query: string, data: MatrixData, seriesNameFormat: string | undefined): TimeSeries[] {\n return data.result.map((res) => {\n const { metric, values, histograms } = res;\n\n // Account for seriesNameFormat from query editor when determining name to show in legend, tooltip, etc.\n const { name, formattedName } = getFormattedPrometheusSeriesName(query, metric, seriesNameFormat);\n\n if (histograms) {\n return {\n name,\n formattedName,\n labels: metric,\n values: histograms.map((histogram) => parseValueTuple([histogram[0], histogram[1].sum])),\n histograms: histograms.map((histogram) => histogram),\n };\n }\n\n return {\n name,\n formattedName,\n labels: metric,\n values: values.map(parseValueTuple),\n };\n });\n}\n\nfunction buildScalarData(query: string, data: ScalarData, seriesNameFormat: string | undefined): TimeSeries[] {\n const { name, formattedName } = getFormattedPrometheusSeriesName(query, {}, seriesNameFormat);\n return [\n {\n name,\n values: [parseValueTuple(data.result)],\n formattedName,\n },\n ];\n}\n\nfunction buildTimeSeries(query: string, data?: InstantQueryResultType, seriesNameFormat?: string): TimeSeries[] {\n if (!data) {\n return [];\n }\n\n const resultType = data.resultType;\n switch (resultType) {\n case 'vector':\n return buildVectorData(query, data, seriesNameFormat);\n case 'matrix':\n return buildMatrixData(query, data, seriesNameFormat);\n case 'scalar':\n return buildScalarData(query, data, seriesNameFormat);\n default:\n console.warn('Unknown result type', resultType, data);\n return [];\n }\n}\n"],"names":["parseDurationString","datasourceSelectValueToSelector","replaceVariables","fromUnixTime","milliseconds","parseValueTuple","getDurationStringSeconds","getPrometheusTimeRange","getRangeStep","DEFAULT_PROM","PROM_DATASOURCE_KIND","getFormattedPrometheusSeriesName","DEFAULT_SCRAPE_INTERVAL","replacePromBuiltinVariables","getTimeSeriesData","spec","context","query","undefined","series","listDatasourceSelectItems","datasourceStore","selectedDatasource","datasource","variableState","getDatasource","datasourceScrapeInterval","Math","trunc","plugin","scrapeInterval","minStep","timeRange","step","suggestedStepMs","start","end","utcOffsetSec","Date","getTimezoneOffset","alignedEnd","floor","alignedStart","intervalMs","minStepMs","seriesNameFormat","client","getDatasourceClient","response","mode","instantQuery","time","rangeQuery","result","data","notices","status","warnings","warningMessage","push","type","message","chartData","stepMs","buildTimeSeries","metadata","executedQueryString","buildVectorData","map","res","metric","value","histogram","name","formattedName","labels","values","sum","histograms","buildMatrixData","buildScalarData","resultType","console","warn"],"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,SAIEA,mBAAmB,QAGd,mBAAmB;AAC1B,SAAgCC,+BAA+B,EAAEC,gBAAgB,QAAQ,4BAA4B;AACrH,SAASC,YAAY,EAAEC,YAAY,QAAQ,WAAW;AACtD,SACEC,eAAe,EAEfC,wBAAwB,EACxBC,sBAAsB,EACtBC,YAAY,EACZC,YAAY,EAKZC,oBAAoB,QACf,cAAc;AACrB,SAASC,gCAAgC,QAAQ,cAAc;AAC/D,SAASC,uBAAuB,QAAkC,WAAW;AAE7E,SAASC,2BAA2B,QAAQ,mCAAmC;AAE/E,OAAO,MAAMC,oBAA+F,OAC1GC,MACAC;IAEA,IAAID,KAAKE,KAAK,KAAKC,aAAaH,KAAKE,KAAK,KAAK,QAAQF,KAAKE,KAAK,KAAK,IAAI;QACxE,+EAA+E;QAC/E,OAAO;YAAEE,QAAQ,EAAE;QAAC;IACtB;IAEA,MAAMC,4BAA4B,MAAMJ,QAAQK,eAAe,CAACD,yBAAyB,CAACV;IAE1F,MAAMY,qBACJrB,gCACEc,KAAKQ,UAAU,IAAId,cACnBO,QAAQQ,aAAa,EACrBJ,8BACGX;IAE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AOmC,gBAAgB/D,OAAOqC,MAAMT;QACtC;YACEqC,QAAQC,IAAI,CAAC,uBAAuBF,YAAY3B;YAChD,OAAO,EAAE;IACb;AACF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DurationString } from '@perses-dev/core';
|
|
2
|
+
import { DatasourceSelectValue } from '@perses-dev/plugin-system';
|
|
2
3
|
import { PrometheusDatasourceSelector } from '../../model';
|
|
3
4
|
/**
|
|
4
5
|
* The spec/options for the PrometheusTimeSeriesQuery plugin.
|
|
@@ -8,6 +9,6 @@ export interface PrometheusTimeSeriesQuerySpec {
|
|
|
8
9
|
seriesNameFormat?: string;
|
|
9
10
|
minStep?: DurationString;
|
|
10
11
|
resolution?: number;
|
|
11
|
-
datasource?: PrometheusDatasourceSelector
|
|
12
|
+
datasource?: DatasourceSelectValue<PrometheusDatasourceSelector>;
|
|
12
13
|
}
|
|
13
14
|
//# sourceMappingURL=time-series-query-model.d.ts.map
|
|
@@ -1 +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,MAAM,aAAa,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,4BAA4B,CAAC;
|
|
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,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,qBAAqB,CAAC,4BAA4B,CAAC,CAAC;CAClE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/plugins/prometheus-time-series-query/time-series-query-model.ts"],"sourcesContent":["// Copyright 2023 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 } from '../../model';\n\n/**\n * The spec/options for the PrometheusTimeSeriesQuery plugin.\n */\nexport interface PrometheusTimeSeriesQuerySpec {\n query: string;\n seriesNameFormat?: string;\n minStep?: DurationString;\n resolution?: number;\n datasource?: PrometheusDatasourceSelector
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/prometheus-time-series-query/time-series-query-model.ts"],"sourcesContent":["// Copyright 2023 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 { DatasourceSelectValue } from '@perses-dev/plugin-system';\nimport { PrometheusDatasourceSelector } from '../../model';\n\n/**\n * The spec/options for the PrometheusTimeSeriesQuery plugin.\n */\nexport interface PrometheusTimeSeriesQuerySpec {\n query: string;\n seriesNameFormat?: string;\n minStep?: DurationString;\n resolution?: number;\n datasource?: DatasourceSelectValue<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;AAMjC;;CAEC,GACD,WAMC"}
|