@perses-dev/prometheus-plugin 0.39.0 → 0.40.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 (78) hide show
  1. package/dist/cjs/components/PromQL.js +9 -7
  2. package/dist/cjs/components/index.js +10 -8
  3. package/dist/cjs/index.js +33 -19
  4. package/dist/cjs/model/index.js +15 -13
  5. package/dist/cjs/model/parse-sample-values.js +6 -2
  6. package/dist/cjs/model/prometheus-client.js +24 -5
  7. package/dist/cjs/model/prometheus-selectors.js +13 -5
  8. package/dist/cjs/model/templating.js +7 -5
  9. package/dist/cjs/model/time.js +14 -8
  10. package/dist/cjs/plugins/MatcherEditor.js +13 -11
  11. package/dist/cjs/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.js +127 -63
  12. package/dist/cjs/plugins/PrometheusDatasourceEditor/index.js +11 -9
  13. package/dist/cjs/plugins/PrometheusDatasourceEditor/types.js +7 -0
  14. package/dist/cjs/plugins/prometheus-datasource.js +53 -7
  15. package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +10 -8
  16. package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +44 -20
  17. package/dist/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +39 -21
  18. package/dist/cjs/plugins/prometheus-time-series-query/index.js +10 -8
  19. package/dist/cjs/plugins/prometheus-time-series-query/query-editor-model.js +42 -9
  20. package/dist/cjs/plugins/prometheus-variables.js +60 -54
  21. package/dist/cjs/plugins/variable.js +9 -7
  22. package/dist/cjs/utils/index.js +10 -8
  23. package/dist/cjs/utils/utils.js +12 -6
  24. package/dist/components/PromQL.js.map +1 -1
  25. package/dist/components/index.js.map +1 -1
  26. package/dist/index.js.map +1 -1
  27. package/dist/model/index.js.map +1 -1
  28. package/dist/model/parse-sample-values.js.map +1 -1
  29. package/dist/model/prometheus-client.d.ts.map +1 -1
  30. package/dist/model/prometheus-client.js +9 -0
  31. package/dist/model/prometheus-client.js.map +1 -1
  32. package/dist/model/prometheus-selectors.js +1 -1
  33. package/dist/model/prometheus-selectors.js.map +1 -1
  34. package/dist/model/templating.js.map +1 -1
  35. package/dist/model/time.js +1 -1
  36. package/dist/model/time.js.map +1 -1
  37. package/dist/plugins/MatcherEditor.js.map +1 -1
  38. package/dist/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.d.ts.map +1 -1
  39. package/dist/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.js +95 -33
  40. package/dist/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.js.map +1 -1
  41. package/dist/plugins/PrometheusDatasourceEditor/index.js.map +1 -1
  42. package/dist/plugins/PrometheusDatasourceEditor/types.d.ts +6 -4
  43. package/dist/plugins/PrometheusDatasourceEditor/types.d.ts.map +1 -1
  44. package/dist/plugins/PrometheusDatasourceEditor/types.js +1 -1
  45. package/dist/plugins/PrometheusDatasourceEditor/types.js.map +1 -1
  46. package/dist/plugins/prometheus-datasource.d.ts +3 -2
  47. package/dist/plugins/prometheus-datasource.d.ts.map +1 -1
  48. package/dist/plugins/prometheus-datasource.js +48 -4
  49. package/dist/plugins/prometheus-datasource.js.map +1 -1
  50. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +1 -1
  51. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js.map +1 -1
  52. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
  53. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +32 -10
  54. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -1
  55. package/dist/plugins/prometheus-time-series-query/get-time-series-data.d.ts.map +1 -1
  56. package/dist/plugins/prometheus-time-series-query/get-time-series-data.js +32 -16
  57. package/dist/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -1
  58. package/dist/plugins/prometheus-time-series-query/index.js.map +1 -1
  59. package/dist/plugins/prometheus-time-series-query/query-editor-model.d.ts +10 -1
  60. package/dist/plugins/prometheus-time-series-query/query-editor-model.d.ts.map +1 -1
  61. package/dist/plugins/prometheus-time-series-query/query-editor-model.js +36 -8
  62. package/dist/plugins/prometheus-time-series-query/query-editor-model.js.map +1 -1
  63. package/dist/plugins/prometheus-time-series-query/time-series-query-model.d.ts +2 -2
  64. package/dist/plugins/prometheus-time-series-query/time-series-query-model.d.ts.map +1 -1
  65. package/dist/plugins/prometheus-time-series-query/time-series-query-model.js.map +1 -1
  66. package/dist/plugins/prometheus-variables.js +27 -27
  67. package/dist/plugins/prometheus-variables.js.map +1 -1
  68. package/dist/plugins/types.d.ts +2 -2
  69. package/dist/plugins/types.d.ts.map +1 -1
  70. package/dist/plugins/types.js.map +1 -1
  71. package/dist/plugins/variable.js +2 -2
  72. package/dist/plugins/variable.js.map +1 -1
  73. package/dist/test/setup-tests.js.map +1 -1
  74. package/dist/utils/index.js.map +1 -1
  75. package/dist/utils/utils.d.ts +1 -1
  76. package/dist/utils/utils.js +3 -3
  77. package/dist/utils/utils.js.map +1 -1
  78. package/package.json +6 -6
@@ -13,10 +13,11 @@
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { produce } from 'immer';
15
15
  import { Stack, TextField, FormControl, InputLabel } from '@mui/material';
16
- import { DatasourceSelect, useDatasourceClient } from '@perses-dev/plugin-system';
16
+ import { DatasourceSelect, useDatasource, useDatasourceClient } from '@perses-dev/plugin-system';
17
17
  import { DEFAULT_PROM, isDefaultPromSelector, isPrometheusDatasourceSelector, PROM_DATASOURCE_KIND } from '../../model';
18
18
  import { PromQLEditor } from '../../components';
