@perses-dev/prometheus-plugin 0.0.0-snapshot-time-range-height-80d08fc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/LICENSE +201 -0
  2. package/dist/cjs/index.js +34 -0
  3. package/dist/cjs/model/api-types.js +16 -0
  4. package/dist/cjs/model/index.js +34 -0
  5. package/dist/cjs/model/parse-sample-values.js +50 -0
  6. package/dist/cjs/model/prometheus-client.js +87 -0
  7. package/dist/cjs/model/prometheus-selectors.js +37 -0
  8. package/dist/cjs/model/templating.js +27 -0
  9. package/dist/cjs/model/time.js +54 -0
  10. package/dist/cjs/model/utils.js +69 -0
  11. package/dist/cjs/model/utils.test.js +126 -0
  12. package/dist/cjs/plugins/MatcherEditor.js +75 -0
  13. package/dist/cjs/plugins/prometheus-datasource.js +54 -0
  14. package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +36 -0
  15. package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +81 -0
  16. package/dist/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +84 -0
  17. package/dist/cjs/plugins/prometheus-time-series-query/index.js +28 -0
  18. package/dist/cjs/plugins/prometheus-time-series-query/query-editor-model.js +83 -0
  19. package/dist/cjs/plugins/prometheus-time-series-query/time-series-query-model.js +16 -0
  20. package/dist/cjs/plugins/prometheus-variables.js +218 -0
  21. package/dist/cjs/plugins/types.js +16 -0
  22. package/dist/cjs/plugins/variable.js +103 -0
  23. package/dist/cjs/test/setup-tests.js +17 -0
  24. package/dist/index.d.ts +6 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +21 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/model/api-types.d.ts +80 -0
  29. package/dist/model/api-types.d.ts.map +1 -0
  30. package/dist/model/api-types.js +15 -0
  31. package/dist/model/api-types.js.map +1 -0
  32. package/dist/model/index.d.ts +8 -0
  33. package/dist/model/index.d.ts.map +1 -0
  34. package/dist/model/index.js +21 -0
  35. package/dist/model/index.js.map +1 -0
  36. package/dist/model/parse-sample-values.d.ts +16 -0
  37. package/dist/model/parse-sample-values.d.ts.map +1 -0
  38. package/dist/model/parse-sample-values.js +44 -0
  39. package/dist/model/parse-sample-values.js.map +1 -0
  40. package/dist/model/prometheus-client.d.ts +27 -0
  41. package/dist/model/prometheus-client.d.ts.map +1 -0
  42. package/dist/model/prometheus-client.js +81 -0
  43. package/dist/model/prometheus-client.js.map +1 -0
  44. package/dist/model/prometheus-selectors.d.ts +22 -0
  45. package/dist/model/prometheus-selectors.d.ts.map +1 -0
  46. package/dist/model/prometheus-selectors.js +30 -0
  47. package/dist/model/prometheus-selectors.js.map +1 -0
  48. package/dist/model/templating.d.ts +6 -0
  49. package/dist/model/templating.d.ts.map +1 -0
  50. package/dist/model/templating.js +21 -0
  51. package/dist/model/templating.js.map +1 -0
  52. package/dist/model/time.d.ts +24 -0
  53. package/dist/model/time.d.ts.map +1 -0
  54. package/dist/model/time.js +49 -0
  55. package/dist/model/time.js.map +1 -0
  56. package/dist/model/utils.d.ts +14 -0
  57. package/dist/model/utils.d.ts.map +1 -0
  58. package/dist/model/utils.js +60 -0
  59. package/dist/model/utils.js.map +1 -0
  60. package/dist/model/utils.test.d.ts +2 -0
  61. package/dist/model/utils.test.d.ts.map +1 -0
  62. package/dist/model/utils.test.js +124 -0
  63. package/dist/model/utils.test.js.map +1 -0
  64. package/dist/plugins/MatcherEditor.d.ts +8 -0
  65. package/dist/plugins/MatcherEditor.d.ts.map +1 -0
  66. package/dist/plugins/MatcherEditor.js +64 -0
  67. package/dist/plugins/MatcherEditor.js.map +1 -0
  68. package/dist/plugins/prometheus-datasource.d.ts +7 -0
  69. package/dist/plugins/prometheus-datasource.d.ts.map +1 -0
  70. package/dist/plugins/prometheus-datasource.js +48 -0
  71. package/dist/plugins/prometheus-datasource.js.map +1 -0
  72. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.d.ts +7 -0
  73. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.d.ts.map +1 -0
  74. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +32 -0
  75. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js.map +1 -0
  76. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts +7 -0
  77. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -0
  78. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +77 -0
  79. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -0
  80. package/dist/plugins/prometheus-time-series-query/get-time-series-data.d.ts +4 -0
  81. package/dist/plugins/prometheus-time-series-query/get-time-series-data.d.ts.map +1 -0
  82. package/dist/plugins/prometheus-time-series-query/get-time-series-data.js +78 -0
  83. package/dist/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -0
  84. package/dist/plugins/prometheus-time-series-query/index.d.ts +2 -0
  85. package/dist/plugins/prometheus-time-series-query/index.d.ts.map +1 -0
  86. package/dist/plugins/prometheus-time-series-query/index.js +15 -0
  87. package/dist/plugins/prometheus-time-series-query/index.js.map +1 -0
  88. package/dist/plugins/prometheus-time-series-query/query-editor-model.d.ts +24 -0
  89. package/dist/plugins/prometheus-time-series-query/query-editor-model.d.ts.map +1 -0
  90. package/dist/plugins/prometheus-time-series-query/query-editor-model.js +78 -0
  91. package/dist/plugins/prometheus-time-series-query/query-editor-model.js.map +1 -0
  92. package/dist/plugins/prometheus-time-series-query/time-series-query-model.d.ts +13 -0
  93. package/dist/plugins/prometheus-time-series-query/time-series-query-model.d.ts.map +1 -0
  94. package/dist/plugins/prometheus-time-series-query/time-series-query-model.js +15 -0
  95. package/dist/plugins/prometheus-time-series-query/time-series-query-model.js.map +1 -0
  96. package/dist/plugins/prometheus-variables.d.ts +6 -0
  97. package/dist/plugins/prometheus-variables.d.ts.map +1 -0
  98. package/dist/plugins/prometheus-variables.js +205 -0
  99. package/dist/plugins/prometheus-variables.js.map +1 -0
  100. package/dist/plugins/types.d.ts +16 -0
  101. package/dist/plugins/types.d.ts.map +1 -0
  102. package/dist/plugins/types.js +15 -0
  103. package/dist/plugins/types.js.map +1 -0
  104. package/dist/plugins/variable.d.ts +8 -0
  105. package/dist/plugins/variable.d.ts.map +1 -0
  106. package/dist/plugins/variable.js +97 -0
  107. package/dist/plugins/variable.js.map +1 -0
  108. package/dist/test/setup-tests.d.ts +2 -0
  109. package/dist/test/setup-tests.d.ts.map +1 -0
  110. package/dist/test/setup-tests.js +15 -0
  111. package/dist/test/setup-tests.js.map +1 -0
  112. package/package.json +46 -0
  113. package/plugin.json +58 -0
