@perses-dev/prometheus-plugin 0.54.0 → 0.56.0

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.
Files changed (96) hide show
  1. package/__mf/css/async/1339.d3010b86.css +1 -0
  2. package/__mf/css/async/1576.d3010b86.css +1 -0
  3. package/__mf/css/async/4576.d3010b86.css +1 -0
  4. package/__mf/js/{Prometheus.7a79b403.js → Prometheus.4d0d5812.js} +3 -3
  5. package/__mf/js/async/1339.194207db.js +1 -0
  6. package/__mf/js/async/212.5fcca998.js +1 -0
  7. package/__mf/js/async/3749.3ecd9372.js +1 -0
  8. package/__mf/js/async/{4075.88e3f633.js → 4075.dab1b7b8.js} +1 -1
  9. package/__mf/js/async/{4238.422a1b1c.js → 4238.c48b1950.js} +1 -1
  10. package/__mf/js/async/4421.1fcb466e.js +1 -0
  11. package/__mf/js/async/4557.f3eb9456.js +2 -0
  12. package/__mf/js/async/4576.f42daf99.js +1 -0
  13. package/__mf/js/async/4676.b7a22f90.js +22 -0
  14. package/__mf/js/async/58.1c9a8daa.js +2 -0
  15. package/__mf/js/async/6341.20eccf91.js +7 -0
  16. package/__mf/js/async/684.4495f632.js +1 -0
  17. package/__mf/js/async/8164.bb3d3363.js +1 -0
  18. package/__mf/js/async/8706.89677575.js +1 -0
  19. package/__mf/js/async/{2675.27451820.js → 9010.bdb2ef97.js} +1 -1
  20. package/__mf/js/async/__federation_expose_PrometheusDatasource.45ee94e2.js +1 -0
  21. package/__mf/js/async/__federation_expose_PrometheusExplorer.b8e555e1.js +1 -0
  22. package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.00dfb1dd.js +1 -0
  23. package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.956ef2d0.js +1 -0
  24. package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.59f2d170.js +1 -0
  25. package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.d7143352.js +1 -0
  26. package/__mf/js/{main.d2018d3d.js → main.afc2ee60.js} +3 -3
  27. package/lib/cjs/explore/PrometheusExplorer.js +7 -2
  28. package/lib/cjs/model/prometheus-client.js +4 -2
  29. package/lib/cjs/plugins/PrometheusLabelNamesVariable.js +8 -2
  30. package/lib/cjs/plugins/PrometheusLabelValuesVariable.js +10 -2
  31. package/lib/cjs/plugins/PrometheusPromQLVariable.js +10 -2
  32. package/lib/cjs/plugins/prometheus-datasource.js +21 -14
  33. package/lib/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +7 -43
  34. package/lib/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +3 -3
  35. package/lib/cjs/plugins/prometheus-variables.js +20 -73
  36. package/lib/explore/PrometheusExplorer.d.ts.map +1 -1
  37. package/lib/explore/PrometheusExplorer.js +7 -2
  38. package/lib/explore/PrometheusExplorer.js.map +1 -1
  39. package/lib/model/prometheus-client.d.ts +8 -7
  40. package/lib/model/prometheus-client.d.ts.map +1 -1
  41. package/lib/model/prometheus-client.js +4 -2
  42. package/lib/model/prometheus-client.js.map +1 -1
  43. package/lib/model/prometheus-selectors.d.ts +2 -2
  44. package/lib/model/prometheus-selectors.d.ts.map +1 -1
  45. package/lib/model/prometheus-selectors.js.map +1 -1
  46. package/lib/plugins/PrometheusLabelNamesVariable.d.ts.map +1 -1
  47. package/lib/plugins/PrometheusLabelNamesVariable.js +10 -4
  48. package/lib/plugins/PrometheusLabelNamesVariable.js.map +1 -1
  49. package/lib/plugins/PrometheusLabelValuesVariable.d.ts.map +1 -1
  50. package/lib/plugins/PrometheusLabelValuesVariable.js +12 -4
  51. package/lib/plugins/PrometheusLabelValuesVariable.js.map +1 -1
  52. package/lib/plugins/PrometheusPromQLVariable.d.ts.map +1 -1
  53. package/lib/plugins/PrometheusPromQLVariable.js +12 -4
  54. package/lib/plugins/PrometheusPromQLVariable.js.map +1 -1
  55. package/lib/plugins/prometheus-datasource.d.ts.map +1 -1
  56. package/lib/plugins/prometheus-datasource.js +21 -14
  57. package/lib/plugins/prometheus-datasource.js.map +1 -1
  58. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
  59. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +7 -43
  60. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -1
  61. package/lib/plugins/prometheus-time-series-query/get-time-series-data.d.ts.map +1 -1
  62. package/lib/plugins/prometheus-time-series-query/get-time-series-data.js +3 -3
  63. package/lib/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -1
  64. package/lib/plugins/prometheus-variables.d.ts.map +1 -1
  65. package/lib/plugins/prometheus-variables.js +22 -81
  66. package/lib/plugins/prometheus-variables.js.map +1 -1
  67. package/lib/plugins/types.d.ts +2 -1
  68. package/lib/plugins/types.d.ts.map +1 -1
  69. package/lib/plugins/types.js.map +1 -1
  70. package/mf-manifest.json +103 -97
  71. package/mf-stats.json +106 -100
  72. package/package.json +6 -6
  73. package/__mf/css/async/1576.dacad691.css +0 -1
  74. package/__mf/css/async/2188.dacad691.css +0 -1
  75. package/__mf/css/async/2341.dacad691.css +0 -1
  76. package/__mf/js/async/212.69f85c2b.js +0 -1
  77. package/__mf/js/async/2188.d2c5eadd.js +0 -1
  78. package/__mf/js/async/2275.95fa6219.js +0 -7
  79. package/__mf/js/async/3391.eced295d.js +0 -73
  80. package/__mf/js/async/4323.fdf7d039.js +0 -1
  81. package/__mf/js/async/4368.38ebfc12.js +0 -2
  82. package/__mf/js/async/4421.b5492f46.js +0 -1
  83. package/__mf/js/async/6714.fd02e782.js +0 -2
  84. package/__mf/js/async/684.f7b5c16e.js +0 -1
  85. package/__mf/js/async/7239.2619666a.js +0 -1
  86. package/__mf/js/async/8706.70f829fc.js +0 -1
  87. package/__mf/js/async/__federation_expose_PrometheusDatasource.8b4b16ca.js +0 -1
  88. package/__mf/js/async/__federation_expose_PrometheusExplorer.8faab52f.js +0 -1
  89. package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.baed70be.js +0 -1
  90. package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.86fed903.js +0 -1
  91. package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.8eb55b7f.js +0 -1
  92. package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.66df70ad.js +0 -1
  93. /package/__mf/js/async/{4368.38ebfc12.js.LICENSE.txt → 4557.f3eb9456.js.LICENSE.txt} +0 -0
  94. /package/__mf/js/async/{3391.eced295d.js.LICENSE.txt → 4676.b7a22f90.js.LICENSE.txt} +0 -0
  95. /package/__mf/js/async/{6714.fd02e782.js.LICENSE.txt → 58.1c9a8daa.js.LICENSE.txt} +0 -0
  96. /package/__mf/js/async/{2275.95fa6219.js.LICENSE.txt → 6341.20eccf91.js.LICENSE.txt} +0 -0