19
- import { useQueryState, useFormatState } from './query-editor-model';
19
+ import { DEFAULT_SCRAPE_INTERVAL } from '../PrometheusDatasourceEditor';
20
+ import { useQueryState, useFormatState, useMinStepState } from './query-editor-model';
20
21
  /**
21
22
  * The options editor component for editing a PrometheusTimeSeriesQuery's spec.
22
23
  */ export function PrometheusTimeSeriesQueryEditor(props) {
@@ -25,8 +26,12 @@ import { useQueryState, useFormatState } from './query-editor-model';
25
26
  const selectedDatasource = datasource !== null && datasource !== void 0 ? datasource : DEFAULT_PROM;
26
27
  const { data: client } = useDatasourceClient(selectedDatasource);
27
28
  const promURL = client === null || client === void 0 ? void 0 : client.options.datasourceUrl;
29
+ const { data: datasourceResource } = useDatasource(selectedDatasource);
28
30
  const { query , handleQueryChange , handleQueryBlur } = useQueryState(props);
29
31
  const { format , handleFormatChange , handleFormatBlur } = useFormatState(props);
32
+ const { minStep , handleMinStepChange , handleMinStepBlur } = useMinStepState(props);
33
+ var _ref;
34
+ const minStepPlaceholder = (_ref = minStep !== null && minStep !== void 0 ? minStep : datasourceResource && (datasourceResource === null || datasourceResource === void 0 ? void 0 : datasourceResource.plugin.spec).scrapeInterval) !== null && _ref !== void 0 ? _ref : DEFAULT_SCRAPE_INTERVAL;
30
35
  const handleDatasourceChange = (next)=>{
31
36
  if (isPrometheusDatasourceSelector(next)) {
32
37
  onChange(produce(value, (draft)=>{
@@ -68,14 +73,31 @@ import { useQueryState, useFormatState } from './query-editor-model';
68
73
  onChange: handleQueryChange,
69
74
  onBlur: handleQueryBlur
70
75
  }),
71
- /*#__PURE__*/ _jsx(TextField, {
72
- fullWidth: true,
73
- label: "Legend Name",
74
- placeholder: "Tip: Use {{label_name}}. Example: {{instance}} will be replaced with values such as 'webserver-123' and 'webserver-456'.",
75
- helperText: "Set the name for each series in the legend and the tooltip.",
76
- value: format !== null && format !== void 0 ? format : '',
77
- onChange: (e)=>handleFormatChange(e.target.value),
78
- onBlur: handleFormatBlur
76
+ /*#__PURE__*/ _jsxs(Stack, {
77
+ direction: "row",
78
+ spacing: 2,
79
+ children: [
80
+ /*#__PURE__*/ _jsx(TextField, {
81
+ fullWidth: true,
82
+ label: "Legend Name",
83
+ placeholder: "Tip: Use {{label_name}}. Example: {{instance}} will be replaced with values such as 'webserver-123' and 'webserver-456'.",
84
+ helperText: "Name for each series in the legend and the tooltip.",
85
+ value: format !== null && format !== void 0 ? format : '',
86
+ onChange: (e)=>handleFormatChange(e.target.value),
87
+ onBlur: handleFormatBlur
88
+ }),
89
+ /*#__PURE__*/ _jsx(TextField, {
90
+ label: "Min Step",
91
+ placeholder: minStepPlaceholder,
92
+ helperText: "Step parameter of the query. Used by $__interval and $__rate_interval too.",
93
+ value: minStep,
94
+ onChange: (e)=>handleMinStepChange(e.target.value),
95
+ onBlur: handleMinStepBlur,
96
+ sx: {
97
+ width: '250px'
98
+ }
99
+ })
100
+ ]
79
101
  })
80
102
  ]
81
103
  });
@@ -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 { Stack, TextField, FormControl, InputLabel } from '@mui/material';\nimport { DatasourceSelect, DatasourceSelectProps, useDatasourceClient } from '@perses-dev/plugin-system';\nimport {\n DEFAULT_PROM,\n isDefaultPromSelector,\n isPrometheusDatasourceSelector,\n PROM_DATASOURCE_KIND,\n PrometheusClient,\n} from '../../model';\nimport { PromQLEditor } from '../../components';\nimport { PrometheusTimeSeriesQueryEditorProps, useQueryState, useFormatState } from './query-editor-model';\n\n/**\n * The options editor component for editing a PrometheusTimeSeriesQuery's spec.\n */\nexport function PrometheusTimeSeriesQueryEditor(props: PrometheusTimeSeriesQueryEditorProps) {\n const { onChange, value } = props;\n const { datasource } = value;\n const selectedDatasource = datasource ?? DEFAULT_PROM;\n\n const { data: client } = useDatasourceClient<PrometheusClient>(selectedDatasource);\n const promURL = client?.options.datasourceUrl;\n\n const { query, handleQueryChange, handleQueryBlur } = useQueryState(props);\n const { format, handleFormatChange, handleFormatBlur } = useFormatState(props);\n\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = (next) => {\n if (isPrometheusDatasourceSelector(next)) {\n onChange(\n produce(value, (draft) => {\n // If they're using the default, just omit the datasource prop (i.e. set to undefined)\n const nextDatasource = isDefaultPromSelector(next) ? undefined : next;\n draft.datasource = nextDatasource;\n })\n );\n return;\n }\n\n throw new Error('Got unexpected non-Prometheus datasource selector');\n };\n\n return (\n <Stack spacing={2}>\n <FormControl margin=\"dense\" fullWidth={false}>\n {/* TODO: How do we ensure unique ID values if there are multiple of these? Can we use React 18 useId and\n maintain 17 compatibility somehow with a polyfill/shim? */}\n <InputLabel id=\"prom-datasource-label\">Prometheus Datasource</InputLabel>\n <DatasourceSelect\n datasourcePluginKind={PROM_DATASOURCE_KIND}\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n labelId=\"prom-datasource-label\"\n label=\"Prometheus Datasource\"\n />\n </FormControl>\n <PromQLEditor\n completeConfig={{ remote: { url: promURL } }}\n value={query}\n onChange={handleQueryChange}\n onBlur={handleQueryBlur}\n />\n <TextField\n fullWidth\n label=\"Legend Name\"\n placeholder=\"Tip: Use {{label_name}}. Example: {{instance}} will be replaced with values such as 'webserver-123' and 'webserver-456'.\"\n helperText=\"Set the name for each series in the legend and the tooltip.\"\n value={format ?? ''}\n onChange={(e) => handleFormatChange(e.target.value)}\n onBlur={handleFormatBlur}\n />\n </Stack>\n );\n}\n"],"names":["produce","Stack","TextField","FormControl","InputLabel","DatasourceSelect","useDatasourceClient","DEFAULT_PROM","isDefaultPromSelector","isPrometheusDatasourceSelector","PROM_DATASOURCE_KIND","PromQLEditor","useQueryState","useFormatState","PrometheusTimeSeriesQueryEditor","props","onChange","value","datasource","selectedDatasource","data","client","promURL","options","datasourceUrl","query","handleQueryChange","handleQueryBlur","format","handleFormatChange","handleFormatBlur","handleDatasourceChange","next","draft","nextDatasource","undefined","Error","spacing","margin","fullWidth","id","datasourcePluginKind","labelId","label","completeConfig","remote","url","onBlur","placeholder","helperText","e","target"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,OAAO,QAAQ,OAAO,CAAC;AAChC,SAASC,KAAK,EAAEC,SAAS,EAAEC,WAAW,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAC1E,SAASC,gBAAgB,EAAyBC,mBAAmB,QAAQ,2BAA2B,CAAC;AACzG,SACEC,YAAY,EACZC,qBAAqB,EACrBC,8BAA8B,EAC9BC,oBAAoB,QAEf,aAAa,CAAC;AACrB,SAASC,YAAY,QAAQ,kBAAkB,CAAC;AAChD,SAA+CC,aAAa,EAAEC,cAAc,QAAQ,sBAAsB,CAAC;AAE3G;;CAEC,GACD,OAAO,SAASC,+BAA+B,CAACC,KAA2C,EAAE;IAC3F,MAAM,EAAEC,QAAQ,CAAA,EAAEC,KAAK,CAAA,EAAE,GAAGF,KAAK,AAAC;IAClC,MAAM,EAAEG,UAAU,CAAA,EAAE,GAAGD,KAAK,AAAC;IAC7B,MAAME,kBAAkB,GAAGD,UAAU,aAAVA,UAAU,cAAVA,UAAU,GAAIX,YAAY,AAAC;IAEtD,MAAM,EAAEa,IAAI,EAAEC,MAAM,CAAA,EAAE,GAAGf,mBAAmB,CAAmBa,kBAAkB,CAAC,AAAC;IACnF,MAAMG,OAAO,GAAGD,MAAM,aAANA,MAAM,WAAS,GAAfA,KAAAA,CAAe,GAAfA,MAAM,CAAEE,OAAO,CAACC,aAAa,AAAC;IAE9C,MAAM,EAAEC,KAAK,CAAA,EAAEC,iBAAiB,CAAA,EAAEC,eAAe,CAAA,EAAE,G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C,aAAa;gBACnBK,WAAW,EAAC,0HAA0H;gBACtIC,UAAU,EAAC,6DAA6D;gBACxEhC,KAAK,EAAEW,MAAM,aAANA,MAAM,cAANA,MAAM,GAAI,EAAE;gBACnBZ,QAAQ,EAAE,CAACkC,CAAC,GAAKrB,kBAAkB,CAACqB,CAAC,CAACC,MAAM,CAAClC,KAAK,CAAC;gBACnD8B,MAAM,EAAEjB,gBAAgB;cACxB;;MACI,CACR;AACJ,CAAC"}
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 { Stack, TextField, FormControl, InputLabel } from '@mui/material';\nimport { DatasourceSelect, DatasourceSelectProps, useDatasource, useDatasourceClient } from '@perses-dev/plugin-system';\nimport {\n DEFAULT_PROM,\n DurationString,\n isDefaultPromSelector,\n isPrometheusDatasourceSelector,\n PROM_DATASOURCE_KIND,\n PrometheusClient,\n} from '../../model';\nimport { PromQLEditor } from '../../components';\nimport { PrometheusDatasourceSpec } from '../prometheus-datasource';\nimport { DEFAULT_SCRAPE_INTERVAL } from '../PrometheusDatasourceEditor';\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) {\n const { onChange, value } = props;\n const { datasource } = value;\n const selectedDatasource = datasource ?? DEFAULT_PROM;\n\n const { data: client } = useDatasourceClient<PrometheusClient>(selectedDatasource);\n const promURL = client?.options.datasourceUrl;\n const { data: datasourceResource } = useDatasource(selectedDatasource);\n\n const { query, handleQueryChange, handleQueryBlur } = useQueryState(props);\n const { format, handleFormatChange, handleFormatBlur } = useFormatState(props);\n const { minStep, handleMinStepChange, handleMinStepBlur } = useMinStepState(props);\n const minStepPlaceholder =\n minStep ??\n (datasourceResource && (datasourceResource?.plugin.spec as PrometheusDatasourceSpec).scrapeInterval) ??\n DEFAULT_SCRAPE_INTERVAL;\n\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = (next) => {\n if (isPrometheusDatasourceSelector(next)) {\n onChange(\n produce(value, (draft) => {\n // If they're using the default, just omit the datasource prop (i.e. set to undefined)\n const nextDatasource = isDefaultPromSelector(next) ? undefined : next;\n draft.datasource = nextDatasource;\n })\n );\n return;\n }\n\n throw new Error('Got unexpected non-Prometheus datasource selector');\n };\n\n return (\n <Stack spacing={2}>\n <FormControl margin=\"dense\" fullWidth={false}>\n {/* TODO: How do we ensure unique ID values if there are multiple of these? Can we use React 18 useId and\n maintain 17 compatibility somehow with a polyfill/shim? */}\n <InputLabel id=\"prom-datasource-label\">Prometheus Datasource</InputLabel>\n <DatasourceSelect\n datasourcePluginKind={PROM_DATASOURCE_KIND}\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n labelId=\"prom-datasource-label\"\n label=\"Prometheus Datasource\"\n />\n </FormControl>\n <PromQLEditor\n completeConfig={{ remote: { url: promURL } }}\n value={query}\n onChange={handleQueryChange}\n onBlur={handleQueryBlur}\n />\n <Stack direction=\"row\" spacing={2}>\n <TextField\n fullWidth\n label=\"Legend Name\"\n placeholder=\"Tip: Use {{label_name}}. Example: {{instance}} will be replaced with values such as 'webserver-123' and 'webserver-456'.\"\n helperText=\"Name for each series in the legend and the tooltip.\"\n value={format ?? ''}\n onChange={(e) => handleFormatChange(e.target.value)}\n onBlur={handleFormatBlur}\n />\n <TextField\n label=\"Min Step\"\n placeholder={minStepPlaceholder}\n helperText=\"Step parameter of the query. Used by $__interval and $__rate_interval too.\"\n value={minStep}\n onChange={(e) => handleMinStepChange(e.target.value as DurationString)}\n onBlur={handleMinStepBlur}\n sx={{ width: '250px' }}\n />\n </Stack>\n </Stack>\n );\n}\n"],"names":["produce","Stack","TextField","FormControl","InputLabel","DatasourceSelect","useDatasource","useDatasourceClient","DEFAULT_PROM","isDefaultPromSelector","isPrometheusDatasourceSelector","PROM_DATASOURCE_KIND","PromQLEditor","DEFAULT_SCRAPE_INTERVAL","useQueryState","useFormatState","useMinStepState","PrometheusTimeSeriesQueryEditor","props","onChange","value","datasource","selectedDatasource","data","client","promURL","options","datasourceUrl","datasourceResource","query","handleQueryChange","handleQueryBlur","format","handleFormatChange","handleFormatBlur","minStep","handleMinStepChange","handleMinStepBlur","minStepPlaceholder","plugin","spec","scrapeInterval","handleDatasourceChange","next","draft","nextDatasource","undefined","Error","spacing","margin","fullWidth","id","datasourcePluginKind","labelId","label","completeConfig","remote","url","onBlur","direction","placeholder","helperText","e","target","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,SAASC,KAAK,EAAEC,SAAS,EAAEC,WAAW,EAAEC,UAAU,QAAQ,gBAAgB;AAC1E,SAASC,gBAAgB,EAAyBC,aAAa,EAAEC,mBAAmB,QAAQ,4BAA4B;AACxH,SACEC,YAAY,EAEZC,qBAAqB,EACrBC,8BAA8B,EAC9BC,oBAAoB,QAEf,cAAc;AACrB,SAASC,YAAY,QAAQ,mBAAmB;AAEhD,SAASC,uBAAuB,QAAQ,gCAAgC;AACxE,SAEEC,aAAa,EACbC,cAAc,EACdC,eAAe,QACV,uBAAuB;AAE9B;;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KAAC1C;gBACC2C,gBAAgB;oBAAEC,QAAQ;wBAAEC,KAAKhC;oBAAQ;gBAAE;gBAC3CL,OAAOS;gBACPV,UAAUW;gBACV4B,QAAQ3B;;0BAEV,MAAC9B;gBAAM0D,WAAU;gBAAMX,SAAS;;kCAC9B,KAAC9C;wBACCgD,SAAS;wBACTI,OAAM;wBACNM,aAAY;wBACZC,YAAW;wBACXzC,OAAOY,mBAAAA,oBAAAA,SAAU;wBACjBb,UAAU,CAAC2C,IAAM7B,mBAAmB6B,EAAEC,OAAO3C;wBAC7CsC,QAAQxB;;kCAEV,KAAChC;wBACCoD,OAAM;wBACNM,aAAatB;wBACbuB,YAAW;wBACXzC,OAAOe;wBACPhB,UAAU,CAAC2C,IAAM1B,oBAAoB0B,EAAEC,OAAO3C;wBAC9CsC,QAAQrB;wBACR2B,IAAI;4BAAEC,OAAO;wBAAQ;;;;;;AAK/B"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-time-series-data.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-time-series-query/get-time-series-data.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,qBAAqB,EAA4B,MAAM,2BAA2B,CAAC;AAW5F,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAE1E,eAAO,MAAM,iBAAiB,EAAE,qBAAqB,CAAC,6BAA6B,CAAC,CAAC,mBAAmB,CAqFvG,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;AAYrH,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAE1E,eAAO,MAAM,iBAAiB,EAAE,qBAAqB,CAAC,6BAA6B,CAAC,CAAC,mBAAmB,CAqGvG,CAAC"}
@@ -10,21 +10,28 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { replaceTemplateVariables } from '@perses-dev/plugin-system';
14
- import { fromUnixTime } from 'date-fns';
13
+ import { formatDuration, msToPrometheusDuration, parseDurationString } from '@perses-dev/core';
14
+ import { replaceTemplateVariables, replaceTemplateVariable } from '@perses-dev/plugin-system';
15
+ import { fromUnixTime, milliseconds } from 'date-fns';
15
16
  import { parseValueTuple, getDurationStringSeconds, getPrometheusTimeRange, getRangeStep, DEFAULT_PROM } from '../../model';
16
17
  import { getFormattedPrometheusSeriesName } from '../../utils';
18
+ import { DEFAULT_SCRAPE_INTERVAL } from '../PrometheusDatasourceEditor';
17
19
  export const getTimeSeriesData = async (spec, context)=>{
18
- var ref;
20
+ var _response_data;
19
21
  if (spec.query === undefined || spec.query === null || spec.query === '') {
20
22
  // Do not make a request to the backend, instead return an empty TimeSeriesData
21
23
  return {
22
24
  series: []
23
25
  };
24
26
  }
25
- const minStep = getDurationStringSeconds(spec.min_step);
27
+ var _spec_datasource;
28
+ const datasource = await context.datasourceStore.getDatasource((_spec_datasource = spec.datasource) !== null && _spec_datasource !== void 0 ? _spec_datasource : DEFAULT_PROM);
29
+ var _datasource_plugin_spec_scrapeInterval;
30
+ const datasourceScrapeInterval = Math.trunc(milliseconds(parseDurationString((_datasource_plugin_spec_scrapeInterval = datasource.plugin.spec.scrapeInterval) !== null && _datasource_plugin_spec_scrapeInterval !== void 0 ? _datasource_plugin_spec_scrapeInterval : DEFAULT_SCRAPE_INTERVAL)) / 1000);
31
+ var _getDurationStringSeconds;
32
+ const minStep = (_getDurationStringSeconds = getDurationStringSeconds(spec.minStep)) !== null && _getDurationStringSeconds !== void 0 ? _getDurationStringSeconds : datasourceScrapeInterval;
26
33
  const timeRange = getPrometheusTimeRange(context.timeRange);
27
- const step = getRangeStep(timeRange, minStep, undefined, context.suggestedStepMs);
34
+ const step = getRangeStep(timeRange, minStep, undefined, context.suggestedStepMs); // TODO: resolution
28
35
  // Align the time range so that it's a multiple of the step
29
36
  let { start , end } = timeRange;
30
37
  const utcOffsetSec = new Date().getTimezoneOffset() * 60;
@@ -32,17 +39,26 @@ export const getTimeSeriesData = async (spec, context)=>{
32
39
  const alignedStart = Math.floor((start + utcOffsetSec) / step) * step - utcOffsetSec;
33
40
  start = alignedStart;
34
41
  end = alignedEnd;
42
+ var _context_suggestedStepMs;
35
43
  // Replace template variable placeholders in PromQL query
36
- let query = spec.query.replace('$__rate_interval', `15s`);
44
+ const intervalMs = (_context_suggestedStepMs = context.suggestedStepMs) !== null && _context_suggestedStepMs !== void 0 ? _context_suggestedStepMs : step * 1000; // Step is in seconds
45
+ let query = replaceTemplateVariable(spec.query, '__interval_ms', intervalMs.toString());
46
+ query = replaceTemplateVariable(spec.query, '__interval', formatDuration(msToPrometheusDuration(intervalMs)));
47
+ const scrapeIntervalMs = minStep * 1000;
48
+ // The $__rate_interval variable is meant to be used in the rate function.
49
+ // It is defined as max($__interval + Scrape interval, 4 * Scrape interval), where Scrape interval is the Min step setting (a setting per PromQL query),
50
+ // if any is set, and otherwise the Scrape interval as set in the Prometheus datasource
51
+ const rateIntervalMs = Math.max(intervalMs + scrapeIntervalMs, 4 * scrapeIntervalMs);
52
+ query = replaceTemplateVariable(query, '__rate_interval', formatDuration(msToPrometheusDuration(rateIntervalMs)));
37
53
  query = replaceTemplateVariables(query, context.variableState);
38
- let seriesNameFormat = spec.series_name_format;
54
+ let seriesNameFormat = spec.seriesNameFormat;
39
55
  // if series name format is defined, replace template variable placeholders in series name format
40
56
  if (seriesNameFormat) {
41
57
  seriesNameFormat = replaceTemplateVariables(seriesNameFormat, context.variableState);
42
58
  }
43
- var _datasource;
59
+ var _spec_datasource1;
44
60
  // Get the datasource, using the default Prom Datasource if one isn't specified in the query
45
- const client = await context.datasourceStore.getDatasourceClient((_datasource = spec.datasource) !== null && _datasource !== void 0 ? _datasource : DEFAULT_PROM);
61
+ const client = await context.datasourceStore.getDatasourceClient((_spec_datasource1 = spec.datasource) !== null && _spec_datasource1 !== void 0 ? _spec_datasource1 : DEFAULT_PROM);
46
62
  // Make the request to Prom
47
63
  const response = await client.rangeQuery({
48
64
  query,
@@ -50,16 +66,16 @@ export const getTimeSeriesData = async (spec, context)=>{
50
66
  end,
51
67
  step
52
68
  });
53
- var ref1;
69
+ var _response_data_result;
54
70
  // TODO: What about error responses from Prom that have a response body?
55
- const result = (ref1 = (ref = response.data) === null || ref === void 0 ? void 0 : ref.result) !== null && ref1 !== void 0 ? ref1 : [];
71
+ const result = (_response_data_result = (_response_data = response.data) === null || _response_data === void 0 ? void 0 : _response_data.result) !== null && _response_data_result !== void 0 ? _response_data_result : [];
56
72
  // Custom display for response header warnings, configurable error responses display coming next
57
73
  const notices = [];
58
74
  if (response.status === 'success') {
59
- var _warnings;
60
- const warnings = (_warnings = response.warnings) !== null && _warnings !== void 0 ? _warnings : [];
61
- var ref2;
62
- const warningMessage = (ref2 = warnings[0]) !== null && ref2 !== void 0 ? ref2 : '';
75
+ var _response_warnings;
76
+ const warnings = (_response_warnings = response.warnings) !== null && _response_warnings !== void 0 ? _response_warnings : [];
77
+ var _warnings_;
78
+ const warningMessage = (_warnings_ = warnings[0]) !== null && _warnings_ !== void 0 ? _warnings_ : '';
63
79
  if (warningMessage !== '') {
64
80
  notices.push({
65
81
  type: 'warning',
@@ -77,7 +93,7 @@ export const getTimeSeriesData = async (spec, context)=>{
77
93
  stepMs: step * 1000,
78
94
  series: result.map((value)=>{
79
95
  const { metric , values } = value;
80
- // Account for series_name_format from query editor when determining name to show in legend, tooltip, etc.
96
+ // Account for seriesNameFormat from query editor when determining name to show in legend, tooltip, etc.
81
97
  const { name , formattedName } = getFormattedPrometheusSeriesName(query, metric, seriesNameFormat);
82
98
  return {
83
99
  name,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/plugins/prometheus-time-series-query/get-time-series-data.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 { Notice, TimeSeriesData } from '@perses-dev/core';\nimport { TimeSeriesQueryPlugin, replaceTemplateVariables } from '@perses-dev/plugin-system';\nimport { fromUnixTime } from 'date-fns';\nimport {\n parseValueTuple,\n PrometheusClient,\n getDurationStringSeconds,\n getPrometheusTimeRange,\n getRangeStep,\n DEFAULT_PROM,\n} from '../../model';\nimport { getFormattedPrometheusSeriesName } from '../../utils';\nimport { PrometheusTimeSeriesQuerySpec } from './time-series-query-model';\n\nexport const getTimeSeriesData: TimeSeriesQueryPlugin<PrometheusTimeSeriesQuerySpec>['getTimeSeriesData'] = async (\n spec,\n context\n) => {\n if (spec.query === undefined || spec.query === null || spec.query === '') {\n // Do not make a request to the backend, instead return an empty TimeSeriesData\n return { series: [] };\n }\n\n const minStep = getDurationStringSeconds(spec.min_step);\n const timeRange = getPrometheusTimeRange(context.timeRange);\n const step = getRangeStep(timeRange, minStep, undefined, context.suggestedStepMs);\n\n // Align the time range so that it's a multiple of the step\n let { start, end } = timeRange;\n const utcOffsetSec = new Date().getTimezoneOffset() * 60;\n\n const alignedEnd = Math.floor((end + utcOffsetSec) / step) * step - utcOffsetSec;\n const alignedStart = Math.floor((start + utcOffsetSec) / step) * step - utcOffsetSec;\n start = alignedStart;\n end = alignedEnd;\n\n // Replace template variable placeholders in PromQL query\n let query = spec.query.replace('$__rate_interval', `15s`);\n query = replaceTemplateVariables(query, context.variableState);\n\n let seriesNameFormat = spec.series_name_format;\n // if series name format is defined, replace template variable placeholders in series name format\n if (seriesNameFormat) {\n seriesNameFormat = replaceTemplateVariables(seriesNameFormat, context.variableState);\n }\n\n // Get the datasource, using the default Prom Datasource if one isn't specified in the query\n const client: PrometheusClient = await context.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);\n\n // Make the request to Prom\n const response = await client.rangeQuery({\n query,\n start,\n end,\n step,\n });\n\n // TODO: What about error responses from Prom that have a response body?\n const result = response.data?.result ?? [];\n\n // 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: result.map((value) => {\n const { metric, values } = value;\n\n // Account for series_name_format from query editor when determining name to show in legend, tooltip, etc.\n const { name, formattedName } = getFormattedPrometheusSeriesName(query, metric, seriesNameFormat);\n\n return {\n name,\n values: values.map(parseValueTuple),\n formattedName,\n labels: metric,\n };\n }),\n metadata: {\n notices,\n executedQueryString: query,\n },\n };\n\n return chartData;\n};\n"],"names":["replaceTemplateVariables","fromUnixTime","parseValueTuple","getDurationStringSeconds","getPrometheusTimeRange","getRangeStep","DEFAULT_PROM","getFormattedPrometheusSeriesName","getTimeSeriesData","spec","context","response","query","undefined","series","minStep","min_step","timeRange","step","suggestedStepMs","start","end","utcOffsetSec","Date","getTimezoneOffset","alignedEnd","Math","floor","alignedStart","replace","variableState","seriesNameFormat","series_name_format","client","datasourceStore","getDatasourceClient","datasource","rangeQuery","result","data","notices","status","warnings","warningMessage","push","type","message","chartData","stepMs","map","value","metric","values","name","formattedName","labels","metadata","executedQueryString"],"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;AAGj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AAC+B,QAAQ,cAAjB/B,SAAiB,cAAjBA,SAAiB,GAAI,EAAE,AAAC;YAClB+B,IAAW;QAAlC,MAAMC,cAAc,GAAGD,CAAAA,IAAW,GAAXA,QAAQ,CAAC,CAAC,CAAC,cAAXA,IAAW,cAAXA,IAAW,GAAI,EAAE,AAAC;QACzC,IAAIC,cAAc,KAAK,EAAE,EAAE;YACzBH,OAAO,CAACI,IAAI,CAAC;gBACXC,IAAI,EAAE,SAAS;gBACfC,OAAO,EAAEH,cAAc;aACxB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,qBAAqB;IACrB,MAAMI,SAAS,GAAmB;QAChC,gEAAgE;QAChE9B,SAAS,EAAE;YAAEG,KAAK,EAAEnB,YAAY,CAACmB,KAAK,CAAC;YAAEC,GAAG,EAAEpB,YAAY,CAACoB,GAAG,CAAC;SAAE;QACjE2B,MAAM,EAAE9B,IAAI,GAAG,IAAI;QAEnBJ,MAAM,EAAEwB,MAAM,CAACW,GAAG,CAAC,CAACC,KAAK,GAAK;YAC5B,MAAM,EAAEC,MAAM,CAAA,EAAEC,MAAM,CAAA,EAAE,GAAGF,KAAK,AAAC;YAEjC,0GAA0G;YAC1G,MAAM,EAAEG,IAAI,CAAA,EAAEC,aAAa,CAAA,EAAE,GAAG/C,gCAAgC,CAACK,KAAK,EAAEuC,MAAM,EAAEpB,gBAAgB,CAAC,AAAC;YAElG,OAAO;gBACLsB,IAAI;gBACJD,MAAM,EAAEA,MAAM,CAACH,GAAG,CAAC/C,eAAe,CAAC;gBACnCoD,aAAa;gBACbC,MAAM,EAAEJ,MAAM;aACf,CAAC;QACJ,CAAC,CAAC;QACFK,QAAQ,EAAE;YACRhB,OAAO;YACPiB,mBAAmB,EAAE7C,KAAK;SAC3B;KACF,AAAC;IAEF,OAAOmC,SAAS,CAAC;AACnB,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/plugins/prometheus-time-series-query/get-time-series-data.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 {\n DatasourceSpec,\n formatDuration,\n msToPrometheusDuration,\n Notice,\n parseDurationString,\n TimeSeriesData,\n} from '@perses-dev/core';\nimport { TimeSeriesQueryPlugin, replaceTemplateVariables, replaceTemplateVariable } 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} from '../../model';\nimport { getFormattedPrometheusSeriesName } from '../../utils';\nimport { DEFAULT_SCRAPE_INTERVAL, PrometheusDatasourceSpec } from '../PrometheusDatasourceEditor';\nimport { PrometheusTimeSeriesQuerySpec } from './time-series-query-model';\n\nexport const getTimeSeriesData: TimeSeriesQueryPlugin<PrometheusTimeSeriesQuerySpec>['getTimeSeriesData'] = async (\n spec,\n context\n) => {\n if (spec.query === undefined || spec.query === null || spec.query === '') {\n // Do not make a request to the backend, instead return an empty TimeSeriesData\n return { series: [] };\n }\n\n const datasource = (await context.datasourceStore.getDatasource(\n spec.datasource ?? DEFAULT_PROM\n )) as DatasourceSpec<PrometheusDatasourceSpec>;\n const datasourceScrapeInterval = Math.trunc(\n milliseconds(parseDurationString(datasource.plugin.spec.scrapeInterval ?? DEFAULT_SCRAPE_INTERVAL)) / 1000\n );\n\n const minStep = getDurationStringSeconds(spec.minStep) ?? datasourceScrapeInterval;\n const timeRange = getPrometheusTimeRange(context.timeRange);\n const step = getRangeStep(timeRange, minStep, undefined, context.suggestedStepMs); // TODO: resolution\n\n // Align the time range so that it's a multiple of the step\n let { start, end } = timeRange;\n const utcOffsetSec = new Date().getTimezoneOffset() * 60;\n\n const alignedEnd = Math.floor((end + utcOffsetSec) / step) * step - utcOffsetSec;\n const alignedStart = Math.floor((start + utcOffsetSec) / step) * step - utcOffsetSec;\n start = alignedStart;\n end = alignedEnd;\n\n // Replace template variable placeholders in PromQL query\n const intervalMs = context.suggestedStepMs ?? step * 1000; // Step is in seconds\n let query = replaceTemplateVariable(spec.query, '__interval_ms', intervalMs.toString());\n query = replaceTemplateVariable(spec.query, '__interval', formatDuration(msToPrometheusDuration(intervalMs)));\n\n const scrapeIntervalMs = minStep * 1000;\n // The $__rate_interval variable is meant to be used in the rate function.\n // It is defined as max($__interval + Scrape interval, 4 * Scrape interval), where Scrape interval is the Min step setting (a setting per PromQL query),\n // if any is set, and otherwise the Scrape interval as set in the Prometheus datasource\n const rateIntervalMs = Math.max(intervalMs + scrapeIntervalMs, 4 * scrapeIntervalMs);\n query = replaceTemplateVariable(query, '__rate_interval', formatDuration(msToPrometheusDuration(rateIntervalMs)));\n query = replaceTemplateVariables(query, context.variableState);\n\n let seriesNameFormat = spec.seriesNameFormat;\n // if series name format is defined, replace template variable placeholders in series name format\n if (seriesNameFormat) {\n seriesNameFormat = replaceTemplateVariables(seriesNameFormat, context.variableState);\n }\n\n // Get the datasource, using the default Prom Datasource if one isn't specified in the query\n const client: PrometheusClient = await context.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);\n\n // Make the request to Prom\n const response = await client.rangeQuery({\n query,\n start,\n end,\n step,\n });\n\n // TODO: What about error responses from Prom that have a response body?\n const result = response.data?.result ?? [];\n\n // 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: result.map((value) => {\n const { metric, values } = value;\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 return {\n name,\n values: values.map(parseValueTuple),\n formattedName,\n labels: metric,\n };\n }),\n metadata: {\n notices,\n executedQueryString: query,\n },\n };\n\n return chartData;\n};\n"],"names":["formatDuration","msToPrometheusDuration","parseDurationString","replaceTemplateVariables","replaceTemplateVariable","fromUnixTime","milliseconds","parseValueTuple","getDurationStringSeconds","getPrometheusTimeRange","getRangeStep","DEFAULT_PROM","getFormattedPrometheusSeriesName","DEFAULT_SCRAPE_INTERVAL","getTimeSeriesData","spec","context","response","query","undefined","series","datasource","datasourceStore","getDatasource","datasourceScrapeInterval","Math","trunc","plugin","scrapeInterval","minStep","timeRange","step","suggestedStepMs","start","end","utcOffsetSec","Date","getTimezoneOffset","alignedEnd","floor","alignedStart","intervalMs","toString","scrapeIntervalMs","rateIntervalMs","max","variableState","seriesNameFormat","client","getDatasourceClient","rangeQuery","result","data","notices","status","warnings","warningMessage","push","type","message","chartData","stepMs","map","value","metric","values","name","formattedName","labels","metadata","executedQueryString"],"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,SAEEA,cAAc,EACdC,sBAAsB,EAEtBC,mBAAmB,QAEd,mBAAmB;AAC1B,SAAgCC,wBAAwB,EAAEC,uBAAuB,QAAQ,4BAA4B;AACrH,SAASC,YAAY,EAAEC,YAAY,QAAQ,WAAW;AACtD,SACEC,eAAe,EAEfC,wBAAwB,EACxBC,sBAAsB,EACtBC,YAAY,EACZC,YAAY,QACP,cAAc;AACrB,SAASC,gCAAgC,QAAQ,cAAc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B,OAAOW,IAAI,CAACC;YAClB,MAAM,EAAEC,OAAM,EAAEC,OAAM,EAAE,GAAGF;YAE3B,wGAAwG;YACxG,MAAM,EAAEG,KAAI,EAAEC,cAAa,EAAE,GAAGvD,iCAAiCM,OAAO8C,QAAQjB;YAEhF,OAAO;gBACLmB;gBACAD,QAAQA,OAAOH,IAAIvD;gBACnB4D;gBACAC,QAAQJ;YACV;QACF;QACAK,UAAU;YACRhB;YACAiB,qBAAqBpD;QACvB;IACF;IAEA,OAAO0C;AACT,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/plugins/prometheus-time-series-query/index.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\nexport * from './PrometheusTimeSeriesQuery';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,6BAA6B,CAAC"}
1
+ {"version":3,"sources":["../../../src/plugins/prometheus-time-series-query/index.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\nexport * from './PrometheusTimeSeriesQuery';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,8BAA8B"}
@@ -1,4 +1,5 @@
1
1
  import { OptionsEditorProps } from '@perses-dev/plugin-system';
2
+ import { DurationString } from '@perses-dev/core';
2
3
  import { PrometheusTimeSeriesQuerySpec } from './time-series-query-model';
3
4
  export declare type PrometheusTimeSeriesQueryEditorProps = OptionsEditorProps<PrometheusTimeSeriesQuerySpec>;
4
5
  /**
@@ -13,11 +14,19 @@ export declare function useQueryState(props: PrometheusTimeSeriesQueryEditorProp
13
14
  handleQueryBlur: () => void;
14
15
  };
15
16
  /**
16
- * Hook to manage `series_name_format` state to ensure panel preview does not rerender until text input is blurred
17
+ * Hook to manage `seriesNameFormat` state to ensure panel preview does not rerender until text input is blurred
17
18
  */
18
19
  export declare function useFormatState(props: PrometheusTimeSeriesQueryEditorProps): {
19
20
  format: string | undefined;
20
21
  handleFormatChange: (e: string) => void;
21
22
  handleFormatBlur: () => void;
22
23
  };
24
+ /**
25
+ * Hook to manage `minStep` state to ensure panel preview does not rerender until text input is blurred
26
+ */
27
+ export declare function useMinStepState(props: PrometheusTimeSeriesQueryEditorProps): {
28
+ minStep: `${number}y` | `${number}w` | `${number}d` | `${number}h` | `${number}m` | `${number}s` | `${number}ms` | `${number}s${number}ms` | `${number}m${number}ms` | `${number}m${number}s` | `${number}m${number}s${number}ms` | `${number}h${number}ms` | `${number}h${number}s` | `${number}h${number}s${number}ms` | `${number}h${number}m` | `${number}h${number}m${number}ms` | `${number}h${number}m${number}s` | `${number}h${number}m${number}s${number}ms` | `${number}d${number}ms` | `${number}d${number}s` | `${number}d${number}s${number}ms` | `${number}d${number}m` | `${number}d${number}m${number}ms` | `${number}d${number}m${number}s` | `${number}d${number}m${number}s${number}ms` | `${number}d${number}h` | `${number}d${number}h${number}ms` | `${number}d${number}h${number}s` | `${number}d${number}h${number}s${number}ms` | `${number}d${number}h${number}m` | `${number}d${number}h${number}m${number}ms` | `${number}d${number}h${number}m${number}s` | `${number}d${number}h${number}m${number}s${number}ms` | `${number}w${number}ms` | `${number}w${number}s` | `${number}w${number}s${number}ms` | `${number}w${number}m` | `${number}w${number}m${number}ms` | `${number}w${number}m${number}s` | `${number}w${number}m${number}s${number}ms` | `${number}w${number}h` | `${number}w${number}h${number}ms` | `${number}w${number}h${number}s` | `${number}w${number}h${number}s${number}ms` | `${number}w${number}h${number}m` | `${number}w${number}h${number}m${number}ms` | `${number}w${number}h${number}m${number}s` | `${number}w${number}h${number}m${number}s${number}ms` | `${number}w${number}d` | `${number}w${number}d${number}ms` | `${number}w${number}d${number}s` | `${number}w${number}d${number}s${number}ms` | `${number}w${number}d${number}m` | `${number}w${number}d${number}m${number}ms` | `${number}w${number}d${number}m${number}s` | `${number}w${number}d${number}m${number}s${number}ms` | `${number}w${number}d${number}h` | `${number}w${number}d${number}h${number}ms` | `${number}w${number}d${number}h${number}s` | `${number}w${number}d${number}h${number}s${number}ms` | `${number}w${number}d${number}h${number}m` | `${number}w${number}d${number}h${number}m${number}ms` | `${number}w${number}d${number}h${number}m${number}s` | `${number}w${number}d${number}h${number}m${number}s${number}ms` | `${number}y${number}ms` | `${number}y${number}s` | `${number}y${number}s${number}ms` | `${number}y${number}m` | `${number}y${number}m${number}ms` | `${number}y${number}m${number}s` | `${number}y${number}m${number}s${number}ms` | `${number}y${number}h` | `${number}y${number}h${number}ms` | `${number}y${number}h${number}s` | `${number}y${number}h${number}s${number}ms` | `${number}y${number}h${number}m` | `${number}y${number}h${number}m${number}ms` | `${number}y${number}h${number}m${number}s` | `${number}y${number}h${number}m${number}s${number}ms` | `${number}y${number}d` | `${number}y${number}d${number}ms` | `${number}y${number}d${number}s` | `${number}y${number}d${number}s${number}ms` | `${number}y${number}d${number}m` | `${number}y${number}d${number}m${number}ms` | `${number}y${number}d${number}m${number}s` | `${number}y${number}d${number}m${number}s${number}ms` | `${number}y${number}d${number}h` | `${number}y${number}d${number}h${number}ms` | `${number}y${number}d${number}h${number}s` | `${number}y${number}d${number}h${number}s${number}ms` | `${number}y${number}d${number}h${number}m` | `${number}y${number}d${number}h${number}m${number}ms` | `${number}y${number}d${number}h${number}m${number}s` | `${number}y${number}d${number}h${number}m${number}s${number}ms` | `${number}y${number}w` | `${number}y${number}w${number}ms` | `${number}y${number}w${number}s` | `${number}y${number}w${number}s${number}ms` | `${number}y${number}w${number}m` | `${number}y${number}w${number}m${number}ms` | `${number}y${number}w${number}m${number}s` | `${number}y${number}w${number}m${number}s${number}ms` | `${number}y${number}w${number}h` | `${number}y${number}w${number}h${number}ms` | `${number}y${number}w${number}h${number}s` | `${number}y${number}w${number}h${number}s${number}ms` | `${number}y${number}w${number}h${number}m` | `${number}y${number}w${number}h${number}m${number}ms` | `${number}y${number}w${number}h${number}m${number}s` | `${number}y${number}w${number}h${number}m${number}s${number}ms` | `${number}y${number}w${number}d` | `${number}y${number}w${number}d${number}ms` | `${number}y${number}w${number}d${number}s` | `${number}y${number}w${number}d${number}s${number}ms` | `${number}y${number}w${number}d${number}m` | `${number}y${number}w${number}d${number}m${number}ms` | `${number}y${number}w${number}d${number}m${number}s` | `${number}y${number}w${number}d${number}m${number}s${number}ms` | `${number}y${number}w${number}d${number}h` | `${number}y${number}w${number}d${number}h${number}ms` | `${number}y${number}w${number}d${number}h${number}s` | `${number}y${number}w${number}d${number}h${number}s${number}ms` | `${number}y${number}w${number}d${number}h${number}m` | `${number}y${number}w${number}d${number}h${number}m${number}ms` | `${number}y${number}w${number}d${number}h${number}m${number}s` | `${number}y${number}w${number}d${number}h${number}m${number}s${number}ms` | undefined;
29
+ handleMinStepChange: (e: DurationString) => void;
30
+ handleMinStepBlur: () => void;
31
+ };
23
32
  //# sourceMappingURL=query-editor-model.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"query-editor-model.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-time-series-query/query-editor-model.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAE1E,oBAAY,oCAAoC,GAAG,kBAAkB,CAAC,6BAA6B,CAAC,CAAC;AAErG;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,oCAAoC;;2BAezC,MAAM;;EAgBrC;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,oCAAoC;;4BAYzC,MAAM;;EAetC"}
1
+ {"version":3,"file":"query-editor-model.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-time-series-query/query-editor-model.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAE1E,oBAAY,oCAAoC,GAAG,kBAAkB,CAAC,6BAA6B,CAAC,CAAC;AAErG;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,oCAAoC;;2BAezC,MAAM;;EAgBrC;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,oCAAoC;;4BAYzC,MAAM;;EAetC;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oCAAoC;;6BAYzC,cAAc;;EAe/C"}
@@ -47,25 +47,25 @@ import { produce } from 'immer';
47
47
  };
48
48
  }
49
49
  /**
50
- * Hook to manage `series_name_format` state to ensure panel preview does not rerender until text input is blurred
50
+ * Hook to manage `seriesNameFormat` state to ensure panel preview does not rerender until text input is blurred
51
51
  */ export function useFormatState(props) {
52
52
  const { onChange , value } = props;
53
53
  // TODO: reusable hook or helper util instead of duplicating from useQueryState
54
- const [format, setFormat] = useState(value.series_name_format);
55
- const [lastSyncedFormat, setLastSyncedFormat] = useState(value.series_name_format);
56
- if (value.series_name_format !== lastSyncedFormat) {
57
- setFormat(value.series_name_format);
58
- setLastSyncedFormat(value.series_name_format);
54
+ const [format, setFormat] = useState(value.seriesNameFormat);
55
+ const [lastSyncedFormat, setLastSyncedFormat] = useState(value.seriesNameFormat);
56
+ if (value.seriesNameFormat !== lastSyncedFormat) {
57
+ setFormat(value.seriesNameFormat);
58
+ setLastSyncedFormat(value.seriesNameFormat);
59
59
  }
60
60
  // Update our local state as the user types
61
61
  const handleFormatChange = (e)=>{
62
62
  setFormat(e);
63
63
  };
64
- // Propagate changes to the panel preview component when series_name_format TextField is blurred
64
+ // Propagate changes to the panel preview component when seriesNameFormat TextField is blurred
65
65
  const handleFormatBlur = ()=>{
66
66
  setLastSyncedFormat(format);
67
67
  onChange(produce(value, (draft)=>{
68
- draft.series_name_format = format;
68
+ draft.seriesNameFormat = format;
69
69
  }));
70
70
  };
71
71
  return {
@@ -74,5 +74,33 @@ import { produce } from 'immer';
74
74
  handleFormatBlur
75
75
  };
76
76
  }
77
+ /**
78
+ * Hook to manage `minStep` state to ensure panel preview does not rerender until text input is blurred
79
+ */ export function useMinStepState(props) {
80
+ const { onChange , value } = props;
81
+ // TODO: reusable hook or helper util instead of duplicating from useQueryState
82
+ const [minStep, setMinStep] = useState(value.minStep);
83
+ const [lastSyncedMinStep, setLastSyncedMinStep] = useState(value.minStep);
84
+ if (value.minStep !== lastSyncedMinStep) {
85
+ setMinStep(value.minStep);
86
+ setLastSyncedMinStep(value.minStep);
87
+ }
88
+ // Update our local state as the user types
89
+ const handleMinStepChange = (e)=>{
90
+ setMinStep(e);
91
+ };
92
+ // Propagate changes to the panel preview component when minStep TextField is blurred
93
+ const handleMinStepBlur = ()=>{
94
+ setLastSyncedMinStep(minStep);
95
+ onChange(produce(value, (draft)=>{
96
+ draft.minStep = minStep;
97
+ }));
98
+ };
99
+ return {
100
+ minStep,
101
+ handleMinStepChange,
102
+ handleMinStepBlur
103
+ };
104
+ }
77
105
 
78
106
  //# sourceMappingURL=query-editor-model.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/plugins/prometheus-time-series-query/query-editor-model.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState } from 'react';\nimport { produce } from 'immer';\nimport { OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { PrometheusTimeSeriesQuerySpec } from './time-series-query-model';\n\nexport type PrometheusTimeSeriesQueryEditorProps = OptionsEditorProps<PrometheusTimeSeriesQuerySpec>;\n\n/**\n * A hook for managing the `query` state in PrometheusTimeSeriesQuerySpec. Returns the `query` value, along with\n * `onChange` and `onBlur` event handlers to the input. Keeps a local copy of the user's input and only syncs those\n * changes with the overall spec value once the input is blurred to prevent re-running queries in the panel's preview\n * every time the user types.\n */\nexport function useQueryState(props: PrometheusTimeSeriesQueryEditorProps) {\n const { onChange, value } = props;\n\n // Local copy of the query's value\n const [query, setQuery] = useState(value.query);\n\n // This is basically \"getDerivedStateFromProps\" to make sure if spec's value changes external to this component,\n // we render with the latest value\n const [lastSyncedQuery, setLastSyncedQuery] = useState(value.query);\n if (value.query !== lastSyncedQuery) {\n setQuery(value.query);\n setLastSyncedQuery(value.query);\n }\n\n // Update our local state's copy as the user types\n const handleQueryChange = (e: string) => {\n setQuery(e);\n };\n\n // Propagate changes to the query's value when the input is blurred to avoid constantly re-running queries in the\n // PanelPreview\n const handleQueryBlur = () => {\n setLastSyncedQuery(query);\n onChange(\n produce(value, (draft) => {\n draft.query = query;\n })\n );\n };\n\n return { query, handleQueryChange, handleQueryBlur };\n}\n\n/**\n * Hook to manage `series_name_format` state to ensure panel preview does not rerender until text input is blurred\n */\nexport function useFormatState(props: PrometheusTimeSeriesQueryEditorProps) {\n const { onChange, value } = props;\n\n // TODO: reusable hook or helper util instead of duplicating from useQueryState\n const [format, setFormat] = useState(value.series_name_format);\n const [lastSyncedFormat, setLastSyncedFormat] = useState(value.series_name_format);\n if (value.series_name_format !== lastSyncedFormat) {\n setFormat(value.series_name_format);\n setLastSyncedFormat(value.series_name_format);\n }\n\n // Update our local state as the user types\n const handleFormatChange = (e: string) => {\n setFormat(e);\n };\n\n // Propagate changes to the panel preview component when series_name_format TextField is blurred\n const handleFormatBlur = () => {\n setLastSyncedFormat(format);\n onChange(\n produce(value, (draft) => {\n draft.series_name_format = format;\n })\n );\n };\n\n return { format, handleFormatChange, handleFormatBlur };\n}\n"],"names":["useState","produce","useQueryState","props","onChange","value","query","setQuery","lastSyncedQuery","setLastSyncedQuery","handleQueryChange","e","handleQueryBlur","draft","useFormatState","format","setFormat","series_name_format","lastSyncedFormat","setLastSyncedFormat","handleFormatChange","handleFormatBlur"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,OAAO,QAAQ,OAAO,CAAC;AAMhC;;;;;CAKC,GACD,OAAO,SAASC,aAAa,CAACC,KAA2C,EAAE;IACzE,MAAM,EAAEC,QAAQ,CAAA,EAAEC,KAAK,CAAA,EAAE,GAAGF,KAAK,AAAC;IAElC,kCAAkC;IAClC,MAAM,CAACG,KAAK,EAAEC,QAAQ,CAAC,GAAGP,Q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CAAC;QACpCE,mBAAmB,CAACd,KAAK,CAACY,kBAAkB,CAAC,CAAC;IAChD,CAAC;IAED,2CAA2C;IAC3C,MAAMG,kBAAkB,GAAG,CAACT,CAAS,GAAK;QACxCK,SAAS,CAACL,CAAC,CAAC,CAAC;IACf,CAAC,AAAC;IAEF,gGAAgG;IAChG,MAAMU,gBAAgB,GAAG,IAAM;QAC7BF,mBAAmB,CAACJ,MAAM,CAAC,CAAC;QAC5BX,QAAQ,CACNH,OAAO,CAACI,KAAK,EAAE,CAACQ,KAAK,GAAK;YACxBA,KAAK,CAACI,kBAAkB,GAAGF,MAAM,CAAC;QACpC,CAAC,CAAC,CACH,CAAC;IACJ,CAAC,AAAC;IAEF,OAAO;QAAEA,MAAM;QAAEK,kBAAkB;QAAEC,gBAAgB;KAAE,CAAC;AAC1D,CAAC"}
1
+ {"version":3,"sources":["../../../src/plugins/prometheus-time-series-query/query-editor-model.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState } from 'react';\nimport { produce } from 'immer';\nimport { OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { DurationString } from '@perses-dev/core';\nimport { PrometheusTimeSeriesQuerySpec } from './time-series-query-model';\n\nexport type PrometheusTimeSeriesQueryEditorProps = OptionsEditorProps<PrometheusTimeSeriesQuerySpec>;\n\n/**\n * A hook for managing the `query` state in PrometheusTimeSeriesQuerySpec. Returns the `query` value, along with\n * `onChange` and `onBlur` event handlers to the input. Keeps a local copy of the user's input and only syncs those\n * changes with the overall spec value once the input is blurred to prevent re-running queries in the panel's preview\n * every time the user types.\n */\nexport function useQueryState(props: PrometheusTimeSeriesQueryEditorProps) {\n const { onChange, value } = props;\n\n // Local copy of the query's value\n const [query, setQuery] = useState(value.query);\n\n // This is basically \"getDerivedStateFromProps\" to make sure if spec's value changes external to this component,\n // we render with the latest value\n const [lastSyncedQuery, setLastSyncedQuery] = useState(value.query);\n if (value.query !== lastSyncedQuery) {\n setQuery(value.query);\n setLastSyncedQuery(value.query);\n }\n\n // Update our local state's copy as the user types\n const handleQueryChange = (e: string) => {\n setQuery(e);\n };\n\n // Propagate changes to the query's value when the input is blurred to avoid constantly re-running queries in the\n // PanelPreview\n const handleQueryBlur = () => {\n setLastSyncedQuery(query);\n onChange(\n produce(value, (draft) => {\n draft.query = query;\n })\n );\n };\n\n return { query, handleQueryChange, handleQueryBlur };\n}\n\n/**\n * Hook to manage `seriesNameFormat` state to ensure panel preview does not rerender until text input is blurred\n */\nexport function useFormatState(props: PrometheusTimeSeriesQueryEditorProps) {\n const { onChange, value } = props;\n\n // TODO: reusable hook or helper util instead of duplicating from useQueryState\n const [format, setFormat] = useState(value.seriesNameFormat);\n const [lastSyncedFormat, setLastSyncedFormat] = useState(value.seriesNameFormat);\n if (value.seriesNameFormat !== lastSyncedFormat) {\n setFormat(value.seriesNameFormat);\n setLastSyncedFormat(value.seriesNameFormat);\n }\n\n // Update our local state as the user types\n const handleFormatChange = (e: string) => {\n setFormat(e);\n };\n\n // Propagate changes to the panel preview component when seriesNameFormat TextField is blurred\n const handleFormatBlur = () => {\n setLastSyncedFormat(format);\n onChange(\n produce(value, (draft) => {\n draft.seriesNameFormat = format;\n })\n );\n };\n\n return { format, handleFormatChange, handleFormatBlur };\n}\n\n/**\n * Hook to manage `minStep` state to ensure panel preview does not rerender until text input is blurred\n */\nexport function useMinStepState(props: PrometheusTimeSeriesQueryEditorProps) {\n const { onChange, value } = props;\n\n // TODO: reusable hook or helper util instead of duplicating from useQueryState\n const [minStep, setMinStep] = useState(value.minStep);\n const [lastSyncedMinStep, setLastSyncedMinStep] = useState(value.minStep);\n if (value.minStep !== lastSyncedMinStep) {\n setMinStep(value.minStep);\n setLastSyncedMinStep(value.minStep);\n }\n\n // Update our local state as the user types\n const handleMinStepChange = (e: DurationString) => {\n setMinStep(e);\n };\n\n // Propagate changes to the panel preview component when minStep TextField is blurred\n const handleMinStepBlur = () => {\n setLastSyncedMinStep(minStep);\n onChange(\n produce(value, (draft) => {\n draft.minStep = minStep;\n })\n );\n };\n\n return { minStep, handleMinStepChange, handleMinStepBlur };\n}\n"],"names":["useState","produce","useQueryState","props","onChange","value","query","setQuery","lastSyncedQuery","setLastSyncedQuery","handleQueryChange","e","handleQueryBlur","draft","useFormatState","format","setFormat","seriesNameFormat","lastSyncedFormat","setLastSyncedFormat","handleFormatChange","handleFormatBlur","useMinStepState","minStep","setMinStep","lastSyncedMinStep","setLastSyncedMinStep","handleMinStepChange","handleMinStepBlur"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,QAAQ,QAAQ,QAAQ;AACjC,SAASC,OAAO,QAAQ,QAAQ;AAOhC;;;;;CAKC,GACD,OAAO,SAASC,cAAcC,KAA2C;IACvE,MAAM,EAAEC,SAAQ,EAAEC,MAAK,EAAE,GAAGF;IAE5B,kCAAkC;IAClC,MAAM,CAACG,OAAOC,SAAS,GAAGP,SAASK,MAAMC;IAEzC,gHAAgH;IAChH,kCAAkC;IAClC,MAAM,CAACE,iBAAiBC,mBAAmB,GAAGT,SAASK,MAAMC;IAC7D,IAAID,MAAMC,UAAUE,iBAAiB;QACnCD,SAASF,MAAMC;QACfG,mBAAmBJ,MAAMC;IAC3B;IAEA,kDAAkD;IAClD,MAAMI,oBAAoB,CAACC;QACzBJ,SAASI;IACX;IAEA,iHAAiH;IACjH,eAAe;IACf,MAAMC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QAAEA;QAASI;QAAqBC;IAAkB;AAC3D"}
@@ -5,8 +5,8 @@ import { PrometheusDatasourceSelector, TemplateString } from '../../model';
5
5
  */
6
6
  export interface PrometheusTimeSeriesQuerySpec {
7
7
  query: TemplateString;
8
- series_name_format?: string;
9
- min_step?: DurationString;
8
+ seriesNameFormat?: string;
9
+ minStep?: DurationString;
10
10
  resolution?: number;
11
11
  datasource?: PrometheusDatasourceSelector;
12
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"time-series-query-model.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-time-series-query/time-series-query-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,4BAA4B,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE3E;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,KAAK,EAAE,cAAc,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,4BAA4B,CAAC;CAC3C"}
1
+ {"version":3,"file":"time-series-query-model.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-time-series-query/time-series-query-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,4BAA4B,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE3E;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,KAAK,EAAE,cAAc,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,4BAA4B,CAAC;CAC3C"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/plugins/prometheus-time-series-query/time-series-query-model.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DurationString } from '@perses-dev/core';\nimport { PrometheusDatasourceSelector, TemplateString } from '../../model';\n\n/**\n * The spec/options for the PrometheusTimeSeriesQuery plugin.\n */\nexport interface PrometheusTimeSeriesQuerySpec {\n query: TemplateString;\n series_name_format?: string;\n min_step?: DurationString;\n resolution?: number;\n datasource?: PrometheusDatasourceSelector;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,WAYC"}
1
+ {"version":3,"sources":["../../../src/plugins/prometheus-time-series-query/time-series-query-model.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DurationString } from '@perses-dev/core';\nimport { PrometheusDatasourceSelector, TemplateString } from '../../model';\n\n/**\n * The spec/options for the PrometheusTimeSeriesQuery plugin.\n */\nexport interface PrometheusTimeSeriesQuerySpec {\n query: TemplateString;\n seriesNameFormat?: string;\n minStep?: DurationString;\n resolution?: number;\n datasource?: PrometheusDatasourceSelector;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,WAYC"}