@@ -0,0 +1,205 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { Stack, TextField } from '@mui/material';
15
+ import { replaceTemplateVariables, parseTemplateVariables, DEFAULT_PROM, getPrometheusTimeRange } from '../model';
16
+ import { MatcherEditor } from './MatcherEditor';
17
+ function PrometheusLabelValuesVariableEditor(props) {
18
+ var _matchers;
19
+ return /*#__PURE__*/ _jsxs(Stack, {
20
+ spacing: 1,
21
+ children: [
22
+ /*#__PURE__*/ _jsx(TextField, {
23
+ sx: {
24
+ mb: 1
25
+ },
26
+ label: "Label Name",
27
+ value: props.value.label_name,
28
+ onChange: (e)=>{
29
+ props.onChange({
30
+ ...props.value,
31
+ label_name: e.target.value
32
+ });
33
+ }
34
+ }),
35
+ /*#__PURE__*/ _jsx(MatcherEditor, {
36
+ matchers: (_matchers = props.value.matchers) !== null && _matchers !== void 0 ? _matchers : [],
37
+ onChange: (e)=>{
38
+ props.onChange({
39
+ ...props.value,
40
+ matchers: e
41
+ });
42
+ }
43
+ })
44
+ ]
45
+ });
46
+ }
47
+ function PrometheusLabelNamesVariableEditor(props) {
48
+ var _matchers;
49
+ return /*#__PURE__*/ _jsx(Stack, {
50
+ spacing: 1,
51
+ children: /*#__PURE__*/ _jsx(MatcherEditor, {
52
+ matchers: (_matchers = props.value.matchers) !== null && _matchers !== void 0 ? _matchers : [],
53
+ onChange: (e)=>{
54
+ props.onChange({
55
+ ...props.value,
56
+ matchers: e
57
+ });
58
+ }
59
+ })
60
+ });
61
+ }
62
+ function PrometheusPromQLVariableEditor(props) {
63
+ return /*#__PURE__*/ _jsxs(Stack, {
64
+ spacing: 1,
65
+ children: [
66
+ /*#__PURE__*/ _jsx(TextField, {
67
+ sx: {
68
+ mb: 1
69
+ },
70
+ label: "PromQL Expression",
71
+ value: props.value.expr,
72
+ onChange: (e)=>{
73
+ props.onChange({
74
+ ...props.value,
75
+ expr: e.target.value
76
+ });
77
+ }
78
+ }),
79
+ /*#__PURE__*/ _jsx(TextField, {
80
+ sx: {
81
+ mb: 1
82
+ },
83
+ label: "Label Name",
84
+ value: props.value.label_name,
85
+ onChange: (e)=>{
86
+ props.onChange({
87
+ ...props.value,
88
+ label_name: e.target.value
89
+ });
90
+ }
91
+ })
92
+ ]
93
+ });
94
+ }
95
+ function capturingMatrix(matrix, label_name) {
96
+ const captured = new Set();
97
+ for (const sample of matrix.result){
98
+ const value = sample.metric[label_name];
99
+ if (value !== undefined) {
100
+ captured.add(value);
101
+ }
102
+ }
103
+ return Array.from(captured.values());
104
+ }
105
+ function capturingVector(vector, label_name) {
106
+ const captured = new Set();
107
+ for (const sample of vector.result){
108
+ const value = sample.metric[label_name];
109
+ if (value !== undefined) {
110
+ captured.add(value);
111
+ }
112
+ }
113
+ return Array.from(captured.values());
114
+ }
115
+ /**
116
+ * Takes a list of strings and returns a list of VariableOptions
117
+ */ const stringArrayToVariableOptions = (values)=>{
118
+ if (!values) return [];
119
+ return values.map((value)=>({
120
+ value,
121
+ label: value
122
+ }));
123
+ };
124
+ export const PrometheusLabelNamesVariable = {
125
+ getVariableOptions: async (spec, ctx)=>{
126
+ var _datasource;
127
+ const client = await ctx.datasourceStore.getDatasourceClient((_datasource = spec.datasource) !== null && _datasource !== void 0 ? _datasource : DEFAULT_PROM);
128
+ const match = spec.matchers ? spec.matchers.map((m)=>replaceTemplateVariables(m, ctx.variables)) : undefined;
129
+ const timeRange = getPrometheusTimeRange(ctx.timeRange);
130
+ const { data: options } = await client.labelNames({
131
+ 'match[]': match,
132
+ ...timeRange
133
+ });
134
+ return {
135
+ data: stringArrayToVariableOptions(options)
136
+ };
137
+ },
138
+ dependsOn: (spec)=>{
139
+ var ref;
140
+ return {
141
+ variables: ((ref = spec.matchers) === null || ref === void 0 ? void 0 : ref.map((m)=>parseTemplateVariables(m)).flat()) || []
142
+ };
143
+ },
144
+ OptionsEditorComponent: PrometheusLabelNamesVariableEditor,
145
+ createInitialOptions: ()=>({})
146
+ };
147
+ export const PrometheusLabelValuesVariable = {
148
+ getVariableOptions: async (spec, ctx)=>{
149
+ const pluginDef = spec;
150
+ var _datasource;
151
+ const client = await ctx.datasourceStore.getDatasourceClient((_datasource = spec.datasource) !== null && _datasource !== void 0 ? _datasource : DEFAULT_PROM);
152
+ const match = pluginDef.matchers ? pluginDef.matchers.map((m)=>replaceTemplateVariables(m, ctx.variables)) : undefined;
153
+ const timeRange = getPrometheusTimeRange(ctx.timeRange);
154
+ const { data: options } = await client.labelValues({
155
+ labelName: replaceTemplateVariables(pluginDef.label_name, ctx.variables),
156
+ 'match[]': match,
157
+ ...timeRange
158
+ });
159
+ return {
160
+ data: stringArrayToVariableOptions(options)
161
+ };
162
+ },
163
+ dependsOn: (spec)=>{
164
+ var ref;
165
+ return {
166
+ variables: ((ref = spec.matchers) === null || ref === void 0 ? void 0 : ref.map((m)=>parseTemplateVariables(m)).flat().concat(parseTemplateVariables(spec.label_name))) || []
167
+ };
168
+ },
169
+ OptionsEditorComponent: PrometheusLabelValuesVariableEditor,
170
+ createInitialOptions: ()=>({
171
+ label_name: ''
172
+ })
173
+ };
174
+ export const PrometheusPromQLVariable = {
175
+ getVariableOptions: async (spec, ctx)=>{
176
+ var _datasource;
177
+ const client = await ctx.datasourceStore.getDatasourceClient((_datasource = spec.datasource) !== null && _datasource !== void 0 ? _datasource : DEFAULT_PROM);
178
+ // TODO we may want to manage a range query as well.
179
+ const { data: options } = await client.instantQuery({
180
+ query: replaceTemplateVariables(spec.expr, ctx.variables)
181
+ });
182
+ const labelName = replaceTemplateVariables(spec.label_name, ctx.variables);
183
+ let values = [];
184
+ if ((options === null || options === void 0 ? void 0 : options.resultType) === 'matrix') {
185
+ values = capturingMatrix(options, labelName);
186
+ } else if ((options === null || options === void 0 ? void 0 : options.resultType) === 'vector') {
187
+ values = capturingVector(options, labelName);
188
+ }
189
+ return {
190
+ data: stringArrayToVariableOptions(values)
191
+ };
192
+ },
193
+ dependsOn: (spec)=>{
194
+ return {
195
+ variables: parseTemplateVariables(spec.expr).concat(parseTemplateVariables(spec.label_name))
196
+ };
197
+ },
198
+ OptionsEditorComponent: PrometheusPromQLVariableEditor,
199
+ createInitialOptions: ()=>({
200
+ expr: '',
201
+ label_name: ''
202
+ })
203
+ };
204
+
205
+ //# sourceMappingURL=prometheus-variables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/plugins/prometheus-variables.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { VariablePlugin, VariableOption, OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { Stack, TextField } from '@mui/material';\nimport {\n replaceTemplateVariables,\n parseTemplateVariables,\n PrometheusClient,\n DEFAULT_PROM,\n getPrometheusTimeRange,\n MatrixData,\n VectorData,\n} from '../model';\nimport {\n PrometheusLabelNamesVariableOptions,\n PrometheusLabelValuesVariableOptions,\n PrometheusPromQLVariableOptions,\n} from './types';\nimport { MatcherEditor } from './MatcherEditor';\n\nfunction PrometheusLabelValuesVariableEditor(props: OptionsEditorProps<PrometheusLabelValuesVariableOptions>) {\n return (\n <Stack spacing={1}>\n <TextField\n sx={{ mb: 1 }}\n label=\"Label Name\"\n value={props.value.label_name}\n onChange={(e) => {\n props.onChange({ ...props.value, label_name: e.target.value });\n }}\n />\n <MatcherEditor\n matchers={props.value.matchers ?? []}\n onChange={(e) => {\n props.onChange({ ...props.value, matchers: e });\n }}\n />\n </Stack>\n );\n}\n\nfunction PrometheusLabelNamesVariableEditor(props: OptionsEditorProps<PrometheusLabelNamesVariableOptions>) {\n return (\n <Stack spacing={1}>\n <MatcherEditor\n matchers={props.value.matchers ?? []}\n onChange={(e) => {\n props.onChange({ ...props.value, matchers: e });\n }}\n />\n </Stack>\n );\n}\n\nfunction PrometheusPromQLVariableEditor(props: OptionsEditorProps<PrometheusPromQLVariableOptions>) {\n return (\n <Stack spacing={1}>\n <TextField\n sx={{ mb: 1 }}\n label=\"PromQL Expression\"\n value={props.value.expr}\n onChange={(e) => {\n props.onChange({ ...props.value, expr: e.target.value });\n }}\n />\n <TextField\n sx={{ mb: 1 }}\n label=\"Label Name\"\n value={props.value.label_name}\n onChange={(e) => {\n props.onChange({ ...props.value, label_name: e.target.value });\n }}\n />\n </Stack>\n );\n}\n\nfunction capturingMatrix(matrix: MatrixData, label_name: string): string[] {\n const captured = new Set<string>();\n for (const sample of matrix.result) {\n const value = sample.metric[label_name];\n if (value !== undefined) {\n captured.add(value);\n }\n }\n return Array.from(captured.values());\n}\n\nfunction capturingVector(vector: VectorData, label_name: string): string[] {\n const captured = new Set<string>();\n for (const sample of vector.result) {\n const value = sample.metric[label_name];\n if (value !== undefined) {\n captured.add(value);\n }\n }\n return Array.from(captured.values());\n}\n\n/**\n * Takes a list of strings and returns a list of VariableOptions\n */\nconst stringArrayToVariableOptions = (values?: string[]): VariableOption[] => {\n if (!values) return [];\n return values.map((value) => ({\n value,\n label: value,\n }));\n};\n\nexport const PrometheusLabelNamesVariable: VariablePlugin<PrometheusLabelNamesVariableOptions> = {\n getVariableOptions: async (spec, ctx) => {\n const client: PrometheusClient = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);\n const match = spec.matchers ? spec.matchers.map((m) => replaceTemplateVariables(m, ctx.variables)) : undefined;\n const timeRange = getPrometheusTimeRange(ctx.timeRange);\n\n const { data: options } = await client.labelNames({ 'match[]': match, ...timeRange });\n return {\n data: stringArrayToVariableOptions(options),\n };\n },\n dependsOn: (spec) => {\n return { variables: spec.matchers?.map((m) => parseTemplateVariables(m)).flat() || [] };\n },\n OptionsEditorComponent: PrometheusLabelNamesVariableEditor,\n createInitialOptions: () => ({}),\n};\n\nexport const PrometheusLabelValuesVariable: VariablePlugin<PrometheusLabelValuesVariableOptions> = {\n getVariableOptions: async (spec, ctx) => {\n const pluginDef = spec;\n const client: PrometheusClient = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);\n const match = pluginDef.matchers\n ? pluginDef.matchers.map((m) => replaceTemplateVariables(m, ctx.variables))\n : undefined;\n\n const timeRange = getPrometheusTimeRange(ctx.timeRange);\n\n const { data: options } = await client.labelValues({\n labelName: replaceTemplateVariables(pluginDef.label_name, ctx.variables),\n 'match[]': match,\n ...timeRange,\n });\n return {\n data: stringArrayToVariableOptions(options),\n };\n },\n dependsOn: (spec) => {\n return {\n variables:\n spec.matchers\n ?.map((m) => parseTemplateVariables(m))\n .flat()\n .concat(parseTemplateVariables(spec.label_name)) || [],\n };\n },\n OptionsEditorComponent: PrometheusLabelValuesVariableEditor,\n createInitialOptions: () => ({ label_name: '' }),\n};\n\nexport const PrometheusPromQLVariable: VariablePlugin<PrometheusPromQLVariableOptions> = {\n getVariableOptions: async (spec, ctx) => {\n const client: PrometheusClient = await ctx.datasourceStore.getDatasourceClient(spec.datasource ?? DEFAULT_PROM);\n // TODO we may want to manage a range query as well.\n const { data: options } = await client.instantQuery({\n query: replaceTemplateVariables(spec.expr, ctx.variables),\n });\n const labelName = replaceTemplateVariables(spec.label_name, ctx.variables);\n let values: string[] = [];\n if (options?.resultType === 'matrix') {\n values = capturingMatrix(options, labelName);\n } else if (options?.resultType === 'vector') {\n values = capturingVector(options, labelName);\n }\n\n return {\n data: stringArrayToVariableOptions(values),\n };\n },\n dependsOn: (spec) => {\n return { variables: parseTemplateVariables(spec.expr).concat(parseTemplateVariables(spec.label_name)) };\n },\n OptionsEditorComponent: PrometheusPromQLVariableEditor,\n createInitialOptions: () => ({ expr: '', label_name: '' }),\n};\n"],"names":["Stack","TextField","replaceTemplateVariables","parseTemplateVariables","DEFAULT_PROM","getPrometheusTimeRange","MatcherEditor","PrometheusLabelValuesVariableEditor","props","spacing","sx","mb","label","value","label_name","onChange","e","target","matchers","PrometheusLabelNamesVariableEditor","PrometheusPromQLVariableEditor","expr","capturingMatrix","matrix","captured","Set","sample","result","metric","undefined","add","Array","from","values","capturingVector","vector","stringArrayToVariableOptions","map","PrometheusLabelNamesVariable","getVariableOptions","spec","ctx","client","datasourceStore","getDatasourceClient","datasource","match","m","variables","timeRange","data","options","labelNames","dependsOn","flat","OptionsEditorComponent","createInitialOptions","PrometheusLabelValuesVariable","pluginDef","labelValues","labelName","concat","PrometheusPromQLVariable","instantQuery","query","resultType"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C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AA;YAAEnC,IAAI,EAAE,EAAE;YAAEP,UAAU,EAAE,EAAE;SAAE,CAAA,AAAC;CAC3D,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { PrometheusDatasourceSelector } from '../model';
2
+ export interface PrometheusVariableOptionsBase {
3
+ datasource?: PrometheusDatasourceSelector;
4
+ }
5
+ export declare type PrometheusLabelNamesVariableOptions = PrometheusVariableOptionsBase & {
6
+ matchers?: string[];
7
+ };
8
+ export declare type PrometheusLabelValuesVariableOptions = PrometheusVariableOptionsBase & {
9
+ label_name: string;
10
+ matchers?: string[];
11
+ };
12
+ export declare type PrometheusPromQLVariableOptions = PrometheusVariableOptionsBase & {
13
+ expr: string;
14
+ label_name: string;
15
+ };
16
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plugins/types.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAExD,MAAM,WAAW,6BAA6B;IAC5C,UAAU,CAAC,EAAE,4BAA4B,CAAC;CAC3C;AAED,oBAAY,mCAAmC,GAAG,6BAA6B,GAAG;IAChF,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF,oBAAY,oCAAoC,GAAG,6BAA6B,GAAG;IACjF,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF,oBAAY,+BAA+B,GAAG,6BAA6B,GAAG;IAE5E,IAAI,EAAE,MAAM,CAAC;IAGb,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export { };
14
+
15
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/plugins/types.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PrometheusDatasourceSelector } from '../model';\n\nexport interface PrometheusVariableOptionsBase {\n datasource?: PrometheusDatasourceSelector;\n}\n\nexport type PrometheusLabelNamesVariableOptions = PrometheusVariableOptionsBase & {\n matchers?: string[];\n};\n\nexport type PrometheusLabelValuesVariableOptions = PrometheusVariableOptionsBase & {\n label_name: string;\n matchers?: string[];\n};\n\nexport type PrometheusPromQLVariableOptions = PrometheusVariableOptionsBase & {\n // expr is the PromQL expression.\n expr: string;\n // label_name is the name of the label that will be used after the PromQL query is performed to select the label value.\n // Note: This field is not part of the Prometheus API.\n label_name: string;\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,WAqBE"}
@@ -0,0 +1,8 @@
1
+ import { VariablePlugin, VariableOption } from '@perses-dev/plugin-system';
2
+ declare type StaticListOption = string | VariableOption;
3
+ declare type StaticListVariableOptions = {
4
+ values: StaticListOption[];
5
+ };
6
+ export declare const StaticListVariable: VariablePlugin<StaticListVariableOptions>;
7
+ export {};
8
+ //# sourceMappingURL=variable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variable.d.ts","sourceRoot":"","sources":["../../src/plugins/variable.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAsB,MAAM,2BAA2B,CAAC;AAG/F,aAAK,gBAAgB,GAAG,MAAM,GAAG,cAAc,CAAC;AAEhD,aAAK,yBAAyB,GAAG;IAC/B,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B,CAAC;AA8CF,eAAO,MAAM,kBAAkB,EAAE,cAAc,CAAC,yBAAyB,CAiBxE,CAAC"}
@@ -0,0 +1,97 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { Autocomplete, TextField, Typography } from '@mui/material';
15
+ function StaticListVariableOptionEditor(props) {
16
+ const value = props.value.values.map((v)=>{
17
+ if (typeof v === 'string') {
18
+ return v;
19
+ } else {
20
+ return v.value;
21
+ }
22
+ });
23
+ const onChange = (__, value)=>{
24
+ props.onChange({
25
+ values: value.map((v)=>{
26
+ return {
27
+ value: v,
28
+ label: v
29
+ };
30
+ })
31
+ });
32
+ };
33
+ return /*#__PURE__*/ _jsxs("div", {
34
+ children: [
35
+ /*#__PURE__*/ _jsx(Autocomplete, {
36
+ onPaste: (e)=>{
37
+ // Append new values on paste
38
+ const v = e.clipboardData.getData('text/plain');
39
+ if (v) {
40
+ const values = v.split(',');
41
+ onChange(null, value.concat(values));
42
+ e.preventDefault();
43
+ }
44
+ },
45
+ multiple: true,
46
+ value: value,
47
+ onChange: onChange,
48
+ options: [],
49
+ freeSolo: true,
50
+ clearOnBlur: true,
51
+ renderInput: (params)=>/*#__PURE__*/ _jsx(TextField, {
52
+ ...params,
53
+ label: "Values",
54
+ placeholder: "Values"
55
+ })
56
+ }),
57
+ /*#__PURE__*/ _jsxs(Typography, {
58
+ variant: "caption",
59
+ children: [
60
+ "Type new value then press ",
61
+ `"`,
62
+ "Enter",
63
+ `"`,
64
+ " to add."
65
+ ]
66
+ })
67
+ ]
68
+ });
69
+ }
70
+ export const StaticListVariable = {
71
+ getVariableOptions: async (spec)=>{
72
+ var ref;
73
+ const values = (ref = spec.values) === null || ref === void 0 ? void 0 : ref.map((v)=>{
74
+ if (typeof v === 'string') {
75
+ return {
76
+ label: v,
77
+ value: v
78
+ };
79
+ }
80
+ return v;
81
+ });
82
+ return {
83
+ data: values
84
+ };
85
+ },
86
+ dependsOn: ()=>{
87
+ return {
88
+ variables: []
89
+ };
90
+ },
91
+ OptionsEditorComponent: StaticListVariableOptionEditor,
92
+ createInitialOptions: ()=>({
93
+ values: []
94
+ })
95
+ };
96
+
97
+ //# sourceMappingURL=variable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/plugins/variable.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { VariablePlugin, VariableOption, OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { Autocomplete, TextField, Typography } from '@mui/material';\n\ntype StaticListOption = string | VariableOption;\n\ntype StaticListVariableOptions = {\n values: StaticListOption[];\n};\n\nfunction StaticListVariableOptionEditor(props: OptionsEditorProps<StaticListVariableOptions>) {\n const value = props.value.values.map((v) => {\n if (typeof v === 'string') {\n return v;\n } else {\n return v.value;\n }\n });\n\n const onChange = (__: unknown, value: string[]) => {\n props.onChange({\n values: value.map((v) => {\n return { value: v, label: v };\n }),\n });\n };\n\n return (\n <div>\n <Autocomplete\n onPaste={(e) => {\n // Append new values on paste\n const v = e.clipboardData.getData('text/plain');\n if (v) {\n const values = v.split(',');\n onChange(null, value.concat(values));\n e.preventDefault();\n }\n }}\n multiple\n value={value}\n onChange={onChange}\n options={[]}\n freeSolo\n clearOnBlur\n renderInput={(params) => <TextField {...params} label=\"Values\" placeholder=\"Values\" />}\n />\n <Typography variant=\"caption\">\n Type new value then press {`\"`}Enter{`\"`} to add.\n </Typography>\n </div>\n );\n}\n\nexport const StaticListVariable: VariablePlugin<StaticListVariableOptions> = {\n getVariableOptions: async (spec) => {\n const values = spec.values?.map((v) => {\n if (typeof v === 'string') {\n return { label: v, value: v };\n }\n return v;\n });\n return {\n data: values,\n };\n },\n dependsOn: () => {\n return { variables: [] };\n },\n OptionsEditorComponent: StaticListVariableOptionEditor,\n createInitialOptions: () => ({ values: [] }),\n};\n"],"names":["Autocomplete","TextField","Typography","StaticListVariableOptionEditor","props","value","values","map","v","onChange","__","label","div","onPaste","e","clipboardData","getData","split","concat","preventDefault","multiple","options","freeSolo","clearOnBlur","renderInput","params","placeholder","variant","StaticListVariable","getVariableOptions","spec","data","dependsOn","variables","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;AAEjC;AACA,SAASA,YAAY,EAAEC,SAAS,EAAEC,UAAU,Q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,QAAQ;wBAACe,WAAW,EAAC,QAAQ;sBAAG;cACtF;0BACF,MAACxB,UAAU;gBAACyB,OAAO,EAAC,SAAS;;oBAAC,4BACF;oBAAC,CAAC,CAAC,CAAC;oBAAC,OAAK;oBAAC,CAAC,CAAC,CAAC;oBAAC,UAC3C;;cAAa;;MACT,CACN;AACJ,CAAC;AAED,OAAO,MAAMC,kBAAkB,GAA8C;IAC3EC,kBAAkB,EAAE,OAAOC,IAAI,GAAK;YACnBA,GAAW;QAA1B,MAAMxB,MAAM,GAAGwB,CAAAA,GAAW,GAAXA,IAAI,CAACxB,MAAM,cAAXwB,GAAW,WAAK,GAAhBA,KAAAA,CAAgB,GAAhBA,GAAW,CAAEvB,GAAG,CAAC,CAACC,CAAC,GAAK;YACrC,IAAI,OAAOA,CAAC,KAAK,QAAQ,EAAE;gBACzB,OAAO;oBAAEG,KAAK,EAAEH,CAAC;oBAAEH,KAAK,EAAEG,CAAC;iBAAE,CAAC;YAChC,CAAC;YACD,OAAOA,CAAC,CAAC;QACX,CAAC,CAAC,AAAC;QACH,OAAO;YACLuB,IAAI,EAAEzB,MAAM;SACb,CAAC;IACJ,CAAC;IACD0B,SAAS,EAAE,IAAM;QACf,OAAO;YAAEC,SAAS,EAAE,EAAE;SAAE,CAAC;IAC3B,CAAC;IACDC,sBAAsB,EAAE/B,8BAA8B;IACtDgC,oBAAoB,EAAE,IAAO,CAAA;YAAE7B,MAAM,EAAE,EAAE;SAAE,CAAA,AAAC;CAC7C,CAAC"}
@@ -0,0 +1,2 @@
1
+ import '@testing-library/jest-dom/extend-expect';
2
+ //# sourceMappingURL=setup-tests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../src/test/setup-tests.ts"],"names":[],"mappings":"AAaA,OAAO,yCAAyC,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import '@testing-library/jest-dom/extend-expect';
14
+
15
+ //# sourceMappingURL=setup-tests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/test/setup-tests.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport '@testing-library/jest-dom/extend-expect';\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,OAAO,yCAAyC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@perses-dev/prometheus-plugin",
3
+ "version": "0.0.0-snapshot-time-range-height-80d08fc",
4
+ "description": "Prometheus plugin for Perses",
5
+ "license": "Apache-2.0",
6
+ "homepage": "https://github.com/perses/perses/blob/main/README.md",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/perses/perses.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/perses/perses/issues"
13
+ },
14
+ "module": "dist/index.js",
15
+ "main": "dist/cjs/index.js",
16
+ "types": "dist/index.d.ts",
17
+ "sideEffects": false,
18
+ "scripts": {
19
+ "clean": "rimraf dist/",
20
+ "build": "concurrently \"npm:build:*\"",
21
+ "build:cjs": "swc ./src -d dist/cjs --config-file ../.cjs.swcrc",
22
+ "build:esm": "swc ./src -d dist --config-file ../.swcrc",
23
+ "build:types": "tsc --emitDeclarationOnly --declaration --preserveWatchOutput",
24
+ "start": "concurrently -P \"npm:build:* -- {*}\" -- --watch",
25
+ "test": "TZ=UTC jest",
26
+ "test:watch": "TZ=UTC jest --watch",
27
+ "lint": "eslint src --ext .ts,.tsx",
28
+ "lint:fix": "eslint --fix src --ext .ts,.tsx"
29
+ },
30
+ "dependencies": {
31
+ "@lezer/highlight": "^1.0.0",
32
+ "@lezer/lr": "^1.2.0",
33
+ "@perses-dev/core": "0.0.0-snapshot-time-range-height-80d08fc",
34
+ "@perses-dev/plugin-system": "0.0.0-snapshot-time-range-height-80d08fc",
35
+ "@prometheus-io/lezer-promql": "^0.37.0",
36
+ "date-fns": "^2.28.0",
37
+ "immer": "^9.0.15"
38
+ },
39
+ "peerDependencies": {
40
+ "react": "^17.0.2 || ^18.0.0"
41
+ },
42
+ "files": [
43
+ "dist",
44
+ "plugin.json"
45
+ ]
46
+ }
package/plugin.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "kind": "PluginModule",
3
+ "metadata": {
4
+ "name": "Prometheus"
5
+ },
6
+ "spec": {
7
+ "plugins": [
8
+ {
9
+ "pluginType": "Variable",
10
+ "kind": "StaticListVariable",
11
+ "display": {
12
+ "name": "[Static] Custom List",
13
+ "description": "Static list variables allow you to define an array of values"
14
+ }
15
+ },
16
+ {
17
+ "pluginType": "Variable",
18
+ "kind": "PrometheusLabelValuesVariable",
19
+ "display": {
20
+ "name": "[Prometheus] Label Values",
21
+ "description": ""
22
+ }
23
+ },
24
+ {
25
+ "pluginType": "Variable",
26
+ "kind": "PrometheusLabelNamesVariable",
27
+ "display": {
28
+ "name": "[Prometheus] Label Names",
29
+ "description": ""
30
+ }
31
+ },
32
+ {
33
+ "pluginType": "Variable",
34
+ "kind": "PrometheusPromQLVariable",
35
+ "display": {
36
+ "name": "[Prometheus] PromQL Result Values",
37
+ "description": ""
38
+ }
39
+ },
40
+ {
41
+ "pluginType": "TimeSeriesQuery",
42
+ "kind": "PrometheusTimeSeriesQuery",
43
+ "display": {
44
+ "name": "Prometheus Range Query",
45
+ "description": ""
46
+ }
47
+ },
48
+ {
49
+ "pluginType": "Datasource",
50
+ "kind": "PrometheusDatasource",
51
+ "display": {
52
+ "name": "Prometheus Datasource",
53
+ "description": ""
54
+ }
55
+ }
56
+ ]
57
+ }
58
+ }