@perses-dev/prometheus-plugin 0.0.0-snapshot-panel-extra-content-2-2767e21 → 0.0.0-snapshot-scatter-chart-embed-8efdfab
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/PromQL.js +9 -7
- package/dist/cjs/components/index.js +10 -8
- package/dist/cjs/index.js +33 -19
- package/dist/cjs/model/index.js +15 -13
- package/dist/cjs/model/parse-sample-values.js +6 -2
- package/dist/cjs/model/prometheus-client.js +40 -5
- package/dist/cjs/model/prometheus-selectors.js +12 -4
- package/dist/cjs/model/templating.js +7 -5
- package/dist/cjs/model/time.js +14 -8
- package/dist/cjs/plugins/MatcherEditor.js +13 -11
- package/dist/cjs/plugins/PrometheusDatasourceEditor.js +612 -0
- package/dist/cjs/plugins/prometheus-datasource.js +58 -6
- package/dist/cjs/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.js +88 -0
- package/dist/cjs/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.js +123 -0
- package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +10 -8
- package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +48 -50
- package/dist/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +41 -21
- package/dist/cjs/plugins/prometheus-time-series-query/index.js +10 -8
- package/dist/cjs/plugins/prometheus-time-series-query/query-editor-model.js +42 -9
- package/dist/cjs/plugins/prometheus-variables.js +60 -54
- package/dist/cjs/plugins/types.js +7 -0
- package/dist/cjs/plugins/variable.js +9 -7
- package/dist/cjs/utils/index.js +10 -8
- package/dist/cjs/utils/utils.js +12 -6
- package/dist/components/PromQL.js.map +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/model/index.js.map +1 -1
- package/dist/model/parse-sample-values.js.map +1 -1
- package/dist/model/prometheus-client.d.ts +4 -0
- package/dist/model/prometheus-client.d.ts.map +1 -1
- package/dist/model/prometheus-client.js +24 -0
- package/dist/model/prometheus-client.js.map +1 -1
- package/dist/model/prometheus-selectors.js.map +1 -1
- package/dist/model/templating.js.map +1 -1
- package/dist/model/time.js +1 -1
- package/dist/model/time.js.map +1 -1
- package/dist/plugins/MatcherEditor.js.map +1 -1
- package/dist/plugins/PrometheusDatasourceEditor.d.ts +9 -0
- package/dist/plugins/PrometheusDatasourceEditor.d.ts.map +1 -0
- package/dist/plugins/PrometheusDatasourceEditor.js +560 -0
- package/dist/plugins/PrometheusDatasourceEditor.js.map +1 -0
- package/dist/plugins/prometheus-datasource.d.ts +1 -5
- package/dist/plugins/prometheus-datasource.d.ts.map +1 -1
- package/dist/plugins/prometheus-datasource.js +56 -6
- package/dist/plugins/prometheus-datasource.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.d.ts +21 -0
- package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.d.ts.map +1 -0
- package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.js +80 -0
- package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.js.map +1 -0
- package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.d.ts +21 -0
- package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.d.ts.map +1 -0
- package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.js +115 -0
- package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.js.map +1 -0
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +1 -1
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +43 -47
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.d.ts.map +1 -1
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.js +34 -16
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/index.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/query-editor-model.d.ts +10 -1
- package/dist/plugins/prometheus-time-series-query/query-editor-model.d.ts.map +1 -1
- package/dist/plugins/prometheus-time-series-query/query-editor-model.js +36 -8
- package/dist/plugins/prometheus-time-series-query/query-editor-model.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/time-series-query-model.d.ts +2 -2
- package/dist/plugins/prometheus-time-series-query/time-series-query-model.d.ts.map +1 -1
- package/dist/plugins/prometheus-time-series-query/time-series-query-model.js.map +1 -1
- package/dist/plugins/prometheus-variables.js +27 -27
- package/dist/plugins/prometheus-variables.js.map +1 -1
- package/dist/plugins/types.d.ts +9 -2
- package/dist/plugins/types.d.ts.map +1 -1
- package/dist/plugins/types.js +1 -1
- package/dist/plugins/types.js.map +1 -1
- package/dist/plugins/variable.js +2 -2
- package/dist/plugins/variable.js.map +1 -1
- package/dist/test/setup-tests.js.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/utils.d.ts +1 -1
- package/dist/utils/utils.js +3 -3
- package/dist/utils/utils.js.map +1 -1
- package/package.json +6 -6
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { RequestHeaders } from '@perses-dev/core';
|
|
2
1
|
import { DatasourcePlugin } from '@perses-dev/plugin-system';
|
|
3
2
|
import { PrometheusClient } from '../model';
|
|
4
|
-
|
|
5
|
-
direct_url?: string;
|
|
6
|
-
headers?: RequestHeaders;
|
|
7
|
-
}
|
|
3
|
+
import { PrometheusDatasourceSpec } from './types';
|
|
8
4
|
export declare const PrometheusDatasource: DatasourcePlugin<PrometheusDatasourceSpec, PrometheusClient>;
|
|
9
5
|
//# sourceMappingURL=prometheus-datasource.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prometheus-datasource.d.ts","sourceRoot":"","sources":["../../src/plugins/prometheus-datasource.
|
|
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,EAAkE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5G,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AA8EnD,eAAO,MAAM,oBAAoB,EAAE,gBAAgB,CAAC,wBAAwB,EAAE,gBAAgB,CAK7F,CAAC"}
|
|
@@ -10,22 +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 { instantQuery, rangeQuery, labelNames, labelValues } from '../model';
|
|
13
|
+
import { healthCheck, instantQuery, rangeQuery, labelNames, labelValues } from '../model';
|
|
14
|
+
import { PrometheusDatasourceEditor } from './PrometheusDatasourceEditor';
|
|
14
15
|
/**
|
|
15
16
|
* Creates a PrometheusClient for a specific datasource spec.
|
|
16
17
|
*/ const createClient = (spec, options)=>{
|
|
17
|
-
const {
|
|
18
|
+
const { directUrl , proxy } = spec;
|
|
18
19
|
const { proxyUrl } = options;
|
|
19
20
|
// Use the direct URL if specified, but fallback to the proxyUrl by default if not specified
|
|
20
|
-
const datasourceUrl =
|
|
21
|
+
const datasourceUrl = directUrl !== null && directUrl !== void 0 ? directUrl : proxyUrl;
|
|
21
22
|
if (datasourceUrl === undefined) {
|
|
22
|
-
throw new Error('No URL specified for Prometheus client. You can use
|
|
23
|
+
throw new Error('No URL specified for Prometheus client. You can use directUrl in the spec to configure it.');
|
|
23
24
|
}
|
|
25
|
+
const specHeaders = proxy === null || proxy === void 0 ? void 0 : proxy.spec.headers;
|
|
24
26
|
// Could think about this becoming a class, although it definitely doesn't have to be
|
|
25
27
|
return {
|
|
26
28
|
options: {
|
|
27
29
|
datasourceUrl
|
|
28
30
|
},
|
|
31
|
+
healthCheck: healthCheck({
|
|
32
|
+
datasourceUrl,
|
|
33
|
+
headers: specHeaders
|
|
34
|
+
}),
|
|
29
35
|
instantQuery: (params, headers)=>instantQuery(params, {
|
|
30
36
|
datasourceUrl,
|
|
31
37
|
headers: headers !== null && headers !== void 0 ? headers : specHeaders
|
|
@@ -44,11 +50,55 @@ import { instantQuery, rangeQuery, labelNames, labelValues } from '../model';
|
|
|
44
50
|
})
|
|
45
51
|
};
|
|
46
52
|
};
|
|
53
|
+
const getBuiltinVariableDefinitions = ()=>{
|
|
54
|
+
return [
|
|
55
|
+
{
|
|
56
|
+
kind: 'BuiltinVariable',
|
|
57
|
+
spec: {
|
|
58
|
+
name: '__interval',
|
|
59
|
+
value: ()=>'$__interval',
|
|
60
|
+
source: 'Prometheus',
|
|
61
|
+
display: {
|
|
62
|
+
name: '__interval',
|
|
63
|
+
description: 'Interval that can be used to group by time in queries. When there are more data points than can be shown on a graph then queries can be made more efficient by grouping by a larger interval.',
|
|
64
|
+
hidden: true
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
kind: 'BuiltinVariable',
|
|
70
|
+
spec: {
|
|
71
|
+
name: '__interval_ms',
|
|
72
|
+
value: ()=>'$__interval_ms',
|
|
73
|
+
source: 'Prometheus',
|
|
74
|
+
display: {
|
|
75
|
+
name: '__interval_ms',
|
|
76
|
+
description: 'Interval in millisecond that can be used to group by time in queries. When there are more data points than can be shown on a graph then queries can be made more efficient by grouping by a larger interval.',
|
|
77
|
+
hidden: true
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
kind: 'BuiltinVariable',
|
|
83
|
+
spec: {
|
|
84
|
+
name: '__rate_interval',
|
|
85
|
+
value: ()=>'$__rate_interval',
|
|
86
|
+
source: 'Prometheus',
|
|
87
|
+
display: {
|
|
88
|
+
name: '__rate_interval',
|
|
89
|
+
description: "Interval at least four times the value of the scrape interval. It avoids problems specific to Prometheus when using 'rate' and 'increase' functions.",
|
|
90
|
+
hidden: true
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
];
|
|
95
|
+
};
|
|
47
96
|
export const PrometheusDatasource = {
|
|
48
97
|
createClient,
|
|
49
|
-
|
|
98
|
+
getBuiltinVariableDefinitions,
|
|
99
|
+
OptionsEditorComponent: PrometheusDatasourceEditor,
|
|
50
100
|
createInitialOptions: ()=>({
|
|
51
|
-
|
|
101
|
+
directUrl: ''
|
|
52
102
|
})
|
|
53
103
|
};
|
|
54
104
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugins/prometheus-datasource.
|
|
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 { healthCheck, instantQuery, rangeQuery, labelNames, labelValues, PrometheusClient } 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 };\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 'Interval that can be used to group by time in queries. When there are more data points than can be shown on a graph then queries can be made more efficient by grouping by a larger interval.',\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:\n 'Interval in millisecond that can be used to group by time in queries. When there are more data points than can be shown on a graph then queries can be made more efficient by grouping by a larger interval.',\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 \"Interval at least four times the value of the scrape interval. It avoids problems specific to Prometheus when using 'rate' and 'increase' functions.\",\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","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,SAASA,WAAW,EAAEC,YAAY,EAAEC,UAAU,EAAEC,UAAU,EAAEC,WAAW,QAA0B,WAAW;AAE5G,SAASC,0BAA0B,QAAQ,+BAA+B;AAE1E;;CAEC,GACD,MAAMC,eAA6F,CAACC,MAAMC;IACxG,MAAM,EAAEC,UAAS,EAAEC,MAAK,EAAE,GAAGH;IAC7B,MAAM,EAAEI,SAAQ,EAAE,GAAGH;IAErB,4FAA4F;IAC5F,MAAMI,gBAAgBH,sBAAAA,uBAAAA,YAAaE;IACnC,IAAIC,kBAAkBC,WAAW;QAC/B,MAAM,IAAIC,MAAM;IAClB;IAEA,MAAMC,cAAcL,kBAAAA,mBAAAA,KAAAA,IAAAA,MAAOH,KAAKS;IAEhC,qFAAqF;IACrF,OAAO;QACLR,SAAS;YACPI;QACF;QACAZ,aAAaA,YAAY;YAAEY;YAAeI,SAASD;QAAY;QAC/Dd,cAAc,CAACgB,QAAQD,UAAYf,aAAagB,QAAQ;gBAAEL;gBAAeI,SAASA,oBAAAA,qBAAAA,UAAWD;YAAY;QACzGb,YAAY,CAACe,QAAQD,UAAYd,WAAWe,QAAQ;gBAAEL;gBAAeI,SAASA,oBAAAA,qBAAAA,UAAWD;YAAY;QACrGZ,YAAY,CAACc,QAAQD,UAAYb,WAAWc,QAAQ;gBAAEL;gBAAeI,SAASA,oBAAAA,qBAAAA,UAAWD;YAAY;QACrGX,aAAa,CAACa,QAAQD,UAAYZ,YAAYa,QAAQ;gBAAEL;gBAAeI,SAASA,oBAAAA,qBAAAA,UAAWD;YAAY;IACzG;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,aACE;oBACFC,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"}
|
package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DatasourceSelector } from '@perses-dev/core/dist/model';
|
|
3
|
+
import { DurationString, PrometheusDatasourceSelector } from '../../model';
|
|
4
|
+
interface DashboardPrometheusTimeSeriesQueryEditorProps {
|
|
5
|
+
selectedDatasource: PrometheusDatasourceSelector;
|
|
6
|
+
handleDatasourceChange: (next: DatasourceSelector) => void;
|
|
7
|
+
promURL: string | undefined;
|
|
8
|
+
query: string;
|
|
9
|
+
handleQueryChange: (e: string) => void;
|
|
10
|
+
handleQueryBlur: () => void;
|
|
11
|
+
format: string | undefined;
|
|
12
|
+
handleFormatChange: (e: string) => void;
|
|
13
|
+
handleFormatBlur: () => void;
|
|
14
|
+
minStepPlaceholder: string;
|
|
15
|
+
minStep: string | undefined;
|
|
16
|
+
handleMinStepChange: (e: DurationString) => void;
|
|
17
|
+
handleMinStepBlur: () => void;
|
|
18
|
+
}
|
|
19
|
+
export declare function DashboardPrometheusTimeSeriesQueryEditor(props: DashboardPrometheusTimeSeriesQueryEditorProps): JSX.Element;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=DashboardPrometheusTimeSeriesQueryEditor.d.ts.map
|
package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DashboardPrometheusTimeSeriesQueryEditor.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAwB,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAGjG,UAAU,6CAA6C;IACrD,kBAAkB,EAAE,4BAA4B,CAAC;IACjD,sBAAsB,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC3D,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,kBAAkB,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,mBAAmB,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IACjD,iBAAiB,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED,wBAAgB,wCAAwC,CAAC,KAAK,EAAE,6CAA6C,eA2D5G"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { Stack, TextField, FormControl, InputLabel } from '@mui/material';
|
|
15
|
+
import { DatasourceSelect } from '@perses-dev/plugin-system';
|
|
16
|
+
import { PROM_DATASOURCE_KIND } from '../../model';
|
|
17
|
+
import { PromQLEditor } from '../../components';
|
|
18
|
+
export function DashboardPrometheusTimeSeriesQueryEditor(props) {
|
|
19
|
+
const { selectedDatasource , handleDatasourceChange , promURL , query , handleQueryChange , handleQueryBlur , format , handleFormatBlur , handleMinStepChange , handleFormatChange , handleMinStepBlur , minStepPlaceholder , minStep } = props;
|
|
20
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
21
|
+
spacing: 2,
|
|
22
|
+
children: [
|
|
23
|
+
/*#__PURE__*/ _jsxs(FormControl, {
|
|
24
|
+
margin: "dense",
|
|
25
|
+
fullWidth: false,
|
|
26
|
+
children: [
|
|
27
|
+
/*#__PURE__*/ _jsx(InputLabel, {
|
|
28
|
+
id: "prom-datasource-label",
|
|
29
|
+
children: "Prometheus Datasource"
|
|
30
|
+
}),
|
|
31
|
+
/*#__PURE__*/ _jsx(DatasourceSelect, {
|
|
32
|
+
datasourcePluginKind: PROM_DATASOURCE_KIND,
|
|
33
|
+
value: selectedDatasource,
|
|
34
|
+
onChange: handleDatasourceChange,
|
|
35
|
+
labelId: "prom-datasource-label",
|
|
36
|
+
label: "Prometheus Datasource"
|
|
37
|
+
})
|
|
38
|
+
]
|
|
39
|
+
}),
|
|
40
|
+
/*#__PURE__*/ _jsx(PromQLEditor, {
|
|
41
|
+
completeConfig: {
|
|
42
|
+
remote: {
|
|
43
|
+
url: promURL
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
value: query,
|
|
47
|
+
onChange: handleQueryChange,
|
|
48
|
+
onBlur: handleQueryBlur
|
|
49
|
+
}),
|
|
50
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
51
|
+
direction: "row",
|
|
52
|
+
spacing: 2,
|
|
53
|
+
children: [
|
|
54
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
55
|
+
fullWidth: true,
|
|
56
|
+
label: "Legend Name",
|
|
57
|
+
placeholder: "Tip: Use {{label_name}}. Example: {{instance}} will be replaced with values such as 'webserver-123' and 'webserver-456'.",
|
|
58
|
+
helperText: "Name for each series in the legend and the tooltip.",
|
|
59
|
+
value: format !== null && format !== void 0 ? format : '',
|
|
60
|
+
onChange: (e)=>handleFormatChange(e.target.value),
|
|
61
|
+
onBlur: handleFormatBlur
|
|
62
|
+
}),
|
|
63
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
64
|
+
label: "Min Step",
|
|
65
|
+
placeholder: minStepPlaceholder,
|
|
66
|
+
helperText: "Step parameter of the query. Used by $__interval and $__rate_interval too.",
|
|
67
|
+
value: minStep,
|
|
68
|
+
onChange: (e)=>handleMinStepChange(e.target.value),
|
|
69
|
+
onBlur: handleMinStepBlur,
|
|
70
|
+
sx: {
|
|
71
|
+
width: '250px'
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
]
|
|
75
|
+
})
|
|
76
|
+
]
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=DashboardPrometheusTimeSeriesQueryEditor.js.map
|
package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.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 { Stack, TextField, FormControl, InputLabel } from '@mui/material';\nimport { DatasourceSelect } from '@perses-dev/plugin-system';\nimport { DatasourceSelector } from '@perses-dev/core/dist/model';\nimport { DurationString, PROM_DATASOURCE_KIND, PrometheusDatasourceSelector } from '../../model';\nimport { PromQLEditor } from '../../components';\n\ninterface DashboardPrometheusTimeSeriesQueryEditorProps {\n selectedDatasource: PrometheusDatasourceSelector;\n handleDatasourceChange: (next: DatasourceSelector) => void;\n promURL: string | undefined;\n query: string;\n handleQueryChange: (e: string) => void;\n handleQueryBlur: () => void;\n format: string | undefined;\n handleFormatChange: (e: string) => void;\n handleFormatBlur: () => void;\n minStepPlaceholder: string;\n minStep: string | undefined;\n handleMinStepChange: (e: DurationString) => void;\n handleMinStepBlur: () => void;\n}\n\nexport function DashboardPrometheusTimeSeriesQueryEditor(props: DashboardPrometheusTimeSeriesQueryEditorProps) {\n const {\n selectedDatasource,\n handleDatasourceChange,\n promURL,\n query,\n handleQueryChange,\n handleQueryBlur,\n format,\n handleFormatBlur,\n handleMinStepChange,\n handleFormatChange,\n handleMinStepBlur,\n minStepPlaceholder,\n minStep,\n } = props;\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":["Stack","TextField","FormControl","InputLabel","DatasourceSelect","PROM_DATASOURCE_KIND","PromQLEditor","DashboardPrometheusTimeSeriesQueryEditor","props","selectedDatasource","handleDatasourceChange","promURL","query","handleQueryChange","handleQueryBlur","format","handleFormatBlur","handleMinStepChange","handleFormatChange","handleMinStepBlur","minStepPlaceholder","minStep","spacing","margin","fullWidth","id","datasourcePluginKind","value","onChange","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,KAAK,EAAEC,SAAS,EAAEC,WAAW,EAAEC,UAAU,QAAQ,gBAAgB;AAC1E,SAASC,gBAAgB,QAAQ,4BAA4B;AAE7D,SAAyBC,oBAAoB,QAAsC,cAAc;AACjG,SAASC,YAAY,QAAQ,mBAAmB;AAkBhD,OAAO,SAASC,yCAAyCC,KAAoD;IAC3G,MAAM,EACJC,mBAAkB,EAClBC,uBAAsB,EACtBC,QAAO,EACPC,MAAK,EACLC,kBAAiB,EACjBC,gBAAe,EACfC,OAAM,EACNC,iBAAgB,EAChBC,oBAAmB,EACnBC,mBAAkB,EAClBC,kBAAiB,EACjBC,mBAAkB,EAClBC,QAAO,EACR,GAAGb;IAEJ,qBACE,MAACR;QAAMsB,SAAS;;0BACd,MAACpB;gBAAYqB,QAAO;gBAAQC,WAAW;;kCAGrC,KAACrB;wBAAWsB,IAAG;kCAAwB;;kCACvC,KAACrB;wBACCsB,sBAAsBrB;wBACtBsB,OAAOlB;wBACPmB,UAAUlB;wBACVmB,SAAQ;wBACRC,OAAM;;;;0BAGV,KAACxB;gBACCyB,gBAAgB;oBAAEC,QAAQ;wBAAEC,KAAKtB;oBAAQ;gBAAE;gBAC3CgB,OAAOf;gBACPgB,UAAUf;gBACVqB,QAAQpB;;0BAEV,MAACd;gBAAMmC,WAAU;gBAAMb,SAAS;;kCAC9B,KAACrB;wBACCuB,SAAS;wBACTM,OAAM;wBACNM,aAAY;wBACZC,YAAW;wBACXV,OAAOZ,mBAAAA,oBAAAA,SAAU;wBACjBa,UAAU,CAACU,IAAMpB,mBAAmBoB,EAAEC,OAAOZ;wBAC7CO,QAAQlB;;kCAEV,KAACf;wBACC6B,OAAM;wBACNM,aAAahB;wBACbiB,YAAW;wBACXV,OAAON;wBACPO,UAAU,CAACU,IAAMrB,oBAAoBqB,EAAEC,OAAOZ;wBAC9CO,QAAQf;wBACRqB,IAAI;4BAAEC,OAAO;wBAAQ;;;;;;AAK/B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DatasourceSelector } from '@perses-dev/core/dist/model';
|
|
3
|
+
import { DurationString, PrometheusDatasourceSelector } from '../../model';
|
|
4
|
+
interface ExplorePrometheusTimeSeriesQueryEditorProps {
|
|
5
|
+
selectedDatasource: PrometheusDatasourceSelector;
|
|
6
|
+
handleDatasourceChange: (next: DatasourceSelector) => void;
|
|
7
|
+
promURL: string | undefined;
|
|
8
|
+
query: string;
|
|
9
|
+
handleQueryChange: (e: string) => void;
|
|
10
|
+
handleQueryBlur: () => void;
|
|
11
|
+
format: string | undefined;
|
|
12
|
+
handleFormatChange: (e: string) => void;
|
|
13
|
+
handleFormatBlur: () => void;
|
|
14
|
+
minStepPlaceholder: string;
|
|
15
|
+
minStep: string | undefined;
|
|
16
|
+
handleMinStepChange: (e: DurationString) => void;
|
|
17
|
+
handleMinStepBlur: () => void;
|
|
18
|
+
}
|
|
19
|
+
export declare function ExplorePrometheusTimeSeriesQueryEditor(props: ExplorePrometheusTimeSeriesQueryEditorProps): JSX.Element;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=ExplorePrometheusTimeSeriesQueryEditor.d.ts.map
|
package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExplorePrometheusTimeSeriesQueryEditor.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,kBAAkB,EAAmB,MAAM,6BAA6B,CAAC;AAClF,OAAO,EAAgB,cAAc,EAAwB,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAG/G,UAAU,2CAA2C;IACnD,kBAAkB,EAAE,4BAA4B,CAAC;IACjD,sBAAsB,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC3D,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,kBAAkB,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,mBAAmB,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IACjD,iBAAiB,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED,wBAAgB,sCAAsC,CAAC,KAAK,EAAE,2CAA2C,eA+ExG"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { Stack, TextField, FormControl, InputLabel, Grid } from '@mui/material';
|
|
15
|
+
import { DatasourceSelect, ProjectSelect, useProjectStore } from '@perses-dev/plugin-system';
|
|
16
|
+
import { DEFAULT_PROM, PROM_DATASOURCE_KIND } from '../../model';
|
|
17
|
+
import { PromQLEditor } from '../../components';
|
|
18
|
+
export function ExplorePrometheusTimeSeriesQueryEditor(props) {
|
|
19
|
+
const { selectedDatasource , handleDatasourceChange , promURL , query , handleQueryChange , handleQueryBlur , format , handleFormatBlur , handleMinStepChange , handleFormatChange , handleMinStepBlur , minStepPlaceholder , minStep } = props;
|
|
20
|
+
const { project , setProject } = useProjectStore();
|
|
21
|
+
const handleProjectChange = (next)=>{
|
|
22
|
+
handleDatasourceChange(DEFAULT_PROM);
|
|
23
|
+
return setProject(next);
|
|
24
|
+
};
|
|
25
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
26
|
+
spacing: 2,
|
|
27
|
+
children: [
|
|
28
|
+
/*#__PURE__*/ _jsxs(Grid, {
|
|
29
|
+
container: true,
|
|
30
|
+
spacing: 2,
|
|
31
|
+
children: [
|
|
32
|
+
/*#__PURE__*/ _jsx(Grid, {
|
|
33
|
+
item: true,
|
|
34
|
+
xs: 2,
|
|
35
|
+
children: /*#__PURE__*/ _jsxs(FormControl, {
|
|
36
|
+
margin: "dense",
|
|
37
|
+
fullWidth: true,
|
|
38
|
+
children: [
|
|
39
|
+
/*#__PURE__*/ _jsx(InputLabel, {
|
|
40
|
+
id: "project-label",
|
|
41
|
+
children: "Projects"
|
|
42
|
+
}),
|
|
43
|
+
/*#__PURE__*/ _jsx(ProjectSelect, {
|
|
44
|
+
labelId: "project-label",
|
|
45
|
+
label: "Projects",
|
|
46
|
+
value: project,
|
|
47
|
+
onChange: handleProjectChange
|
|
48
|
+
})
|
|
49
|
+
]
|
|
50
|
+
})
|
|
51
|
+
}),
|
|
52
|
+
/*#__PURE__*/ _jsx(Grid, {
|
|
53
|
+
item: true,
|
|
54
|
+
children: /*#__PURE__*/ _jsxs(FormControl, {
|
|
55
|
+
margin: "dense",
|
|
56
|
+
fullWidth: true,
|
|
57
|
+
children: [
|
|
58
|
+
/*#__PURE__*/ _jsx(InputLabel, {
|
|
59
|
+
id: "prom-datasource-label",
|
|
60
|
+
children: "Prometheus Datasource"
|
|
61
|
+
}),
|
|
62
|
+
/*#__PURE__*/ _jsx(DatasourceSelect, {
|
|
63
|
+
datasourcePluginKind: PROM_DATASOURCE_KIND,
|
|
64
|
+
value: selectedDatasource,
|
|
65
|
+
project: project.metadata.name,
|
|
66
|
+
onChange: handleDatasourceChange,
|
|
67
|
+
labelId: "prom-datasource-label",
|
|
68
|
+
label: "Prometheus Datasource"
|
|
69
|
+
})
|
|
70
|
+
]
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
]
|
|
74
|
+
}),
|
|
75
|
+
/*#__PURE__*/ _jsx(PromQLEditor, {
|
|
76
|
+
completeConfig: {
|
|
77
|
+
remote: {
|
|
78
|
+
url: promURL
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
value: query,
|
|
82
|
+
onChange: handleQueryChange,
|
|
83
|
+
onBlur: handleQueryBlur
|
|
84
|
+
}),
|
|
85
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
86
|
+
direction: "row",
|
|
87
|
+
spacing: 2,
|
|
88
|
+
children: [
|
|
89
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
90
|
+
fullWidth: true,
|
|
91
|
+
label: "Legend Name",
|
|
92
|
+
placeholder: "Tip: Use {{label_name}}. Example: {{instance}} will be replaced with values such as 'webserver-123' and 'webserver-456'.",
|
|
93
|
+
helperText: "Name for each series in the legend and the tooltip.",
|
|
94
|
+
value: format !== null && format !== void 0 ? format : '',
|
|
95
|
+
onChange: (e)=>handleFormatChange(e.target.value),
|
|
96
|
+
onBlur: handleFormatBlur
|
|
97
|
+
}),
|
|
98
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
99
|
+
label: "Min Step",
|
|
100
|
+
placeholder: minStepPlaceholder,
|
|
101
|
+
helperText: "Step parameter of the query. Used by $__interval and $__rate_interval too.",
|
|
102
|
+
value: minStep,
|
|
103
|
+
onChange: (e)=>handleMinStepChange(e.target.value),
|
|
104
|
+
onBlur: handleMinStepBlur,
|
|
105
|
+
sx: {
|
|
106
|
+
width: '250px'
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
})
|
|
111
|
+
]
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
//# sourceMappingURL=ExplorePrometheusTimeSeriesQueryEditor.js.map
|
package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.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 { Stack, TextField, FormControl, InputLabel, Grid } from '@mui/material';\nimport { DatasourceSelect, ProjectSelect, useProjectStore } from '@perses-dev/plugin-system';\nimport { DatasourceSelector, ProjectResource } from '@perses-dev/core/dist/model';\nimport { DEFAULT_PROM, DurationString, PROM_DATASOURCE_KIND, PrometheusDatasourceSelector } from '../../model';\nimport { PromQLEditor } from '../../components';\n\ninterface ExplorePrometheusTimeSeriesQueryEditorProps {\n selectedDatasource: PrometheusDatasourceSelector;\n handleDatasourceChange: (next: DatasourceSelector) => void;\n promURL: string | undefined;\n query: string;\n handleQueryChange: (e: string) => void;\n handleQueryBlur: () => void;\n format: string | undefined;\n handleFormatChange: (e: string) => void;\n handleFormatBlur: () => void;\n minStepPlaceholder: string;\n minStep: string | undefined;\n handleMinStepChange: (e: DurationString) => void;\n handleMinStepBlur: () => void;\n}\n\nexport function ExplorePrometheusTimeSeriesQueryEditor(props: ExplorePrometheusTimeSeriesQueryEditorProps) {\n const {\n selectedDatasource,\n handleDatasourceChange,\n promURL,\n query,\n handleQueryChange,\n handleQueryBlur,\n format,\n handleFormatBlur,\n handleMinStepChange,\n handleFormatChange,\n handleMinStepBlur,\n minStepPlaceholder,\n minStep,\n } = props;\n\n const { project, setProject } = useProjectStore();\n\n const handleProjectChange = (next: ProjectResource) => {\n handleDatasourceChange(DEFAULT_PROM);\n return setProject(next);\n };\n\n return (\n <Stack spacing={2}>\n <Grid container spacing={2}>\n <Grid item xs={2}>\n <FormControl margin=\"dense\" fullWidth={true}>\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=\"project-label\">Projects</InputLabel>\n <ProjectSelect labelId=\"project-label\" label=\"Projects\" value={project} onChange={handleProjectChange} />\n </FormControl>\n </Grid>\n <Grid item>\n <FormControl margin=\"dense\" fullWidth={true}>\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 project={project.metadata.name}\n onChange={handleDatasourceChange}\n labelId=\"prom-datasource-label\"\n label=\"Prometheus Datasource\"\n />\n </FormControl>\n </Grid>\n </Grid>\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":["Stack","TextField","FormControl","InputLabel","Grid","DatasourceSelect","ProjectSelect","useProjectStore","DEFAULT_PROM","PROM_DATASOURCE_KIND","PromQLEditor","ExplorePrometheusTimeSeriesQueryEditor","props","selectedDatasource","handleDatasourceChange","promURL","query","handleQueryChange","handleQueryBlur","format","handleFormatBlur","handleMinStepChange","handleFormatChange","handleMinStepBlur","minStepPlaceholder","minStep","project","setProject","handleProjectChange","next","spacing","container","item","xs","margin","fullWidth","id","labelId","label","value","onChange","datasourcePluginKind","metadata","name","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,KAAK,EAAEC,SAAS,EAAEC,WAAW,EAAEC,UAAU,EAAEC,IAAI,QAAQ,gBAAgB;AAChF,SAASC,gBAAgB,EAAEC,aAAa,EAAEC,eAAe,QAAQ,4BAA4B;AAE7F,SAASC,YAAY,EAAkBC,oBAAoB,QAAsC,cAAc;AAC/G,SAASC,YAAY,QAAQ,mBAAmB;AAkBhD,OAAO,SAASC,uCAAuCC,KAAkD;IACvG,MAAM,EACJC,mBAAkB,EAClBC,uBAAsB,EACtBC,QAAO,EACPC,MAAK,EACLC,kBAAiB,EACjBC,gBAAe,EACfC,OAAM,EACNC,iBAAgB,EAChBC,oBAAmB,EACnBC,mBAAkB,EAClBC,kBAAiB,EACjBC,mBAAkB,EAClBC,QAAO,EACR,GAAGb;IAEJ,MAAM,EAAEc,QAAO,EAAEC,WAAU,EAAE,GAAGpB;IAEhC,MAAMqB,sBAAsB,CAACC;QAC3Bf,uBAAuBN;QACvB,OAAOmB,WAAWE;IACpB;IAEA,qBACE,MAAC7B;QAAM8B,SAAS;;0BACd,MAAC1B;gBAAK2B,SAAS;gBAACD,SAAS;;kCACvB,KAAC1B;wBAAK4B,IAAI;wBAACC,IAAI;kCACb,cAAA,MAAC/B;4BAAYgC,QAAO;4BAAQC,WAAW;;8CAGrC,KAAChC;oCAAWiC,IAAG;8CAAgB;;8CAC/B,KAAC9B;oCAAc+B,SAAQ;oCAAgBC,OAAM;oCAAWC,OAAOb;oCAASc,UAAUZ;;;;;kCAGtF,KAACxB;wBAAK4B,IAAI;kCACR,cAAA,MAAC9B;4BAAYgC,QAAO;4BAAQC,WAAW;;8CAGrC,KAAChC;oCAAWiC,IAAG;8CAAwB;;8CACvC,KAAC/B;oCACCoC,sBAAsBhC;oCACtB8B,OAAO1B;oCACPa,SAASA,QAAQgB,SAASC;oCAC1BH,UAAU1B;oCACVuB,SAAQ;oCACRC,OAAM;;;;;;;0BAKd,KAAC5B;gBACCkC,gBAAgB;oBAAEC,QAAQ;wBAAEC,KAAK/B;oBAAQ;gBAAE;gBAC3CwB,OAAOvB;gBACPwB,UAAUvB;gBACV8B,QAAQ7B;;0BAEV,MAAClB;gBAAMgD,WAAU;gBAAMlB,SAAS;;kCAC9B,KAAC7B;wBACCkC,SAAS;wBACTG,OAAM;wBACNW,aAAY;wBACZC,YAAW;wBACXX,OAAOpB,mBAAAA,oBAAAA,SAAU;wBACjBqB,UAAU,CAACW,IAAM7B,mBAAmB6B,EAAEC,OAAOb;wBAC7CQ,QAAQ3B;;kCAEV,KAACnB;wBACCqC,OAAM;wBACNW,aAAazB;wBACb0B,YAAW;wBACXX,OAAOd;wBACPe,UAAU,CAACW,IAAM9B,oBAAoB8B,EAAEC,OAAOb;wBAC9CQ,QAAQxB;wBACR8B,IAAI;4BAAEC,OAAO;wBAAQ;;;;;;AAK/B"}
|
|
@@ -25,7 +25,7 @@ import { PrometheusTimeSeriesQueryEditor } from './PrometheusTimeSeriesQueryEdit
|
|
|
25
25
|
dependsOn: (spec)=>{
|
|
26
26
|
// Variables can be used in the query and/or in the legend format string
|
|
27
27
|
const queryVariables = parseTemplateVariables(spec.query);
|
|
28
|
-
const legendVariables = parseTemplateVariables(spec.
|
|
28
|
+
const legendVariables = parseTemplateVariables(spec.seriesNameFormat || '');
|
|
29
29
|
const allVariables = [
|
|
30
30
|
...new Set([
|
|
31
31
|
...queryVariables,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.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 { TimeSeriesQueryPlugin, parseTemplateVariables } from '@perses-dev/plugin-system';\nimport { getTimeSeriesData } from './get-time-series-data';\nimport { PrometheusTimeSeriesQueryEditor } from './PrometheusTimeSeriesQueryEditor';\nimport { PrometheusTimeSeriesQuerySpec } from './time-series-query-model';\n\n/**\n * The core Prometheus TimeSeriesQuery plugin for Perses.\n */\nexport const PrometheusTimeSeriesQuery: TimeSeriesQueryPlugin<PrometheusTimeSeriesQuerySpec> = {\n getTimeSeriesData,\n OptionsEditorComponent: PrometheusTimeSeriesQueryEditor,\n createInitialOptions: () => ({\n query: '',\n datasource: undefined,\n }),\n dependsOn: (spec) => {\n // Variables can be used in the query and/or in the legend format string\n const queryVariables = parseTemplateVariables(spec.query);\n const legendVariables = parseTemplateVariables(spec.
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.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 { TimeSeriesQueryPlugin, parseTemplateVariables } from '@perses-dev/plugin-system';\nimport { getTimeSeriesData } from './get-time-series-data';\nimport { PrometheusTimeSeriesQueryEditor } from './PrometheusTimeSeriesQueryEditor';\nimport { PrometheusTimeSeriesQuerySpec } from './time-series-query-model';\n\n/**\n * The core Prometheus TimeSeriesQuery plugin for Perses.\n */\nexport const PrometheusTimeSeriesQuery: TimeSeriesQueryPlugin<PrometheusTimeSeriesQuerySpec> = {\n getTimeSeriesData,\n OptionsEditorComponent: PrometheusTimeSeriesQueryEditor,\n createInitialOptions: () => ({\n query: '',\n datasource: undefined,\n }),\n dependsOn: (spec) => {\n // Variables can be used in the query and/or in the legend format string\n const queryVariables = parseTemplateVariables(spec.query);\n const legendVariables = parseTemplateVariables(spec.seriesNameFormat || '');\n const allVariables = [...new Set([...queryVariables, ...legendVariables])];\n return {\n variables: allVariables,\n };\n },\n};\n"],"names":["parseTemplateVariables","getTimeSeriesData","PrometheusTimeSeriesQueryEditor","PrometheusTimeSeriesQuery","OptionsEditorComponent","createInitialOptions","query","datasource","undefined","dependsOn","spec","queryVariables","legendVariables","seriesNameFormat","allVariables","Set","variables"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAAgCA,sBAAsB,QAAQ,4BAA4B;AAC1F,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,+BAA+B,QAAQ,oCAAoC;AAGpF;;CAEC,GACD,OAAO,MAAMC,4BAAkF;IAC7FF;IACAG,wBAAwBF;IACxBG,sBAAsB,IAAO,CAAA;YAC3BC,OAAO;YACPC,YAAYC;QACd,CAAA;IACAC,WAAW,CAACC;QACV,wEAAwE;QACxE,MAAMC,iBAAiBX,uBAAuBU,KAAKJ;QACnD,MAAMM,kBAAkBZ,uBAAuBU,KAAKG,oBAAoB;QACxE,MAAMC,eAAe;eAAI,IAAIC,IAAI;mBAAIJ;mBAAmBC;aAAgB;SAAE;QAC1E,OAAO;YACLI,WAAWF;QACb;IACF;AACF,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrometheusTimeSeriesQueryEditor.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"PrometheusTimeSeriesQueryEditor.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.tsx"],"names":[],"mappings":";AAiBA,OAAO,EACL,oCAAoC,EAIrC,MAAM,sBAAsB,CAAC;AAI9B;;GAEG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,oCAAoC,eAqE1F"}
|
|
@@ -10,23 +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 { jsx as _jsx
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { produce } from 'immer';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
15
|
+
import { useDatasource, useDatasourceClient } from '@perses-dev/plugin-system';
|
|
16
|
+
import { DEFAULT_PROM, isDefaultPromSelector, isPrometheusDatasourceSelector } from '../../model';
|
|
17
|
+
import { DEFAULT_SCRAPE_INTERVAL } from '../types';
|
|
18
|
+
import { useQueryState, useFormatState, useMinStepState } from './query-editor-model';
|
|
19
|
+
import { DashboardPrometheusTimeSeriesQueryEditor } from './DashboardPrometheusTimeSeriesQueryEditor';
|
|
20
|
+
import { ExplorePrometheusTimeSeriesQueryEditor } from './ExplorePrometheusTimeSeriesQueryEditor';
|
|
20
21
|
/**
|
|
21
22
|
* The options editor component for editing a PrometheusTimeSeriesQuery's spec.
|
|
22
23
|
*/ export function PrometheusTimeSeriesQueryEditor(props) {
|
|
23
|
-
const { onChange , value } = props;
|
|
24
|
+
const { onChange , value , isExplore } = props;
|
|
24
25
|
const { datasource } = value;
|
|
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)=>{
|
|
@@ -38,46 +43,37 @@ import { useQueryState, useFormatState } from './query-editor-model';
|
|
|
38
43
|
}
|
|
39
44
|
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
40
45
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
|
79
|
-
})
|
|
80
|
-
]
|
|
46
|
+
if (isExplore) {
|
|
47
|
+
return /*#__PURE__*/ _jsx(ExplorePrometheusTimeSeriesQueryEditor, {
|
|
48
|
+
selectedDatasource: selectedDatasource,
|
|
49
|
+
handleDatasourceChange: handleDatasourceChange,
|
|
50
|
+
promURL: promURL,
|
|
51
|
+
query: query,
|
|
52
|
+
handleQueryChange: handleQueryChange,
|
|
53
|
+
handleQueryBlur: handleQueryBlur,
|
|
54
|
+
format: format,
|
|
55
|
+
handleFormatChange: handleFormatChange,
|
|
56
|
+
handleFormatBlur: handleFormatBlur,
|
|
57
|
+
minStepPlaceholder: minStepPlaceholder,
|
|
58
|
+
minStep: minStep,
|
|
59
|
+
handleMinStepChange: handleMinStepChange,
|
|
60
|
+
handleMinStepBlur: handleMinStepBlur
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return /*#__PURE__*/ _jsx(DashboardPrometheusTimeSeriesQueryEditor, {
|
|
64
|
+
selectedDatasource: selectedDatasource,
|
|
65
|
+
handleDatasourceChange: handleDatasourceChange,
|
|
66
|
+
promURL: promURL,
|
|
67
|
+
query: query,
|
|
68
|
+
handleQueryChange: handleQueryChange,
|
|
69
|
+
handleQueryBlur: handleQueryBlur,
|
|
70
|
+
format: format,
|
|
71
|
+
handleFormatChange: handleFormatChange,
|
|
72
|
+
handleFormatBlur: handleFormatBlur,
|
|
73
|
+
minStepPlaceholder: minStepPlaceholder,
|
|
74
|
+
minStep: minStep,
|
|
75
|
+
handleMinStepChange: handleMinStepChange,
|
|
76
|
+
handleMinStepBlur: handleMinStepBlur
|
|
81
77
|
});
|
|
82
78
|
}
|
|
83
79
|
|