@@ -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';\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
+ {"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(\n datasourceSelectValue: DatasourceSelectValue<PrometheusDatasourceSelector>\n): 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<DatasourceSelector>\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,sBACdC,qBAA0E;IAE1E,OAAO,CAACL,qBAAqBK,0BAA0BA,sBAAsBC,IAAI,KAAKC;AACxF;AAEA;;CAEC,GACD,OAAO,SAASC,+BACdH,qBAAgE;IAEhE,OAAOL,qBAAqBK,0BAA0BA,sBAAsBF,IAAI,KAAKF;AACvF"}
@@ -1 +1 @@
1
- {"version":3,"file":"PrometheusLabelNamesVariable.d.ts","sourceRoot":"","sources":["../../../src/plugins/PrometheusLabelNamesVariable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA+D,MAAM,2BAA2B,CAAC;AAGxH,OAAO,EAAE,mCAAmC,EAAE,MAAM,SAAS,CAAC;AAE9D,eAAO,MAAM,4BAA4B,EAAE,cAAc,CAAC,mCAAmC,CAgB5F,CAAC"}
1
+ {"version":3,"file":"PrometheusLabelNamesVariable.d.ts","sourceRoot":"","sources":["../../../src/plugins/PrometheusLabelNamesVariable.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAMf,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,mCAAmC,EAAE,MAAM,SAAS,CAAC;AAE9D,eAAO,MAAM,4BAA4B,EAAE,cAAc,CAAC,mCAAmC,CAyB5F,CAAC"}
@@ -1,9 +1,10 @@
1
- import { replaceVariables, parseVariables } from '@perses-dev/plugin-system';
2
- import { DEFAULT_PROM, getPrometheusTimeRange } from '../model';
1
+ import { replaceVariables, parseVariables, datasourceSelectValueToSelector, isVariableDatasource } from '@perses-dev/plugin-system';
2
+ import { DEFAULT_PROM, getPrometheusTimeRange, PROM_DATASOURCE_KIND } from '../model';
3
3
  import { stringArrayToVariableOptions, PrometheusLabelNamesVariableEditor } from './prometheus-variables';
4
4
  export const PrometheusLabelNamesVariable = {
5
5
  getVariableOptions: async (spec, ctx)=>{
6
- const client = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);
6
+ const datasourceSelector = datasourceSelectValueToSelector(spec.datasource ?? DEFAULT_PROM, ctx.variables, await ctx.datasourceStore.listDatasourceSelectItems(PROM_DATASOURCE_KIND)) ?? DEFAULT_PROM;
7
+ const client = await ctx.datasourceStore.getDatasourceClient(datasourceSelector);
7
8
  const match = spec.matchers ? spec.matchers.map((m)=>replaceVariables(m, ctx.variables)) : undefined;
8
9
  const timeRange = getPrometheusTimeRange(ctx.timeRange);
9
10
  const { data: options } = await client.labelNames({
@@ -15,8 +16,13 @@ export const PrometheusLabelNamesVariable = {
15
16
  };
16
17
  },
17
18
  dependsOn: (spec)=>{
19
+ const matcherVariables = spec.matchers?.map((m)=>parseVariables(m)).flat() || [];
20
+ const datasourceVariables = spec.datasource && isVariableDatasource(spec.datasource) ? parseVariables(spec.datasource) : [];
18
21
  return {
19
- variables: spec.matchers?.map((m)=>parseVariables(m)).flat() || []
22
+ variables: [
23
+ ...matcherVariables,
24
+ ...datasourceVariables
25
+ ]
20
26
  };
21
27
  },
22
28
  OptionsEditorComponent: PrometheusLabelNamesVariableEditor,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/plugins/PrometheusLabelNamesVariable.tsx"],"sourcesContent":["import { VariablePlugin, GetVariableOptionsContext, replaceVariables, parseVariables } from '@perses-dev/plugin-system';\nimport { PrometheusClient, DEFAULT_PROM, getPrometheusTimeRange } from '../model';\nimport { stringArrayToVariableOptions, PrometheusLabelNamesVariableEditor } from './prometheus-variables';\nimport { PrometheusLabelNamesVariableOptions } from './types';\n\nexport const PrometheusLabelNamesVariable: VariablePlugin<PrometheusLabelNamesVariableOptions> = {\n getVariableOptions: async (spec: PrometheusLabelNamesVariableOptions, ctx: GetVariableOptionsContext) => {\n const client: PrometheusClient = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);\n const match = spec.matchers ? spec.matchers.map((m) => replaceVariables(m, ctx.variables)) : undefined;\n const timeRange = getPrometheusTimeRange(ctx.timeRange);\n\n const { data: options } = await client.labelNames({ 'match[]': match, ...timeRange });\n return {\n data: stringArrayToVariableOptions(options),\n };\n },\n dependsOn: (spec: PrometheusLabelNamesVariableOptions) => {\n return { variables: spec.matchers?.map((m) => parseVariables(m)).flat() || [] };\n },\n OptionsEditorComponent: PrometheusLabelNamesVariableEditor,\n createInitialOptions: () => ({}),\n};\n"],"names":["replaceVariables","parseVariables","DEFAULT_PROM","getPrometheusTimeRange","stringArrayToVariableOptions","PrometheusLabelNamesVariableEditor","PrometheusLabelNamesVariable","getVariableOptions","spec","ctx","client","datasourceStore","getDatasourceClient","datasource","match","matchers","map","m","variables","undefined","timeRange","data","options","labelNames","dependsOn","flat","OptionsEditorComponent","createInitialOptions"],"mappings":"AAAA,SAAoDA,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AACxH,SAA2BC,YAAY,EAAEC,sBAAsB,QAAQ,WAAW;AAClF,SAASC,4BAA4B,EAAEC,kCAAkC,QAAQ,yBAAyB;AAG1G,OAAO,MAAMC,+BAAoF;IAC/FC,oBAAoB,OAAOC,MAA2CC;QACpE,MAAMC,SAA2B,MAAMD,IAAIE,eAAe,CAACC,mBAAmB,CAACJ,KAAKK,UAAU,IAAIX;QAClG,MAAMY,QAAQN,KAAKO,QAAQ,GAAGP,KAAKO,QAAQ,CAACC,GAAG,CAAC,CAACC,IAAMjB,iBAAiBiB,GAAGR,IAAIS,SAAS,KAAKC;QAC7F,MAAMC,YAAYjB,uBAAuBM,IAAIW,SAAS;QAEtD,MAAM,EAAEC,MAAMC,OAAO,EAAE,GAAG,MAAMZ,OAAOa,UAAU,CAAC;YAAE,WAAWT;YAAO,GAAGM,SAAS;QAAC;QACnF,OAAO;YACLC,MAAMjB,6BAA6BkB;QACrC;IACF;IACAE,WAAW,CAAChB;QACV,OAAO;YAAEU,WAAWV,KAAKO,QAAQ,EAAEC,IAAI,CAACC,IAAMhB,eAAegB,IAAIQ,UAAU,EAAE;QAAC;IAChF;IACAC,wBAAwBrB;IACxBsB,sBAAsB,IAAO,CAAA,CAAC,CAAA;AAChC,EAAE"}
1
+ {"version":3,"sources":["../../../src/plugins/PrometheusLabelNamesVariable.tsx"],"sourcesContent":["import {\n VariablePlugin,\n GetVariableOptionsContext,\n replaceVariables,\n parseVariables,\n datasourceSelectValueToSelector,\n isVariableDatasource,\n} from '@perses-dev/plugin-system';\nimport { PrometheusClient, DEFAULT_PROM, getPrometheusTimeRange, PROM_DATASOURCE_KIND } from '../model';\nimport { stringArrayToVariableOptions, PrometheusLabelNamesVariableEditor } from './prometheus-variables';\nimport { PrometheusLabelNamesVariableOptions } from './types';\n\nexport const PrometheusLabelNamesVariable: VariablePlugin<PrometheusLabelNamesVariableOptions> = {\n getVariableOptions: async (spec: PrometheusLabelNamesVariableOptions, ctx: GetVariableOptionsContext) => {\n const datasourceSelector =\n datasourceSelectValueToSelector(\n spec.datasource ?? DEFAULT_PROM,\n ctx.variables,\n await ctx.datasourceStore.listDatasourceSelectItems(PROM_DATASOURCE_KIND)\n ) ?? DEFAULT_PROM;\n const client: PrometheusClient = await ctx.datasourceStore.getDatasourceClient(datasourceSelector);\n const match = spec.matchers ? spec.matchers.map((m) => replaceVariables(m, ctx.variables)) : undefined;\n const timeRange = getPrometheusTimeRange(ctx.timeRange);\n\n const { data: options } = await client.labelNames({ 'match[]': match, ...timeRange });\n return {\n data: stringArrayToVariableOptions(options),\n };\n },\n dependsOn: (spec: PrometheusLabelNamesVariableOptions) => {\n const matcherVariables = spec.matchers?.map((m) => parseVariables(m)).flat() || [];\n const datasourceVariables =\n spec.datasource && isVariableDatasource(spec.datasource) ? parseVariables(spec.datasource) : [];\n return { variables: [...matcherVariables, ...datasourceVariables] };\n },\n OptionsEditorComponent: PrometheusLabelNamesVariableEditor,\n createInitialOptions: () => ({}),\n};\n"],"names":["replaceVariables","parseVariables","datasourceSelectValueToSelector","isVariableDatasource","DEFAULT_PROM","getPrometheusTimeRange","PROM_DATASOURCE_KIND","stringArrayToVariableOptions","PrometheusLabelNamesVariableEditor","PrometheusLabelNamesVariable","getVariableOptions","spec","ctx","datasourceSelector","datasource","variables","datasourceStore","listDatasourceSelectItems","client","getDatasourceClient","match","matchers","map","m","undefined","timeRange","data","options","labelNames","dependsOn","matcherVariables","flat","datasourceVariables","OptionsEditorComponent","createInitialOptions"],"mappings":"AAAA,SAGEA,gBAAgB,EAChBC,cAAc,EACdC,+BAA+B,EAC/BC,oBAAoB,QACf,4BAA4B;AACnC,SAA2BC,YAAY,EAAEC,sBAAsB,EAAEC,oBAAoB,QAAQ,WAAW;AACxG,SAASC,4BAA4B,EAAEC,kCAAkC,QAAQ,yBAAyB;AAG1G,OAAO,MAAMC,+BAAoF;IAC/FC,oBAAoB,OAAOC,MAA2CC;QACpE,MAAMC,qBACJX,gCACES,KAAKG,UAAU,IAAIV,cACnBQ,IAAIG,SAAS,EACb,MAAMH,IAAII,eAAe,CAACC,yBAAyB,CAACX,0BACjDF;QACP,MAAMc,SAA2B,MAAMN,IAAII,eAAe,CAACG,mBAAmB,CAACN;QAC/E,MAAMO,QAAQT,KAAKU,QAAQ,GAAGV,KAAKU,QAAQ,CAACC,GAAG,CAAC,CAACC,IAAMvB,iBAAiBuB,GAAGX,IAAIG,SAAS,KAAKS;QAC7F,MAAMC,YAAYpB,uBAAuBO,IAAIa,SAAS;QAEtD,MAAM,EAAEC,MAAMC,OAAO,EAAE,GAAG,MAAMT,OAAOU,UAAU,CAAC;YAAE,WAAWR;YAAO,GAAGK,SAAS;QAAC;QACnF,OAAO;YACLC,MAAMnB,6BAA6BoB;QACrC;IACF;IACAE,WAAW,CAAClB;QACV,MAAMmB,mBAAmBnB,KAAKU,QAAQ,EAAEC,IAAI,CAACC,IAAMtB,eAAesB,IAAIQ,UAAU,EAAE;QAClF,MAAMC,sBACJrB,KAAKG,UAAU,IAAIX,qBAAqBQ,KAAKG,UAAU,IAAIb,eAAeU,KAAKG,UAAU,IAAI,EAAE;QACjG,OAAO;YAAEC,WAAW;mBAAIe;mBAAqBE;aAAoB;QAAC;IACpE;IACAC,wBAAwBzB;IACxB0B,sBAAsB,IAAO,CAAA,CAAC,CAAA;AAChC,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"PrometheusLabelValuesVariable.d.ts","sourceRoot":"","sources":["../../../src/plugins/PrometheusLabelValuesVariable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA+D,MAAM,2BAA2B,CAAC;AAGxH,OAAO,EAAE,oCAAoC,EAAE,MAAM,SAAS,CAAC;AAE/D,eAAO,MAAM,6BAA6B,EAAE,cAAc,CAAC,oCAAoC,CA4B9F,CAAC"}
1
+ {"version":3,"file":"PrometheusLabelValuesVariable.d.ts","sourceRoot":"","sources":["../../../src/plugins/PrometheusLabelValuesVariable.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAMf,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,oCAAoC,EAAE,MAAM,SAAS,CAAC;AAE/D,eAAO,MAAM,6BAA6B,EAAE,cAAc,CAAC,oCAAoC,CAkC9F,CAAC"}
@@ -1,10 +1,11 @@
1
- import { replaceVariables, parseVariables } from '@perses-dev/plugin-system';
2
- import { DEFAULT_PROM, getPrometheusTimeRange } from '../model';
1
+ import { replaceVariables, parseVariables, datasourceSelectValueToSelector, isVariableDatasource } from '@perses-dev/plugin-system';
2
+ import { DEFAULT_PROM, getPrometheusTimeRange, PROM_DATASOURCE_KIND } from '../model';
3
3
  import { stringArrayToVariableOptions, PrometheusLabelValuesVariableEditor } from './prometheus-variables';
4
4
  export const PrometheusLabelValuesVariable = {
5
5
  getVariableOptions: async (spec, ctx)=>{
6
6
  const pluginDef = spec;
7
- const client = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);
7
+ const datasourceSelector = datasourceSelectValueToSelector(spec.datasource ?? DEFAULT_PROM, ctx.variables, await ctx.datasourceStore.listDatasourceSelectItems(PROM_DATASOURCE_KIND)) ?? DEFAULT_PROM;
8
+ const client = await ctx.datasourceStore.getDatasourceClient(datasourceSelector);
8
9
  const match = pluginDef.matchers ? pluginDef.matchers.map((m)=>replaceVariables(m, ctx.variables)) : undefined;
9
10
  const timeRange = getPrometheusTimeRange(ctx.timeRange);
10
11
  const { data: options } = await client.labelValues({
@@ -17,8 +18,15 @@ export const PrometheusLabelValuesVariable = {
17
18
  };
18
19
  },
19
20
  dependsOn: (spec)=>{
21
+ const matcherVariables = spec.matchers?.map((m)=>parseVariables(m)).flat() || [];
22
+ const labelVariables = parseVariables(spec.labelName);
23
+ const datasourceVariables = spec.datasource && isVariableDatasource(spec.datasource) ? parseVariables(spec.datasource) : [];
20
24
  return {
21
- variables: spec.matchers?.map((m)=>parseVariables(m)).flat().concat(parseVariables(spec.labelName)) || []
25
+ variables: [
26
+ ...matcherVariables,
27
+ ...labelVariables,
28
+ ...datasourceVariables
29
+ ]
22
30
  };
23
31
  },
24
32
  OptionsEditorComponent: PrometheusLabelValuesVariableEditor,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/plugins/PrometheusLabelValuesVariable.tsx"],"sourcesContent":["import { VariablePlugin, GetVariableOptionsContext, replaceVariables, parseVariables } from '@perses-dev/plugin-system';\nimport { PrometheusClient, DEFAULT_PROM, getPrometheusTimeRange } from '../model';\nimport { stringArrayToVariableOptions, PrometheusLabelValuesVariableEditor } from './prometheus-variables';\nimport { PrometheusLabelValuesVariableOptions } from './types';\n\nexport const PrometheusLabelValuesVariable: VariablePlugin<PrometheusLabelValuesVariableOptions> = {\n getVariableOptions: async (spec: PrometheusLabelValuesVariableOptions, ctx: GetVariableOptionsContext) => {\n const pluginDef = spec;\n const client: PrometheusClient = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);\n const match = pluginDef.matchers ? pluginDef.matchers.map((m) => replaceVariables(m, ctx.variables)) : undefined;\n\n const timeRange = getPrometheusTimeRange(ctx.timeRange);\n\n const { data: options } = await client.labelValues({\n labelName: replaceVariables(pluginDef.labelName, ctx.variables),\n 'match[]': match,\n ...timeRange,\n });\n return {\n data: stringArrayToVariableOptions(options),\n };\n },\n dependsOn: (spec: PrometheusLabelValuesVariableOptions) => {\n return {\n variables:\n spec.matchers\n ?.map((m) => parseVariables(m))\n .flat()\n .concat(parseVariables(spec.labelName)) || [],\n };\n },\n OptionsEditorComponent: PrometheusLabelValuesVariableEditor,\n createInitialOptions: () => ({ labelName: '' }),\n};\n"],"names":["replaceVariables","parseVariables","DEFAULT_PROM","getPrometheusTimeRange","stringArrayToVariableOptions","PrometheusLabelValuesVariableEditor","PrometheusLabelValuesVariable","getVariableOptions","spec","ctx","pluginDef","client","datasourceStore","getDatasourceClient","datasource","match","matchers","map","m","variables","undefined","timeRange","data","options","labelValues","labelName","dependsOn","flat","concat","OptionsEditorComponent","createInitialOptions"],"mappings":"AAAA,SAAoDA,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AACxH,SAA2BC,YAAY,EAAEC,sBAAsB,QAAQ,WAAW;AAClF,SAASC,4BAA4B,EAAEC,mCAAmC,QAAQ,yBAAyB;AAG3G,OAAO,MAAMC,gCAAsF;IACjGC,oBAAoB,OAAOC,MAA4CC;QACrE,MAAMC,YAAYF;QAClB,MAAMG,SAA2B,MAAMF,IAAIG,eAAe,CAACC,mBAAmB,CAACL,KAAKM,UAAU,IAAIZ;QAClG,MAAMa,QAAQL,UAAUM,QAAQ,GAAGN,UAAUM,QAAQ,CAACC,GAAG,CAAC,CAACC,IAAMlB,iBAAiBkB,GAAGT,IAAIU,SAAS,KAAKC;QAEvG,MAAMC,YAAYlB,uBAAuBM,IAAIY,SAAS;QAEtD,MAAM,EAAEC,MAAMC,OAAO,EAAE,GAAG,MAAMZ,OAAOa,WAAW,CAAC;YACjDC,WAAWzB,iBAAiBU,UAAUe,SAAS,EAAEhB,IAAIU,SAAS;YAC9D,WAAWJ;YACX,GAAGM,SAAS;QACd;QACA,OAAO;YACLC,MAAMlB,6BAA6BmB;QACrC;IACF;IACAG,WAAW,CAAClB;QACV,OAAO;YACLW,WACEX,KAAKQ,QAAQ,EACTC,IAAI,CAACC,IAAMjB,eAAeiB,IAC3BS,OACAC,OAAO3B,eAAeO,KAAKiB,SAAS,MAAM,EAAE;QACnD;IACF;IACAI,wBAAwBxB;IACxByB,sBAAsB,IAAO,CAAA;YAAEL,WAAW;QAAG,CAAA;AAC/C,EAAE"}
1
+ {"version":3,"sources":["../../../src/plugins/PrometheusLabelValuesVariable.tsx"],"sourcesContent":["import {\n VariablePlugin,\n GetVariableOptionsContext,\n replaceVariables,\n parseVariables,\n datasourceSelectValueToSelector,\n isVariableDatasource,\n} from '@perses-dev/plugin-system';\nimport { PrometheusClient, DEFAULT_PROM, getPrometheusTimeRange, PROM_DATASOURCE_KIND } from '../model';\nimport { stringArrayToVariableOptions, PrometheusLabelValuesVariableEditor } from './prometheus-variables';\nimport { PrometheusLabelValuesVariableOptions } from './types';\n\nexport const PrometheusLabelValuesVariable: VariablePlugin<PrometheusLabelValuesVariableOptions> = {\n getVariableOptions: async (spec: PrometheusLabelValuesVariableOptions, ctx: GetVariableOptionsContext) => {\n const pluginDef = spec;\n const datasourceSelector =\n datasourceSelectValueToSelector(\n spec.datasource ?? DEFAULT_PROM,\n ctx.variables,\n await ctx.datasourceStore.listDatasourceSelectItems(PROM_DATASOURCE_KIND)\n ) ?? DEFAULT_PROM;\n const client: PrometheusClient = await ctx.datasourceStore.getDatasourceClient(datasourceSelector);\n const match = pluginDef.matchers ? pluginDef.matchers.map((m) => replaceVariables(m, ctx.variables)) : undefined;\n\n const timeRange = getPrometheusTimeRange(ctx.timeRange);\n\n const { data: options } = await client.labelValues({\n labelName: replaceVariables(pluginDef.labelName, ctx.variables),\n 'match[]': match,\n ...timeRange,\n });\n return {\n data: stringArrayToVariableOptions(options),\n };\n },\n dependsOn: (spec: PrometheusLabelValuesVariableOptions) => {\n const matcherVariables = spec.matchers?.map((m) => parseVariables(m)).flat() || [];\n const labelVariables = parseVariables(spec.labelName);\n const datasourceVariables =\n spec.datasource && isVariableDatasource(spec.datasource) ? parseVariables(spec.datasource) : [];\n return {\n variables: [...matcherVariables, ...labelVariables, ...datasourceVariables],\n };\n },\n OptionsEditorComponent: PrometheusLabelValuesVariableEditor,\n createInitialOptions: () => ({ labelName: '' }),\n};\n"],"names":["replaceVariables","parseVariables","datasourceSelectValueToSelector","isVariableDatasource","DEFAULT_PROM","getPrometheusTimeRange","PROM_DATASOURCE_KIND","stringArrayToVariableOptions","PrometheusLabelValuesVariableEditor","PrometheusLabelValuesVariable","getVariableOptions","spec","ctx","pluginDef","datasourceSelector","datasource","variables","datasourceStore","listDatasourceSelectItems","client","getDatasourceClient","match","matchers","map","m","undefined","timeRange","data","options","labelValues","labelName","dependsOn","matcherVariables","flat","labelVariables","datasourceVariables","OptionsEditorComponent","createInitialOptions"],"mappings":"AAAA,SAGEA,gBAAgB,EAChBC,cAAc,EACdC,+BAA+B,EAC/BC,oBAAoB,QACf,4BAA4B;AACnC,SAA2BC,YAAY,EAAEC,sBAAsB,EAAEC,oBAAoB,QAAQ,WAAW;AACxG,SAASC,4BAA4B,EAAEC,mCAAmC,QAAQ,yBAAyB;AAG3G,OAAO,MAAMC,gCAAsF;IACjGC,oBAAoB,OAAOC,MAA4CC;QACrE,MAAMC,YAAYF;QAClB,MAAMG,qBACJZ,gCACES,KAAKI,UAAU,IAAIX,cACnBQ,IAAII,SAAS,EACb,MAAMJ,IAAIK,eAAe,CAACC,yBAAyB,CAACZ,0BACjDF;QACP,MAAMe,SAA2B,MAAMP,IAAIK,eAAe,CAACG,mBAAmB,CAACN;QAC/E,MAAMO,QAAQR,UAAUS,QAAQ,GAAGT,UAAUS,QAAQ,CAACC,GAAG,CAAC,CAACC,IAAMxB,iBAAiBwB,GAAGZ,IAAII,SAAS,KAAKS;QAEvG,MAAMC,YAAYrB,uBAAuBO,IAAIc,SAAS;QAEtD,MAAM,EAAEC,MAAMC,OAAO,EAAE,GAAG,MAAMT,OAAOU,WAAW,CAAC;YACjDC,WAAW9B,iBAAiBa,UAAUiB,SAAS,EAAElB,IAAII,SAAS;YAC9D,WAAWK;YACX,GAAGK,SAAS;QACd;QACA,OAAO;YACLC,MAAMpB,6BAA6BqB;QACrC;IACF;IACAG,WAAW,CAACpB;QACV,MAAMqB,mBAAmBrB,KAAKW,QAAQ,EAAEC,IAAI,CAACC,IAAMvB,eAAeuB,IAAIS,UAAU,EAAE;QAClF,MAAMC,iBAAiBjC,eAAeU,KAAKmB,SAAS;QACpD,MAAMK,sBACJxB,KAAKI,UAAU,IAAIZ,qBAAqBQ,KAAKI,UAAU,IAAId,eAAeU,KAAKI,UAAU,IAAI,EAAE;QACjG,OAAO;YACLC,WAAW;mBAAIgB;mBAAqBE;mBAAmBC;aAAoB;QAC7E;IACF;IACAC,wBAAwB5B;IACxB6B,sBAAsB,IAAO,CAAA;YAAEP,WAAW;QAAG,CAAA;AAC/C,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"PrometheusPromQLVariable.d.ts","sourceRoot":"","sources":["../../../src/plugins/PrometheusPromQLVariable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA+D,MAAM,2BAA2B,CAAC;AAQxH,OAAO,EAAE,+BAA+B,EAAE,MAAM,SAAS,CAAC;AAE1D,eAAO,MAAM,wBAAwB,EAAE,cAAc,CAAC,+BAA+B,CAwBpF,CAAC"}
1
+ {"version":3,"file":"PrometheusPromQLVariable.d.ts","sourceRoot":"","sources":["../../../src/plugins/PrometheusPromQLVariable.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAMf,MAAM,2BAA2B,CAAC;AAQnC,OAAO,EAAE,+BAA+B,EAAE,MAAM,SAAS,CAAC;AAE1D,eAAO,MAAM,wBAAwB,EAAE,cAAc,CAAC,+BAA+B,CAkCpF,CAAC"}
@@ -1,9 +1,10 @@
1
- import { replaceVariables, parseVariables } from '@perses-dev/plugin-system';
2
- import { DEFAULT_PROM } from '../model';
1
+ import { replaceVariables, parseVariables, datasourceSelectValueToSelector, isVariableDatasource } from '@perses-dev/plugin-system';
2
+ import { DEFAULT_PROM, PROM_DATASOURCE_KIND } from '../model';
3
3
  import { capturingMatrix, capturingVector, stringArrayToVariableOptions, PrometheusPromQLVariableEditor } from './prometheus-variables';
4
4
  export const PrometheusPromQLVariable = {
5
5
  getVariableOptions: async (spec, ctx)=>{
6
- const client = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);
6
+ const datasourceSelector = datasourceSelectValueToSelector(spec.datasource ?? DEFAULT_PROM, ctx.variables, await ctx.datasourceStore.listDatasourceSelectItems(PROM_DATASOURCE_KIND)) ?? DEFAULT_PROM;
7
+ const client = await ctx.datasourceStore.getDatasourceClient(datasourceSelector);
7
8
  // TODO we may want to manage a range query as well.
8
9
  const { data: options } = await client.instantQuery({
9
10
  query: replaceVariables(spec.expr, ctx.variables)
@@ -20,8 +21,15 @@ export const PrometheusPromQLVariable = {
20
21
  };
21
22
  },
22
23
  dependsOn: (spec)=>{
24
+ const exprVariables = parseVariables(spec.expr);
25
+ const labelVariables = parseVariables(spec.labelName);
26
+ const datasourceVariables = spec.datasource && isVariableDatasource(spec.datasource) ? parseVariables(spec.datasource) : [];
23
27
  return {
24
- variables: parseVariables(spec.expr).concat(parseVariables(spec.labelName))
28
+ variables: [
29
+ ...exprVariables,
30
+ ...labelVariables,
31
+ ...datasourceVariables
32
+ ]
25
33
  };
26
34
  },
27
35
  OptionsEditorComponent: PrometheusPromQLVariableEditor,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/plugins/PrometheusPromQLVariable.tsx"],"sourcesContent":["import { VariablePlugin, GetVariableOptionsContext, replaceVariables, parseVariables } from '@perses-dev/plugin-system';\nimport { PrometheusClient, DEFAULT_PROM } from '../model';\nimport {\n capturingMatrix,\n capturingVector,\n stringArrayToVariableOptions,\n PrometheusPromQLVariableEditor,\n} from './prometheus-variables';\nimport { PrometheusPromQLVariableOptions } from './types';\n\nexport const PrometheusPromQLVariable: VariablePlugin<PrometheusPromQLVariableOptions> = {\n getVariableOptions: async (spec: PrometheusPromQLVariableOptions, ctx: GetVariableOptionsContext) => {\n const client: PrometheusClient = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);\n // TODO we may want to manage a range query as well.\n const { data: options } = await client.instantQuery({\n query: replaceVariables(spec.expr, ctx.variables),\n });\n const labelName = replaceVariables(spec.labelName, ctx.variables);\n let values: string[] = [];\n if (options?.resultType === 'matrix') {\n values = capturingMatrix(options, labelName);\n } else if (options?.resultType === 'vector') {\n values = capturingVector(options, labelName);\n }\n\n return {\n data: stringArrayToVariableOptions(values),\n };\n },\n dependsOn: (spec: PrometheusPromQLVariableOptions) => {\n return { variables: parseVariables(spec.expr).concat(parseVariables(spec.labelName)) };\n },\n OptionsEditorComponent: PrometheusPromQLVariableEditor,\n createInitialOptions: () => ({ expr: '', labelName: '' }),\n};\n"],"names":["replaceVariables","parseVariables","DEFAULT_PROM","capturingMatrix","capturingVector","stringArrayToVariableOptions","PrometheusPromQLVariableEditor","PrometheusPromQLVariable","getVariableOptions","spec","ctx","client","datasourceStore","getDatasourceClient","datasource","data","options","instantQuery","query","expr","variables","labelName","values","resultType","dependsOn","concat","OptionsEditorComponent","createInitialOptions"],"mappings":"AAAA,SAAoDA,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AACxH,SAA2BC,YAAY,QAAQ,WAAW;AAC1D,SACEC,eAAe,EACfC,eAAe,EACfC,4BAA4B,EAC5BC,8BAA8B,QACzB,yBAAyB;AAGhC,OAAO,MAAMC,2BAA4E;IACvFC,oBAAoB,OAAOC,MAAuCC;QAChE,MAAMC,SAA2B,MAAMD,IAAIE,eAAe,CAACC,mBAAmB,CAACJ,KAAKK,UAAU,IAAIZ;QAClG,oDAAoD;QACpD,MAAM,EAAEa,MAAMC,OAAO,EAAE,GAAG,MAAML,OAAOM,YAAY,CAAC;YAClDC,OAAOlB,iBAAiBS,KAAKU,IAAI,EAAET,IAAIU,SAAS;QAClD;QACA,MAAMC,YAAYrB,iBAAiBS,KAAKY,SAAS,EAAEX,IAAIU,SAAS;QAChE,IAAIE,SAAmB,EAAE;QACzB,IAAIN,SAASO,eAAe,UAAU;YACpCD,SAASnB,gBAAgBa,SAASK;QACpC,OAAO,IAAIL,SAASO,eAAe,UAAU;YAC3CD,SAASlB,gBAAgBY,SAASK;QACpC;QAEA,OAAO;YACLN,MAAMV,6BAA6BiB;QACrC;IACF;IACAE,WAAW,CAACf;QACV,OAAO;YAAEW,WAAWnB,eAAeQ,KAAKU,IAAI,EAAEM,MAAM,CAACxB,eAAeQ,KAAKY,SAAS;QAAG;IACvF;IACAK,wBAAwBpB;IACxBqB,sBAAsB,IAAO,CAAA;YAAER,MAAM;YAAIE,WAAW;QAAG,CAAA;AACzD,EAAE"}
1
+ {"version":3,"sources":["../../../src/plugins/PrometheusPromQLVariable.tsx"],"sourcesContent":["import {\n VariablePlugin,\n GetVariableOptionsContext,\n replaceVariables,\n parseVariables,\n datasourceSelectValueToSelector,\n isVariableDatasource,\n} from '@perses-dev/plugin-system';\nimport { PrometheusClient, DEFAULT_PROM, PROM_DATASOURCE_KIND } from '../model';\nimport {\n capturingMatrix,\n capturingVector,\n stringArrayToVariableOptions,\n PrometheusPromQLVariableEditor,\n} from './prometheus-variables';\nimport { PrometheusPromQLVariableOptions } from './types';\n\nexport const PrometheusPromQLVariable: VariablePlugin<PrometheusPromQLVariableOptions> = {\n getVariableOptions: async (spec: PrometheusPromQLVariableOptions, ctx: GetVariableOptionsContext) => {\n const datasourceSelector =\n datasourceSelectValueToSelector(\n spec.datasource ?? DEFAULT_PROM,\n ctx.variables,\n await ctx.datasourceStore.listDatasourceSelectItems(PROM_DATASOURCE_KIND)\n ) ?? DEFAULT_PROM;\n const client: PrometheusClient = await ctx.datasourceStore.getDatasourceClient(datasourceSelector);\n // TODO we may want to manage a range query as well.\n const { data: options } = await client.instantQuery({\n query: replaceVariables(spec.expr, ctx.variables),\n });\n const labelName = replaceVariables(spec.labelName, ctx.variables);\n let values: string[] = [];\n if (options?.resultType === 'matrix') {\n values = capturingMatrix(options, labelName);\n } else if (options?.resultType === 'vector') {\n values = capturingVector(options, labelName);\n }\n\n return {\n data: stringArrayToVariableOptions(values),\n };\n },\n dependsOn: (spec: PrometheusPromQLVariableOptions) => {\n const exprVariables = parseVariables(spec.expr);\n const labelVariables = parseVariables(spec.labelName);\n const datasourceVariables =\n spec.datasource && isVariableDatasource(spec.datasource) ? parseVariables(spec.datasource) : [];\n return { variables: [...exprVariables, ...labelVariables, ...datasourceVariables] };\n },\n OptionsEditorComponent: PrometheusPromQLVariableEditor,\n createInitialOptions: () => ({ expr: '', labelName: '' }),\n};\n"],"names":["replaceVariables","parseVariables","datasourceSelectValueToSelector","isVariableDatasource","DEFAULT_PROM","PROM_DATASOURCE_KIND","capturingMatrix","capturingVector","stringArrayToVariableOptions","PrometheusPromQLVariableEditor","PrometheusPromQLVariable","getVariableOptions","spec","ctx","datasourceSelector","datasource","variables","datasourceStore","listDatasourceSelectItems","client","getDatasourceClient","data","options","instantQuery","query","expr","labelName","values","resultType","dependsOn","exprVariables","labelVariables","datasourceVariables","OptionsEditorComponent","createInitialOptions"],"mappings":"AAAA,SAGEA,gBAAgB,EAChBC,cAAc,EACdC,+BAA+B,EAC/BC,oBAAoB,QACf,4BAA4B;AACnC,SAA2BC,YAAY,EAAEC,oBAAoB,QAAQ,WAAW;AAChF,SACEC,eAAe,EACfC,eAAe,EACfC,4BAA4B,EAC5BC,8BAA8B,QACzB,yBAAyB;AAGhC,OAAO,MAAMC,2BAA4E;IACvFC,oBAAoB,OAAOC,MAAuCC;QAChE,MAAMC,qBACJZ,gCACEU,KAAKG,UAAU,IAAIX,cACnBS,IAAIG,SAAS,EACb,MAAMH,IAAII,eAAe,CAACC,yBAAyB,CAACb,0BACjDD;QACP,MAAMe,SAA2B,MAAMN,IAAII,eAAe,CAACG,mBAAmB,CAACN;QAC/E,oDAAoD;QACpD,MAAM,EAAEO,MAAMC,OAAO,EAAE,GAAG,MAAMH,OAAOI,YAAY,CAAC;YAClDC,OAAOxB,iBAAiBY,KAAKa,IAAI,EAAEZ,IAAIG,SAAS;QAClD;QACA,MAAMU,YAAY1B,iBAAiBY,KAAKc,SAAS,EAAEb,IAAIG,SAAS;QAChE,IAAIW,SAAmB,EAAE;QACzB,IAAIL,SAASM,eAAe,UAAU;YACpCD,SAASrB,gBAAgBgB,SAASI;QACpC,OAAO,IAAIJ,SAASM,eAAe,UAAU;YAC3CD,SAASpB,gBAAgBe,SAASI;QACpC;QAEA,OAAO;YACLL,MAAMb,6BAA6BmB;QACrC;IACF;IACAE,WAAW,CAACjB;QACV,MAAMkB,gBAAgB7B,eAAeW,KAAKa,IAAI;QAC9C,MAAMM,iBAAiB9B,eAAeW,KAAKc,SAAS;QACpD,MAAMM,sBACJpB,KAAKG,UAAU,IAAIZ,qBAAqBS,KAAKG,UAAU,IAAId,eAAeW,KAAKG,UAAU,IAAI,EAAE;QACjG,OAAO;YAAEC,WAAW;mBAAIc;mBAAkBC;mBAAmBC;aAAoB;QAAC;IACpF;IACAC,wBAAwBxB;IACxByB,sBAAsB,IAAO,CAAA;YAAET,MAAM;YAAIC,WAAW;QAAG,CAAA;AACzD,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"prometheus-datasource.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-datasource.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAML,gBAAgB,EAIjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAgFnD,eAAO,MAAM,oBAAoB,EAAE,gBAAgB,CAAC,wBAAwB,EAAE,gBAAgB,CAK7F,CAAC"}
1
+ {"version":3,"file":"prometheus-datasource.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-datasource.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAML,gBAAgB,EAIjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAuFnD,eAAO,MAAM,oBAAoB,EAAE,gBAAgB,CAAC,wBAAwB,EAAE,gBAAgB,CAK7F,CAAC"}
@@ -32,33 +32,40 @@ import { PrometheusDatasourceEditor } from './PrometheusDatasourceEditor';
32
32
  datasourceUrl,
33
33
  headers: specHeaders
34
34
  }),
35
- instantQuery: (params, headers)=>instantQuery(params, {
35
+ instantQuery: (params, headers, abortSignal)=>instantQuery(params, {
36
36
  datasourceUrl,
37
- headers: headers ?? specHeaders
37
+ headers: headers ?? specHeaders,
38
+ abortSignal
38
39
  }),
39
- rangeQuery: (params, headers)=>rangeQuery(params, {
40
+ rangeQuery: (params, headers, abortSignal)=>rangeQuery(params, {
40
41
  datasourceUrl,
41
- headers: headers ?? specHeaders
42
+ headers: headers ?? specHeaders,
43
+ abortSignal
42
44
  }),
43
- labelNames: (params, headers)=>labelNames(params, {
45
+ labelNames: (params, headers, abortSignal)=>labelNames(params, {
44
46
  datasourceUrl,
45
- headers: headers ?? specHeaders
47
+ headers: headers ?? specHeaders,
48
+ abortSignal
46
49
  }),
47
- labelValues: (params, headers)=>labelValues(params, {
50
+ labelValues: (params, headers, abortSignal)=>labelValues(params, {
48
51
  datasourceUrl,
49
- headers: headers ?? specHeaders
52
+ headers: headers ?? specHeaders,
53
+ abortSignal
50
54
  }),
51
- metricMetadata: (params, headers)=>metricMetadata(params, {
55
+ metricMetadata: (params, headers, abortSignal)=>metricMetadata(params, {
52
56
  datasourceUrl,
53
- headers: headers ?? specHeaders
57
+ headers: headers ?? specHeaders,
58
+ abortSignal
54
59
  }),
55
- series: (params, headers)=>series(params, {
60
+ series: (params, headers, abortSignal)=>series(params, {
56
61
  datasourceUrl,
57
- headers: headers ?? specHeaders
62
+ headers: headers ?? specHeaders,
63
+ abortSignal
58
64
  }),
59
- parseQuery: (params, headers)=>parseQuery(params, {
65
+ parseQuery: (params, headers, abortSignal)=>parseQuery(params, {
60
66
  datasourceUrl,
61
- headers: headers ?? specHeaders
67
+ headers: headers ?? specHeaders,
68
+ abortSignal
62
69
  })
63
70
  };
64
71
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/plugins/prometheus-datasource.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 { BuiltinVariableDefinition } from '@perses-dev/core';\nimport { DatasourcePlugin } from '@perses-dev/plugin-system';\nimport {\n healthCheck,\n instantQuery,\n rangeQuery,\n labelNames,\n labelValues,\n PrometheusClient,\n metricMetadata,\n series,\n parseQuery,\n} from '../model';\nimport { PrometheusDatasourceSpec } from './types';\nimport { PrometheusDatasourceEditor } from './PrometheusDatasourceEditor';\n\n/**\n * Creates a PrometheusClient for a specific datasource spec.\n */\nconst createClient: DatasourcePlugin<PrometheusDatasourceSpec, PrometheusClient>['createClient'] = (spec, options) => {\n const { directUrl, proxy } = 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 = directUrl ?? proxyUrl;\n if (datasourceUrl === undefined) {\n throw new Error('No URL specified for Prometheus client. You can use directUrl in the spec to configure it.');\n }\n\n const specHeaders = proxy?.spec.headers;\n\n // Could think about this becoming a class, although it definitely doesn't have to be\n return {\n options: {\n datasourceUrl,\n },\n healthCheck: healthCheck({ datasourceUrl, headers: specHeaders }),\n instantQuery: (params, headers) => instantQuery(params, { datasourceUrl, headers: headers ?? specHeaders }),\n rangeQuery: (params, headers) => rangeQuery(params, { datasourceUrl, headers: headers ?? specHeaders }),\n labelNames: (params, headers) => labelNames(params, { datasourceUrl, headers: headers ?? specHeaders }),\n labelValues: (params, headers) => labelValues(params, { datasourceUrl, headers: headers ?? specHeaders }),\n metricMetadata: (params, headers) => metricMetadata(params, { datasourceUrl, headers: headers ?? specHeaders }),\n series: (params, headers) => series(params, { datasourceUrl, headers: headers ?? specHeaders }),\n parseQuery: (params, headers) => parseQuery(params, { datasourceUrl, headers: headers ?? specHeaders }),\n };\n};\n\nconst getBuiltinVariableDefinitions: () => BuiltinVariableDefinition[] = () => {\n return [\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__interval',\n value: () => '$__interval', // will be overriden when time series query is called\n source: 'Prometheus',\n display: {\n name: '__interval',\n description:\n 'For dynamic queries that adapt across different time ranges, use $__interval instead of hardcoded intervals. It represents the actual spacing between data points: it’s calculated based on the current time range and the panel pixel width (taking the \"Min step\" as a lower bound).',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__interval_ms',\n value: () => '$__interval_ms', // will be overriden when time series query is called\n source: 'Prometheus',\n display: {\n name: '__interval_ms',\n description: 'Same as $__interval but in milliseconds.',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__rate_interval',\n value: () => '$__rate_interval', // will be overriden when time series query is called\n source: 'Prometheus',\n display: {\n name: '__rate_interval',\n description:\n 'Use this one rather than $__interval as the range parameter of functions like rate, increase, etc. With such function it is advised to choose a range that is at least 4x the scrape interval (this is to allow for various races, and to be resilient to a failed scrape). $__rate_interval provides that, as it is defined as `max($__interval + Min Step, 4 * Min Step)`, where Min Step value should represent the scrape interval of the metrics.',\n hidden: true,\n },\n },\n },\n ] as BuiltinVariableDefinition[];\n};\n\nexport const PrometheusDatasource: DatasourcePlugin<PrometheusDatasourceSpec, PrometheusClient> = {\n createClient,\n getBuiltinVariableDefinitions,\n OptionsEditorComponent: PrometheusDatasourceEditor,\n createInitialOptions: () => ({ directUrl: '' }),\n};\n"],"names":["healthCheck","instantQuery","rangeQuery","labelNames","labelValues","metricMetadata","series","parseQuery","PrometheusDatasourceEditor","createClient","spec","options","directUrl","proxy","proxyUrl","datasourceUrl","undefined","Error","specHeaders","headers","params","getBuiltinVariableDefinitions","kind","name","value","source","display","description","hidden","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;AAIjC,SACEA,WAAW,EACXC,YAAY,EACZC,UAAU,EACVC,UAAU,EACVC,WAAW,EAEXC,cAAc,EACdC,MAAM,EACNC,UAAU,QACL,WAAW;AAElB,SAASC,0BAA0B,QAAQ,+BAA+B;AAE1E;;CAEC,GACD,MAAMC,eAA6F,CAACC,MAAMC;IACxG,MAAM,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAGH;IAC7B,MAAM,EAAEI,QAAQ,EAAE,GAAGH;IAErB,4FAA4F;IAC5F,MAAMI,gBAAgBH,aAAaE;IACnC,IAAIC,kBAAkBC,WAAW;QAC/B,MAAM,IAAIC,MAAM;IAClB;IAEA,MAAMC,cAAcL,OAAOH,KAAKS;IAEhC,qFAAqF;IACrF,OAAO;QACLR,SAAS;YACPI;QACF;QACAf,aAAaA,YAAY;YAAEe;YAAeI,SAASD;QAAY;QAC/DjB,cAAc,CAACmB,QAAQD,UAAYlB,aAAamB,QAAQ;gBAAEL;gBAAeI,SAASA,WAAWD;YAAY;QACzGhB,YAAY,CAACkB,QAAQD,UAAYjB,WAAWkB,QAAQ;gBAAEL;gBAAeI,SAASA,WAAWD;YAAY;QACrGf,YAAY,CAACiB,QAAQD,UAAYhB,WAAWiB,QAAQ;gBAAEL;gBAAeI,SAASA,WAAWD;YAAY;QACrGd,aAAa,CAACgB,QAAQD,UAAYf,YAAYgB,QAAQ;gBAAEL;gBAAeI,SAASA,WAAWD;YAAY;QACvGb,gBAAgB,CAACe,QAAQD,UAAYd,eAAee,QAAQ;gBAAEL;gBAAeI,SAASA,WAAWD;YAAY;QAC7GZ,QAAQ,CAACc,QAAQD,UAAYb,OAAOc,QAAQ;gBAAEL;gBAAeI,SAASA,WAAWD;YAAY;QAC7FX,YAAY,CAACa,QAAQD,UAAYZ,WAAWa,QAAQ;gBAAEL;gBAAeI,SAASA,WAAWD;YAAY;IACvG;AACF;AAEA,MAAMG,gCAAmE;IACvE,OAAO;QACL;YACEC,MAAM;YACNZ,MAAM;gBACJa,MAAM;gBACNC,OAAO,IAAM;gBACbC,QAAQ;gBACRC,SAAS;oBACPH,MAAM;oBACNI,aACE;oBACFC,QAAQ;gBACV;YACF;QACF;QACA;YACEN,MAAM;YACNZ,MAAM;gBACJa,MAAM;gBACNC,OAAO,IAAM;gBACbC,QAAQ;gBACRC,SAAS;oBACPH,MAAM;oBACNI,aAAa;oBACbC,QAAQ;gBACV;YACF;QACF;QACA;YACEN,MAAM;YACNZ,MAAM;gBACJa,MAAM;gBACNC,OAAO,IAAM;gBACbC,QAAQ;gBACRC,SAAS;oBACPH,MAAM;oBACNI,aACE;oBACFC,QAAQ;gBACV;YACF;QACF;KACD;AACH;AAEA,OAAO,MAAMC,uBAAqF;IAChGpB;IACAY;IACAS,wBAAwBtB;IACxBuB,sBAAsB,IAAO,CAAA;YAAEnB,WAAW;QAAG,CAAA;AAC/C,EAAE"}
1
+ {"version":3,"sources":["../../../src/plugins/prometheus-datasource.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 { BuiltinVariableDefinition } from '@perses-dev/core';\nimport { DatasourcePlugin } from '@perses-dev/plugin-system';\nimport {\n healthCheck,\n instantQuery,\n rangeQuery,\n labelNames,\n labelValues,\n PrometheusClient,\n metricMetadata,\n series,\n parseQuery,\n} from '../model';\nimport { PrometheusDatasourceSpec } from './types';\nimport { PrometheusDatasourceEditor } from './PrometheusDatasourceEditor';\n\n/**\n * Creates a PrometheusClient for a specific datasource spec.\n */\nconst createClient: DatasourcePlugin<PrometheusDatasourceSpec, PrometheusClient>['createClient'] = (spec, options) => {\n const { directUrl, proxy } = 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 = directUrl ?? proxyUrl;\n if (datasourceUrl === undefined) {\n throw new Error('No URL specified for Prometheus client. You can use directUrl in the spec to configure it.');\n }\n\n const specHeaders = proxy?.spec.headers;\n\n // Could think about this becoming a class, although it definitely doesn't have to be\n return {\n options: {\n datasourceUrl,\n },\n healthCheck: healthCheck({ datasourceUrl, headers: specHeaders }),\n instantQuery: (params, headers, abortSignal) =>\n instantQuery(params, { datasourceUrl, headers: headers ?? specHeaders, abortSignal }),\n rangeQuery: (params, headers, abortSignal) =>\n rangeQuery(params, { datasourceUrl, headers: headers ?? specHeaders, abortSignal }),\n labelNames: (params, headers, abortSignal) =>\n labelNames(params, { datasourceUrl, headers: headers ?? specHeaders, abortSignal }),\n labelValues: (params, headers, abortSignal) =>\n labelValues(params, { datasourceUrl, headers: headers ?? specHeaders, abortSignal }),\n metricMetadata: (params, headers, abortSignal) =>\n metricMetadata(params, { datasourceUrl, headers: headers ?? specHeaders, abortSignal }),\n series: (params, headers, abortSignal) =>\n series(params, { datasourceUrl, headers: headers ?? specHeaders, abortSignal }),\n parseQuery: (params, headers, abortSignal) =>\n parseQuery(params, { datasourceUrl, headers: headers ?? specHeaders, abortSignal }),\n };\n};\n\nconst getBuiltinVariableDefinitions: () => BuiltinVariableDefinition[] = () => {\n return [\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__interval',\n value: () => '$__interval', // will be overriden when time series query is called\n source: 'Prometheus',\n display: {\n name: '__interval',\n description:\n 'For dynamic queries that adapt across different time ranges, use $__interval instead of hardcoded intervals. It represents the actual spacing between data points: it’s calculated based on the current time range and the panel pixel width (taking the \"Min step\" as a lower bound).',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__interval_ms',\n value: () => '$__interval_ms', // will be overriden when time series query is called\n source: 'Prometheus',\n display: {\n name: '__interval_ms',\n description: 'Same as $__interval but in milliseconds.',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__rate_interval',\n value: () => '$__rate_interval', // will be overriden when time series query is called\n source: 'Prometheus',\n display: {\n name: '__rate_interval',\n description:\n 'Use this one rather than $__interval as the range parameter of functions like rate, increase, etc. With such function it is advised to choose a range that is at least 4x the scrape interval (this is to allow for various races, and to be resilient to a failed scrape). $__rate_interval provides that, as it is defined as `max($__interval + Min Step, 4 * Min Step)`, where Min Step value should represent the scrape interval of the metrics.',\n hidden: true,\n },\n },\n },\n ] as BuiltinVariableDefinition[];\n};\n\nexport const PrometheusDatasource: DatasourcePlugin<PrometheusDatasourceSpec, PrometheusClient> = {\n createClient,\n getBuiltinVariableDefinitions,\n OptionsEditorComponent: PrometheusDatasourceEditor,\n createInitialOptions: () => ({ directUrl: '' }),\n};\n"],"names":["healthCheck","instantQuery","rangeQuery","labelNames","labelValues","metricMetadata","series","parseQuery","PrometheusDatasourceEditor","createClient","spec","options","directUrl","proxy","proxyUrl","datasourceUrl","undefined","Error","specHeaders","headers","params","abortSignal","getBuiltinVariableDefinitions","kind","name","value","source","display","description","hidden","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;AAIjC,SACEA,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;YAAY;IACrF;AACF;AAEA,MAAMC,gCAAmE;IACvE,OAAO;QACL;YACEC,MAAM;YACNb,MAAM;gBACJc,MAAM;gBACNC,OAAO,IAAM;gBACbC,QAAQ;gBACRC,SAAS;oBACPH,MAAM;oBACNI,aACE;oBACFC,QAAQ;gBACV;YACF;QACF;QACA;YACEN,MAAM;YACNb,MAAM;gBACJc,MAAM;gBACNC,OAAO,IAAM;gBACbC,QAAQ;gBACRC,SAAS;oBACPH,MAAM;oBACNI,aAAa;oBACbC,QAAQ;gBACV;YACF;QACF;QACA;YACEN,MAAM;YACNb,MAAM;gBACJc,MAAM;gBACNC,OAAO,IAAM;gBACbC,QAAQ;gBACRC,SAAS;oBACPH,MAAM;oBACNI,aACE;oBACFC,QAAQ;gBACV;YACF;QACF;KACD;AACH;AAEA,OAAO,MAAMC,uBAAqF;IAChGrB;IACAa;IACAS,wBAAwBvB;IACxBwB,sBAAsB,IAAO,CAAA;YAAEpB,WAAW;QAAG,CAAA;AAC/C,EAAE"}
@@ -1 +1 @@
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;AAYlD,OAAO,EACL,oCAAoC,EAIrC,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,oCAAoC,GAAG,YAAY,CAkIzG"}
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,CAmGzG"}
@@ -15,7 +15,6 @@ import { produce } from 'immer';
15
15
  import { DatasourceSelect, useDatasource, useDatasourceClient, useDatasourceSelectValueToSelector } from '@perses-dev/plugin-system';
16
16
  import { useId } from '@perses-dev/components';
17
17
  import { FormControl, Stack, TextField } from '@mui/material';
18
- import { useCallback } from 'react';
19
18
  import { DEFAULT_PROM, isDefaultPromSelector, isPrometheusDatasourceSelector, PROM_DATASOURCE_KIND } from '../../model';
20
19
  import { DEFAULT_SCRAPE_INTERVAL } from '../types';
21
20
  import { PromQLEditor } from '../../components';
@@ -23,7 +22,7 @@ import { useQueryState, useFormatState, useMinStepState } from './query-editor-m
23
22
  /**
24
23
  * The options editor component for editing a PrometheusTimeSeriesQuery's spec.
25
24
  */ export function PrometheusTimeSeriesQueryEditor(props) {
26
- const { onChange, value, value: { query, datasource }, queryHandlerSettings, isReadonly } = props;
25
+ const { onChange, value, value: { query, datasource }, isReadonly } = props;
27
26
  const datasourceSelectValue = datasource ?? DEFAULT_PROM;
28
27
  const datasourceSelectLabelID = useId('prom-datasource-label'); // for panels with multiple queries, this component is rendered multiple times on the same page
29
28
  const selectedDatasource = useDatasourceSelectValueToSelector(datasourceSelectValue, PROM_DATASOURCE_KIND);
@@ -44,45 +43,10 @@ import { useQueryState, useFormatState, useMinStepState } from './query-editor-m
44
43
  const nextDatasource = isDefaultPromSelector(next) ? undefined : next;
45
44
  draft.datasource = nextDatasource;
46
45
  }));
47
- if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
48
- ...value,
49
- datasource: next
50
- });
51
46
  return;
52
47
  }
53
48
  throw new Error('Got unexpected non-Prometheus datasource selector');
54
49
  };
55
- const handlePromQlEditorChanges = useCallback((e)=>{
56
- handleQueryChange(e);
57
- if (queryHandlerSettings?.watchQueryChanges) {
58
- queryHandlerSettings?.watchQueryChanges(e);
59
- }
60
- }, [
61
- queryHandlerSettings,
62
- handleQueryChange
63
- ]);
64
- const handleLegendSpecChange = useCallback((e)=>{
65
- handleFormatChange(e.target.value);
66
- if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
67
- ...value,
68
- seriesNameFormat: e.target.value
69
- });
70
- }, [
71
- queryHandlerSettings,
72
- handleFormatChange,
73
- value
74
- ]);
75
- const handleMinStepSpecChange = useCallback((e)=>{
76
- handleMinStepChange(e.target.value ? e.target.value : undefined);
77
- if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
78
- ...value,
79
- minStep: e.target.value
80
- });
81
- }, [
82
- queryHandlerSettings,
83
- handleMinStepChange,
84
- value
85
- ]);
86
50
  return /*#__PURE__*/ _jsxs(Stack, {
87
51
  spacing: 2,
88
52
  children: [
@@ -107,8 +71,8 @@ import { useQueryState, useFormatState, useMinStepState } from './query-editor-m
107
71
  },
108
72
  value: query,
109
73
  datasource: selectedDatasource,
110
- onChange: handlePromQlEditorChanges,
111
- onBlur: queryHandlerSettings?.runWithOnBlur ? handleQueryBlur : undefined,
74
+ onChange: handleQueryChange,
75
+ onBlur: handleQueryBlur,
112
76
  isReadOnly: isReadonly
113
77
  }),
114
78
  /*#__PURE__*/ _jsxs(Stack, {
@@ -121,8 +85,8 @@ import { useQueryState, useFormatState, useMinStepState } from './query-editor-m
121
85
  placeholder: "Example: '{{instance}}' will generate series names like 'webserver-123', 'webserver-456'...",
122
86
  helperText: "Text to be displayed in the legend and the tooltip. Use {{label_name}} to interpolate label values.",
123
87
  value: format ?? '',
124
- onChange: handleLegendSpecChange,
125
- onBlur: queryHandlerSettings?.runWithOnBlur ? handleFormatBlur : undefined,
88
+ onChange: (e)=>handleFormatChange(e.target.value),
89
+ onBlur: handleFormatBlur,
126
90
  slotProps: {
127
91
  inputLabel: {
128
92
  shrink: isReadonly ? true : undefined
@@ -137,8 +101,8 @@ import { useQueryState, useFormatState, useMinStepState } from './query-editor-m
137
101
  placeholder: minStepPlaceholder,
138
102
  helperText: "Lower bound for the step. If not provided, the scrape interval of the datasource is used.",
139
103
  value: minStep ?? '',
140
- onChange: handleMinStepSpecChange,
141
- onBlur: queryHandlerSettings?.runWithOnBlur ? handleMinStepBlur : undefined,
104
+ onChange: (e)=>handleMinStepChange(e.target.value ? e.target.value : undefined),
105
+ onBlur: handleMinStepBlur,
142
106
  sx: {
143
107
  width: '250px'
144
108
  },
@@ -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 {\n DatasourceSelect,\n DatasourceSelectProps,\n useDatasource,\n useDatasourceClient,\n useDatasourceSelectValueToSelector,\n} from '@perses-dev/plugin-system';\nimport { useId } from '@perses-dev/components';\nimport { FormControl, Stack, TextField } from '@mui/material';\nimport { ReactElement, useCallback } 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 {\n onChange,\n value,\n value: { query, datasource },\n queryHandlerSettings,\n isReadonly,\n } = props;\n\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 /* Good to know: The usage of onchange here causes an immediate spec update which eventually updates the panel\n This was probably intentional to allow for quick switching between datasources.\n Could have been triggered only with Run Query button as well.\n */\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 if (queryHandlerSettings?.setWatchOtherSpecs)\n queryHandlerSettings.setWatchOtherSpecs({ ...value, datasource: next });\n return;\n }\n\n throw new Error('Got unexpected non-Prometheus datasource selector');\n };\n\n const handlePromQlEditorChanges = useCallback(\n (e: string) => {\n handleQueryChange(e);\n if (queryHandlerSettings?.watchQueryChanges) {\n queryHandlerSettings?.watchQueryChanges(e);\n }\n },\n [queryHandlerSettings, handleQueryChange]\n );\n\n const handleLegendSpecChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n handleFormatChange(e.target.value);\n if (queryHandlerSettings?.setWatchOtherSpecs)\n queryHandlerSettings.setWatchOtherSpecs({ ...value, seriesNameFormat: e.target.value });\n },\n [queryHandlerSettings, handleFormatChange, value]\n );\n\n const handleMinStepSpecChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n handleMinStepChange(e.target.value ? (e.target.value as DurationString) : undefined);\n if (queryHandlerSettings?.setWatchOtherSpecs)\n queryHandlerSettings.setWatchOtherSpecs({ ...value, minStep: e.target.value });\n },\n [queryHandlerSettings, handleMinStepChange, value]\n );\n\n return (\n <Stack spacing={2}>\n <FormControl margin=\"dense\" fullWidth={false}>\n <DatasourceSelect\n datasourcePluginKind={PROM_DATASOURCE_KIND}\n value={datasourceSelectValue}\n onChange={handleDatasourceChange}\n labelId={datasourceSelectLabelID}\n label=\"Prometheus Datasource\"\n notched\n readOnly={isReadonly}\n />\n </FormControl>\n <PromQLEditor\n completeConfig={{ remote: { url: promURL } }}\n 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={handlePromQlEditorChanges}\n onBlur={queryHandlerSettings?.runWithOnBlur ? handleQueryBlur : undefined}\n isReadOnly={isReadonly}\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={handleLegendSpecChange}\n onBlur={queryHandlerSettings?.runWithOnBlur ? handleFormatBlur : undefined}\n slotProps={{\n inputLabel: { shrink: isReadonly ? true : undefined },\n input: { readOnly: isReadonly },\n }}\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={handleMinStepSpecChange}\n onBlur={queryHandlerSettings?.runWithOnBlur ? handleMinStepBlur : undefined}\n sx={{ width: '250px' }}\n slotProps={{\n inputLabel: { shrink: isReadonly ? true : undefined },\n input: { readOnly: isReadonly },\n }}\n />\n </Stack>\n </Stack>\n );\n}\n"],"names":["produce","DatasourceSelect","useDatasource","useDatasourceClient","useDatasourceSelectValueToSelector","useId","FormControl","Stack","TextField","useCallback","DEFAULT_PROM","isDefaultPromSelector","isPrometheusDatasourceSelector","PROM_DATASOURCE_KIND","DEFAULT_SCRAPE_INTERVAL","PromQLEditor","useQueryState","useFormatState","useMinStepState","PrometheusTimeSeriesQueryEditor","props","onChange","value","query","datasource","queryHandlerSettings","isReadonly","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","setWatchOtherSpecs","Error","handlePromQlEditorChanges","e","watchQueryChanges","handleLegendSpecChange","target","seriesNameFormat","handleMinStepSpecChange","spacing","margin","fullWidth","datasourcePluginKind","labelId","label","notched","readOnly","completeConfig","remote","url","onBlur","runWithOnBlur","isReadOnly","direction","placeholder","helperText","slotProps","inputLabel","shrink","input","sx","width"],"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,OAAO,QAAQ,QAAQ;AAChC,SACEC,gBAAgB,EAEhBC,aAAa,EACbC,mBAAmB,EACnBC,kCAAkC,QAC7B,4BAA4B;AACnC,SAASC,KAAK,QAAQ,yBAAyB;AAC/C,SAASC,WAAW,EAAEC,KAAK,EAAEC,SAAS,QAAQ,gBAAgB;AAC9D,SAAuBC,WAAW,QAAQ,QAAQ;AAClD,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;;0BAEd,MAACnB;gBAAMqE,WAAU;gBAAMd,SAAS;;kCAC9B,KAACtD;wBACCwD,SAAS;wBACTG,OAAM;wBACNU,aAAY;wBACZC,YAAW;wBACXxD,OAAOgB,UAAU;wBACjBjB,UAAUqC;wBACVe,QAAQhD,sBAAsBiD,gBAAgBlC,mBAAmBY;wBACjE2B,WAAW;4BACTC,YAAY;gCAAEC,QAAQvD,aAAa,OAAO0B;4BAAU;4BACpD8B,OAAO;gCAAEb,UAAU3C;4BAAW;wBAChC;;kCAEF,KAAClB;wBACC2D,OAAM;wBACNU,aAAajC;wBACbkC,YAAW;wBACXxD,OAAOmB,WAAW;wBAClBpB,UAAUwC;wBACVY,QAAQhD,sBAAsBiD,gBAAgB/B,oBAAoBS;wBAClE+B,IAAI;4BAAEC,OAAO;wBAAQ;wBACrBL,WAAW;4BACTC,YAAY;gCAAEC,QAAQvD,aAAa,OAAO0B;4BAAU;4BACpD8B,OAAO;gCAAEb,UAAU3C;4BAAW;wBAChC;;;;;;AAKV"}
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, 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 {\n onChange,\n value,\n value: { query, datasource },\n isReadonly,\n } = props;\n\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 /* Good to know: The usage of onchange here causes an immediate spec update which eventually updates the panel\n This was probably intentional to allow for quick switching between datasources.\n Could have been triggered only with Run Query button as well.\n */\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 <DatasourceSelect\n datasourcePluginKind={PROM_DATASOURCE_KIND}\n value={datasourceSelectValue}\n onChange={handleDatasourceChange}\n labelId={datasourceSelectLabelID}\n label=\"Prometheus Datasource\"\n notched\n readOnly={isReadonly}\n />\n </FormControl>\n <PromQLEditor\n completeConfig={{ remote: { url: promURL } }}\n 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 isReadOnly={isReadonly}\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 slotProps={{\n inputLabel: { shrink: isReadonly ? true : undefined },\n input: { readOnly: isReadonly },\n }}\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 ? (e.target.value as DurationString) : undefined)}\n onBlur={handleMinStepBlur}\n sx={{ width: '250px' }}\n slotProps={{\n inputLabel: { shrink: isReadonly ? true : undefined },\n input: { readOnly: isReadonly },\n }}\n />\n </Stack>\n </Stack>\n );\n}\n"],"names":["produce","DatasourceSelect","useDatasource","useDatasourceClient","useDatasourceSelectValueToSelector","useId","FormControl","Stack","TextField","DEFAULT_PROM","isDefaultPromSelector","isPrometheusDatasourceSelector","PROM_DATASOURCE_KIND","DEFAULT_SCRAPE_INTERVAL","PromQLEditor","useQueryState","useFormatState","useMinStepState","PrometheusTimeSeriesQueryEditor","props","onChange","value","query","datasource","isReadonly","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","datasourcePluginKind","labelId","label","notched","readOnly","completeConfig","remote","url","onBlur","isReadOnly","direction","placeholder","helperText","e","target","slotProps","inputLabel","shrink","input","sx","width"],"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,OAAO,QAAQ,QAAQ;AAChC,SACEC,gBAAgB,EAEhBC,aAAa,EACbC,mBAAmB,EACnBC,kCAAkC,QAC7B,4BAA4B;AACnC,SAASC,KAAK,QAAQ,yBAAyB;AAC/C,SAASC,WAAW,EAAEC,KAAK,EAAEC,SAAS,QAAQ,gBAAgB;AAE9D,SACEC,YAAY,EAEZC,qBAAqB,EACrBC,8BAA8B,EAC9BC,oBAAoB,QAGf,cAAc;AACrB,SAASC,uBAAuB,QAAkC,WAAW;AAC7E,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAEEC,aAAa,EACbC,cAAc,EACdC,eAAe,QACV,uBAAuB;AAE9B;;CAEC,GACD,OAAO,SAASC,gCAAgCC,KAA2C;IACzF,MAAM,EACJC,QAAQ,EACRC,KAAK,EACLA,OAAO,EAAEC,KAAK,EAAEC,UAAU,EAAE,EAC5BC,UAAU,EACX,GAAGL;IAEJ,MAAMM,wBAAwBF,cAAcd;IAE5C,MAAMiB,0BAA0BrB,MAAM,0BAA0B,+FAA+F;IAE/J,MAAMsB,qBAAqBvB,mCACzBqB,uBACAb;IAGF,MAAM,EAAEgB,MAAMC,MAAM,EA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AAU,CAACgD,IAAM/B,mBAAmB+B,EAAEC,MAAM,CAAChD,KAAK;wBAClD0C,QAAQzB;wBACRgC,WAAW;4BACTC,YAAY;gCAAEC,QAAQhD,aAAa,OAAO0B;4BAAU;4BACpDuB,OAAO;gCAAEd,UAAUnC;4BAAW;wBAChC;;kCAEF,KAAChB;wBACCiD,OAAM;wBACNS,aAAaxB;wBACbyB,YAAW;wBACX9C,OAAOkB,WAAW;wBAClBnB,UAAU,CAACgD,IAAM5B,oBAAoB4B,EAAEC,MAAM,CAAChD,KAAK,GAAI+C,EAAEC,MAAM,CAAChD,KAAK,GAAsB6B;wBAC3Fa,QAAQtB;wBACRiC,IAAI;4BAAEC,OAAO;wBAAQ;wBACrBL,WAAW;4BACTC,YAAY;gCAAEC,QAAQhD,aAAa,OAAO0B;4BAAU;4BACpDuB,OAAO;gCAAEd,UAAUnC;4BAAW;wBAChC;;;;;;AAKV"}
@@ -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,EAAqD,MAAM,2BAA2B,CAAC;AAiBrH,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAG1E,eAAO,MAAM,iBAAiB,EAAE,qBAAqB,CAAC,6BAA6B,CAAC,CAAC,mBAAmB,CAyHvG,CAAC"}
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,CAmIvG,CAAC"}
@@ -17,7 +17,7 @@ import { parseValueTuple, getDurationStringSeconds, getPrometheusTimeRange, getR
17
17
  import { getFormattedPrometheusSeriesName } from '../../utils';
18
18
  import { DEFAULT_SCRAPE_INTERVAL } from '../types';
19
19
  import { replacePromBuiltinVariables } from './replace-prom-builtin-variables';
20
- export const getTimeSeriesData = async (spec, context)=>{
20
+ export const getTimeSeriesData = async (spec, context, abortSignal)=>{
21
21
  if (spec.query === undefined || spec.query === null || spec.query === '') {
22
22
  // Do not make a request to the backend, instead return an empty TimeSeriesData
23
23
  return {
@@ -69,7 +69,7 @@ export const getTimeSeriesData = async (spec, context)=>{
69
69
  response = await client.instantQuery({
70
70
  query,
71
71
  time: end
72
- });
72
+ }, undefined, abortSignal);
73
73
  break;
74
74
  case 'range':
75
75
  default:
@@ -78,7 +78,7 @@ export const getTimeSeriesData = async (spec, context)=>{
78
78
  start,
79
79
  end,
80
80
  step
81
- });
81
+ }, undefined, abortSignal);
82
82
  break;
83
83
  }
84
84
  // TODO: What about error responses from Prom that have a response body?
@@ -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, 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\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 /* Ensure end is always greater than start:\n If the step is greater than equal to the diff of end and start,\n both start, and end will eventually be rounded to the same value,\n Consequently, the time range will be zero, which does not return any valid value\n */\n if (end === start) {\n end = start + step;\n console.warn(`Step (${step}) was larger than the time range! end of time range was set accordingly.`);\n }\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","console","warn","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"],"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;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UAAU;IAClC,OAAQA;QACN,KAAK;YACH,OAAOd,gBAAgBpD,OAAOuC,MAAMT;QACtC,KAAK;YACH,OAAOkC,gBAAgBhE,OAAOuC,MAAMT;QACtC,KAAK;YACH,OAAOmC,gBAAgBjE,OAAOuC,MAAMT;QACtC;YACEJ,QAAQC,IAAI,CAAC,uBAAuBuC,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 abortSignal\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\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 /* Ensure end is always greater than start:\n If the step is greater than equal to the diff of end and start,\n both start, and end will eventually be rounded to the same value,\n Consequently, the time range will be zero, which does not return any valid value\n */\n if (end === start) {\n end = start + step;\n console.warn(`Step (${step}) was larger than the time range! end of time range was set accordingly.`);\n }\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\n let response;\n switch (context.mode) {\n case 'instant':\n response = await client.instantQuery(\n {\n query,\n time: end,\n },\n undefined,\n abortSignal\n );\n break;\n case 'range':\n default:\n response = await client.rangeQuery(\n {\n query,\n start,\n end,\n step,\n },\n undefined,\n abortSignal\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","abortSignal","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","console","warn","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"],"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,SACAC;IAEA,IAAIF,KAAKG,KAAK,KAAKC,aAAaJ,KAAKG,KAAK,KAAK,QAAQH,KAAKG,KAAK,KAAK,IAAI;QACxE,+EAA+E;QAC/E,OAAO;YAAEE,QAAQ,EAAE;QAAC;IACtB;IAEA,MAAMC,4BAA4B,MAAML,QAAQM,eAAe,CAACD,yBAAyB,CAACX;IAE1F,MAAMa,qBACJtB,gCACEc,KAAKS,UAAU,IAAIf,cACnBO,QAAQS,aAAa,EACrBJ,8BACGZ;IAEP,MAAMe,aAAc,MAAMR,QAAQM,eAAe,CAACI,aAAa,CAC7DH;IAEF,MAAMI,2BAA2BC,KAAKC,KAAK,CACzCzB,aAAaJ,oBAAoBwB,WAAWM,MAAM,CAACf,IAAI,CAACgB,cAAc,IAAInB,4BAA4B;IAGxG,kEAAkE;IAClE,6FAA6F;IAC7F,MAAMoB,UACJ1B,yBACE,mDAAmD;IACnD,iHAAiH;IACjHJ,iBAAiBa,KAAKiB,O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1 @@
1
- {"version":3,"file":"prometheus-variables.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-variables.tsx"],"names":[],"mappings":"AAaA,OAAO,EAGL,kBAAkB,EAElB,cAAc,EACf,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAyB,MAAM,OAAO,CAAC;AAE5D,OAAO,EAIL,UAAU,EAGV,UAAU,EACX,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,mCAAmC,EACnC,oCAAoC,EACpC,+BAA+B,EAChC,MAAM,SAAS,CAAC;AAUjB,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,kBAAkB,CAAC,oCAAoC,CAAC,GAC9D,YAAY,CAsEd;AAED,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,kBAAkB,CAAC,mCAAmC,CAAC,GAC7D,YAAY,CAsDd;AAED,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,kBAAkB,CAAC,+BAA+B,CAAC,GACzD,YAAY,CAsFd;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAS/E;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAS/E;AAED;;GAEG;AACH,eAAO,MAAM,4BAA4B,GAAI,SAAS,MAAM,EAAE,KAAG,cAAc,EAM9E,CAAC"}
1
+ {"version":3,"file":"prometheus-variables.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-variables.tsx"],"names":[],"mappings":"AAaA,OAAO,EAIL,kBAAkB,EAGlB,cAAc,EACf,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAyB,MAAM,OAAO,CAAC;AAE5D,OAAO,EAIL,UAAU,EAIV,UAAU,EACX,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,mCAAmC,EACnC,oCAAoC,EACpC,+BAA+B,EAChC,MAAM,SAAS,CAAC;A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