@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.
- package/LICENSE +201 -0
- package/dist/cjs/index.js +34 -0
- package/dist/cjs/model/api-types.js +16 -0
- package/dist/cjs/model/index.js +34 -0
- package/dist/cjs/model/parse-sample-values.js +50 -0
- package/dist/cjs/model/prometheus-client.js +87 -0
- package/dist/cjs/model/prometheus-selectors.js +37 -0
- package/dist/cjs/model/templating.js +27 -0
- package/dist/cjs/model/time.js +54 -0
- package/dist/cjs/model/utils.js +69 -0
- package/dist/cjs/model/utils.test.js +126 -0
- package/dist/cjs/plugins/MatcherEditor.js +75 -0
- package/dist/cjs/plugins/prometheus-datasource.js +54 -0
- package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +36 -0
- package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +81 -0
- package/dist/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +84 -0
- package/dist/cjs/plugins/prometheus-time-series-query/index.js +28 -0
- package/dist/cjs/plugins/prometheus-time-series-query/query-editor-model.js +83 -0
- package/dist/cjs/plugins/prometheus-time-series-query/time-series-query-model.js +16 -0
- package/dist/cjs/plugins/prometheus-variables.js +218 -0
- package/dist/cjs/plugins/types.js +16 -0
- package/dist/cjs/plugins/variable.js +103 -0
- package/dist/cjs/test/setup-tests.js +17 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/model/api-types.d.ts +80 -0
- package/dist/model/api-types.d.ts.map +1 -0
- package/dist/model/api-types.js +15 -0
- package/dist/model/api-types.js.map +1 -0
- package/dist/model/index.d.ts +8 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +21 -0
- package/dist/model/index.js.map +1 -0
- package/dist/model/parse-sample-values.d.ts +16 -0
- package/dist/model/parse-sample-values.d.ts.map +1 -0
- package/dist/model/parse-sample-values.js +44 -0
- package/dist/model/parse-sample-values.js.map +1 -0
- package/dist/model/prometheus-client.d.ts +27 -0
- package/dist/model/prometheus-client.d.ts.map +1 -0
- package/dist/model/prometheus-client.js +81 -0
- package/dist/model/prometheus-client.js.map +1 -0
- package/dist/model/prometheus-selectors.d.ts +22 -0
- package/dist/model/prometheus-selectors.d.ts.map +1 -0
- package/dist/model/prometheus-selectors.js +30 -0
- package/dist/model/prometheus-selectors.js.map +1 -0
- package/dist/model/templating.d.ts +6 -0
- package/dist/model/templating.d.ts.map +1 -0
- package/dist/model/templating.js +21 -0
- package/dist/model/templating.js.map +1 -0
- package/dist/model/time.d.ts +24 -0
- package/dist/model/time.d.ts.map +1 -0
- package/dist/model/time.js +49 -0
- package/dist/model/time.js.map +1 -0
- package/dist/model/utils.d.ts +14 -0
- package/dist/model/utils.d.ts.map +1 -0
- package/dist/model/utils.js +60 -0
- package/dist/model/utils.js.map +1 -0
- package/dist/model/utils.test.d.ts +2 -0
- package/dist/model/utils.test.d.ts.map +1 -0
- package/dist/model/utils.test.js +124 -0
- package/dist/model/utils.test.js.map +1 -0
- package/dist/plugins/MatcherEditor.d.ts +8 -0
- package/dist/plugins/MatcherEditor.d.ts.map +1 -0
- package/dist/plugins/MatcherEditor.js +64 -0
- package/dist/plugins/MatcherEditor.js.map +1 -0
- package/dist/plugins/prometheus-datasource.d.ts +7 -0
- package/dist/plugins/prometheus-datasource.d.ts.map +1 -0
- package/dist/plugins/prometheus-datasource.js +48 -0
- package/dist/plugins/prometheus-datasource.js.map +1 -0
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.d.ts +7 -0
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.d.ts.map +1 -0
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +32 -0
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js.map +1 -0
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts +7 -0
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -0
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +77 -0
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -0
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.d.ts +4 -0
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.d.ts.map +1 -0
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.js +78 -0
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -0
- package/dist/plugins/prometheus-time-series-query/index.d.ts +2 -0
- package/dist/plugins/prometheus-time-series-query/index.d.ts.map +1 -0
- package/dist/plugins/prometheus-time-series-query/index.js +15 -0
- package/dist/plugins/prometheus-time-series-query/index.js.map +1 -0
- package/dist/plugins/prometheus-time-series-query/query-editor-model.d.ts +24 -0
- package/dist/plugins/prometheus-time-series-query/query-editor-model.d.ts.map +1 -0
- package/dist/plugins/prometheus-time-series-query/query-editor-model.js +78 -0
- package/dist/plugins/prometheus-time-series-query/query-editor-model.js.map +1 -0
- package/dist/plugins/prometheus-time-series-query/time-series-query-model.d.ts +13 -0
- package/dist/plugins/prometheus-time-series-query/time-series-query-model.d.ts.map +1 -0
- package/dist/plugins/prometheus-time-series-query/time-series-query-model.js +15 -0
- package/dist/plugins/prometheus-time-series-query/time-series-query-model.js.map +1 -0
- package/dist/plugins/prometheus-variables.d.ts +6 -0
- package/dist/plugins/prometheus-variables.d.ts.map +1 -0
- package/dist/plugins/prometheus-variables.js +205 -0
- package/dist/plugins/prometheus-variables.js.map +1 -0
- package/dist/plugins/types.d.ts +16 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +15 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/plugins/variable.d.ts +8 -0
- package/dist/plugins/variable.d.ts.map +1 -0
- package/dist/plugins/variable.js +97 -0
- package/dist/plugins/variable.js.map +1 -0
- package/dist/test/setup-tests.d.ts +2 -0
- package/dist/test/setup-tests.d.ts.map +1 -0
- package/dist/test/setup-tests.js +15 -0
- package/dist/test/setup-tests.js.map +1 -0
- package/package.json +46 -0
- package/plugin.json +58 -0
|
@@ -0,0 +1,218 @@
|
|
|
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
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
PrometheusLabelNamesVariable: ()=>PrometheusLabelNamesVariable,
|
|
25
|
+
PrometheusLabelValuesVariable: ()=>PrometheusLabelValuesVariable,
|
|
26
|
+
PrometheusPromQLVariable: ()=>PrometheusPromQLVariable
|
|
27
|
+
});
|
|
28
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
29
|
+
const _material = require("@mui/material");
|
|
30
|
+
const _model = require("../model");
|
|
31
|
+
const _matcherEditor = require("./MatcherEditor");
|
|
32
|
+
function PrometheusLabelValuesVariableEditor(props) {
|
|
33
|
+
var _matchers;
|
|
34
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
35
|
+
spacing: 1,
|
|
36
|
+
children: [
|
|
37
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
38
|
+
sx: {
|
|
39
|
+
mb: 1
|
|
40
|
+
},
|
|
41
|
+
label: "Label Name",
|
|
42
|
+
value: props.value.label_name,
|
|
43
|
+
onChange: (e)=>{
|
|
44
|
+
props.onChange({
|
|
45
|
+
...props.value,
|
|
46
|
+
label_name: e.target.value
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}),
|
|
50
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_matcherEditor.MatcherEditor, {
|
|
51
|
+
matchers: (_matchers = props.value.matchers) !== null && _matchers !== void 0 ? _matchers : [],
|
|
52
|
+
onChange: (e)=>{
|
|
53
|
+
props.onChange({
|
|
54
|
+
...props.value,
|
|
55
|
+
matchers: e
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function PrometheusLabelNamesVariableEditor(props) {
|
|
63
|
+
var _matchers;
|
|
64
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Stack, {
|
|
65
|
+
spacing: 1,
|
|
66
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_matcherEditor.MatcherEditor, {
|
|
67
|
+
matchers: (_matchers = props.value.matchers) !== null && _matchers !== void 0 ? _matchers : [],
|
|
68
|
+
onChange: (e)=>{
|
|
69
|
+
props.onChange({
|
|
70
|
+
...props.value,
|
|
71
|
+
matchers: e
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function PrometheusPromQLVariableEditor(props) {
|
|
78
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
79
|
+
spacing: 1,
|
|
80
|
+
children: [
|
|
81
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
82
|
+
sx: {
|
|
83
|
+
mb: 1
|
|
84
|
+
},
|
|
85
|
+
label: "PromQL Expression",
|
|
86
|
+
value: props.value.expr,
|
|
87
|
+
onChange: (e)=>{
|
|
88
|
+
props.onChange({
|
|
89
|
+
...props.value,
|
|
90
|
+
expr: e.target.value
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}),
|
|
94
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
95
|
+
sx: {
|
|
96
|
+
mb: 1
|
|
97
|
+
},
|
|
98
|
+
label: "Label Name",
|
|
99
|
+
value: props.value.label_name,
|
|
100
|
+
onChange: (e)=>{
|
|
101
|
+
props.onChange({
|
|
102
|
+
...props.value,
|
|
103
|
+
label_name: e.target.value
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
]
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function capturingMatrix(matrix, label_name) {
|
|
111
|
+
const captured = new Set();
|
|
112
|
+
for (const sample of matrix.result){
|
|
113
|
+
const value = sample.metric[label_name];
|
|
114
|
+
if (value !== undefined) {
|
|
115
|
+
captured.add(value);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return Array.from(captured.values());
|
|
119
|
+
}
|
|
120
|
+
function capturingVector(vector, label_name) {
|
|
121
|
+
const captured = new Set();
|
|
122
|
+
for (const sample of vector.result){
|
|
123
|
+
const value = sample.metric[label_name];
|
|
124
|
+
if (value !== undefined) {
|
|
125
|
+
captured.add(value);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return Array.from(captured.values());
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Takes a list of strings and returns a list of VariableOptions
|
|
132
|
+
*/ const stringArrayToVariableOptions = (values)=>{
|
|
133
|
+
if (!values) return [];
|
|
134
|
+
return values.map((value)=>({
|
|
135
|
+
value,
|
|
136
|
+
label: value
|
|
137
|
+
}));
|
|
138
|
+
};
|
|
139
|
+
const PrometheusLabelNamesVariable = {
|
|
140
|
+
getVariableOptions: async (spec, ctx)=>{
|
|
141
|
+
var _datasource;
|
|
142
|
+
const client = await ctx.datasourceStore.getDatasourceClient((_datasource = spec.datasource) !== null && _datasource !== void 0 ? _datasource : _model.DEFAULT_PROM);
|
|
143
|
+
const match = spec.matchers ? spec.matchers.map((m)=>(0, _model.replaceTemplateVariables)(m, ctx.variables)) : undefined;
|
|
144
|
+
const timeRange = (0, _model.getPrometheusTimeRange)(ctx.timeRange);
|
|
145
|
+
const { data: options } = await client.labelNames({
|
|
146
|
+
'match[]': match,
|
|
147
|
+
...timeRange
|
|
148
|
+
});
|
|
149
|
+
return {
|
|
150
|
+
data: stringArrayToVariableOptions(options)
|
|
151
|
+
};
|
|
152
|
+
},
|
|
153
|
+
dependsOn: (spec)=>{
|
|
154
|
+
var ref;
|
|
155
|
+
return {
|
|
156
|
+
variables: ((ref = spec.matchers) === null || ref === void 0 ? void 0 : ref.map((m)=>(0, _model.parseTemplateVariables)(m)).flat()) || []
|
|
157
|
+
};
|
|
158
|
+
},
|
|
159
|
+
OptionsEditorComponent: PrometheusLabelNamesVariableEditor,
|
|
160
|
+
createInitialOptions: ()=>({})
|
|
161
|
+
};
|
|
162
|
+
const PrometheusLabelValuesVariable = {
|
|
163
|
+
getVariableOptions: async (spec, ctx)=>{
|
|
164
|
+
const pluginDef = spec;
|
|
165
|
+
var _datasource;
|
|
166
|
+
const client = await ctx.datasourceStore.getDatasourceClient((_datasource = spec.datasource) !== null && _datasource !== void 0 ? _datasource : _model.DEFAULT_PROM);
|
|
167
|
+
const match = pluginDef.matchers ? pluginDef.matchers.map((m)=>(0, _model.replaceTemplateVariables)(m, ctx.variables)) : undefined;
|
|
168
|
+
const timeRange = (0, _model.getPrometheusTimeRange)(ctx.timeRange);
|
|
169
|
+
const { data: options } = await client.labelValues({
|
|
170
|
+
labelName: (0, _model.replaceTemplateVariables)(pluginDef.label_name, ctx.variables),
|
|
171
|
+
'match[]': match,
|
|
172
|
+
...timeRange
|
|
173
|
+
});
|
|
174
|
+
return {
|
|
175
|
+
data: stringArrayToVariableOptions(options)
|
|
176
|
+
};
|
|
177
|
+
},
|
|
178
|
+
dependsOn: (spec)=>{
|
|
179
|
+
var ref;
|
|
180
|
+
return {
|
|
181
|
+
variables: ((ref = spec.matchers) === null || ref === void 0 ? void 0 : ref.map((m)=>(0, _model.parseTemplateVariables)(m)).flat().concat((0, _model.parseTemplateVariables)(spec.label_name))) || []
|
|
182
|
+
};
|
|
183
|
+
},
|
|
184
|
+
OptionsEditorComponent: PrometheusLabelValuesVariableEditor,
|
|
185
|
+
createInitialOptions: ()=>({
|
|
186
|
+
label_name: ''
|
|
187
|
+
})
|
|
188
|
+
};
|
|
189
|
+
const PrometheusPromQLVariable = {
|
|
190
|
+
getVariableOptions: async (spec, ctx)=>{
|
|
191
|
+
var _datasource;
|
|
192
|
+
const client = await ctx.datasourceStore.getDatasourceClient((_datasource = spec.datasource) !== null && _datasource !== void 0 ? _datasource : _model.DEFAULT_PROM);
|
|
193
|
+
// TODO we may want to manage a range query as well.
|
|
194
|
+
const { data: options } = await client.instantQuery({
|
|
195
|
+
query: (0, _model.replaceTemplateVariables)(spec.expr, ctx.variables)
|
|
196
|
+
});
|
|
197
|
+
const labelName = (0, _model.replaceTemplateVariables)(spec.label_name, ctx.variables);
|
|
198
|
+
let values = [];
|
|
199
|
+
if ((options === null || options === void 0 ? void 0 : options.resultType) === 'matrix') {
|
|
200
|
+
values = capturingMatrix(options, labelName);
|
|
201
|
+
} else if ((options === null || options === void 0 ? void 0 : options.resultType) === 'vector') {
|
|
202
|
+
values = capturingVector(options, labelName);
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
data: stringArrayToVariableOptions(values)
|
|
206
|
+
};
|
|
207
|
+
},
|
|
208
|
+
dependsOn: (spec)=>{
|
|
209
|
+
return {
|
|
210
|
+
variables: (0, _model.parseTemplateVariables)(spec.expr).concat((0, _model.parseTemplateVariables)(spec.label_name))
|
|
211
|
+
};
|
|
212
|
+
},
|
|
213
|
+
OptionsEditorComponent: PrometheusPromQLVariableEditor,
|
|
214
|
+
createInitialOptions: ()=>({
|
|
215
|
+
expr: '',
|
|
216
|
+
label_name: ''
|
|
217
|
+
})
|
|
218
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "StaticListVariable", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>StaticListVariable
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _material = require("@mui/material");
|
|
23
|
+
function StaticListVariableOptionEditor(props) {
|
|
24
|
+
const value = props.value.values.map((v)=>{
|
|
25
|
+
if (typeof v === 'string') {
|
|
26
|
+
return v;
|
|
27
|
+
} else {
|
|
28
|
+
return v.value;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const onChange = (__, value)=>{
|
|
32
|
+
props.onChange({
|
|
33
|
+
values: value.map((v)=>{
|
|
34
|
+
return {
|
|
35
|
+
value: v,
|
|
36
|
+
label: v
|
|
37
|
+
};
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)("div", {
|
|
42
|
+
children: [
|
|
43
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Autocomplete, {
|
|
44
|
+
onPaste: (e)=>{
|
|
45
|
+
// Append new values on paste
|
|
46
|
+
const v = e.clipboardData.getData('text/plain');
|
|
47
|
+
if (v) {
|
|
48
|
+
const values = v.split(',');
|
|
49
|
+
onChange(null, value.concat(values));
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
multiple: true,
|
|
54
|
+
value: value,
|
|
55
|
+
onChange: onChange,
|
|
56
|
+
options: [],
|
|
57
|
+
freeSolo: true,
|
|
58
|
+
clearOnBlur: true,
|
|
59
|
+
renderInput: (params)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
60
|
+
...params,
|
|
61
|
+
label: "Values",
|
|
62
|
+
placeholder: "Values"
|
|
63
|
+
})
|
|
64
|
+
}),
|
|
65
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
66
|
+
variant: "caption",
|
|
67
|
+
children: [
|
|
68
|
+
"Type new value then press ",
|
|
69
|
+
`"`,
|
|
70
|
+
"Enter",
|
|
71
|
+
`"`,
|
|
72
|
+
" to add."
|
|
73
|
+
]
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
const StaticListVariable = {
|
|
79
|
+
getVariableOptions: async (spec)=>{
|
|
80
|
+
var ref;
|
|
81
|
+
const values = (ref = spec.values) === null || ref === void 0 ? void 0 : ref.map((v)=>{
|
|
82
|
+
if (typeof v === 'string') {
|
|
83
|
+
return {
|
|
84
|
+
label: v,
|
|
85
|
+
value: v
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return v;
|
|
89
|
+
});
|
|
90
|
+
return {
|
|
91
|
+
data: values
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
dependsOn: ()=>{
|
|
95
|
+
return {
|
|
96
|
+
variables: []
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
OptionsEditorComponent: StaticListVariableOptionEditor,
|
|
100
|
+
createInitialOptions: ()=>({
|
|
101
|
+
values: []
|
|
102
|
+
})
|
|
103
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
require("@testing-library/jest-dom/extend-expect");
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PrometheusTimeSeriesQuery } from './plugins/prometheus-time-series-query';
|
|
2
|
+
import { StaticListVariable } from './plugins/variable';
|
|
3
|
+
import { PrometheusLabelNamesVariable, PrometheusLabelValuesVariable, PrometheusPromQLVariable } from './plugins/prometheus-variables';
|
|
4
|
+
import { PrometheusDatasource } from './plugins/prometheus-datasource';
|
|
5
|
+
export { PrometheusTimeSeriesQuery, StaticListVariable, PrometheusLabelNamesVariable, PrometheusLabelValuesVariable, PrometheusPromQLVariable, PrometheusDatasource, };
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AAEnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,EAC7B,wBAAwB,EACzB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAGvE,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,4BAA4B,EAC5B,6BAA6B,EAC7B,wBAAwB,EACxB,oBAAoB,GACrB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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 { PrometheusTimeSeriesQuery } from './plugins/prometheus-time-series-query';
|
|
14
|
+
// @TODO: Move this to a more generic location;
|
|
15
|
+
import { StaticListVariable } from './plugins/variable';
|
|
16
|
+
import { PrometheusLabelNamesVariable, PrometheusLabelValuesVariable, PrometheusPromQLVariable } from './plugins/prometheus-variables';
|
|
17
|
+
import { PrometheusDatasource } from './plugins/prometheus-datasource';
|
|
18
|
+
// Export plugins under the same name as the kinds they handle from the plugin.json
|
|
19
|
+
export { PrometheusTimeSeriesQuery, StaticListVariable, PrometheusLabelNamesVariable, PrometheusLabelValuesVariable, PrometheusPromQLVariable, PrometheusDatasource };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.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 { PrometheusTimeSeriesQuery } from './plugins/prometheus-time-series-query';\n// @TODO: Move this to a more generic location;\nimport { StaticListVariable } from './plugins/variable';\nimport {\n PrometheusLabelNamesVariable,\n PrometheusLabelValuesVariable,\n PrometheusPromQLVariable,\n} from './plugins/prometheus-variables';\nimport { PrometheusDatasource } from './plugins/prometheus-datasource';\n\n// Export plugins under the same name as the kinds they handle from the plugin.json\nexport {\n PrometheusTimeSeriesQuery,\n StaticListVariable,\n PrometheusLabelNamesVariable,\n PrometheusLabelValuesVariable,\n PrometheusPromQLVariable,\n PrometheusDatasource,\n};\n"],"names":["PrometheusTimeSeriesQuery","StaticListVariable","PrometheusLabelNamesVariable","PrometheusLabelValuesVariable","PrometheusPromQLVariable","PrometheusDatasource"],"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,yBAAyB,QAAQ,wCAAwC,CAAC;AACnF,+CAA+C;AAC/C,SAASC,kBAAkB,QAAQ,oBAAoB,CAAC;AACxD,SACEC,4BAA4B,EAC5BC,6BAA6B,EAC7BC,wBAAwB,QACnB,gCAAgC,CAAC;AACxC,SAASC,oBAAoB,QAAQ,iCAAiC,CAAC;AAEvE,mFAAmF;AACnF,SACEL,yBAAyB,EACzBC,kBAAkB,EAClBC,4BAA4B,EAC5BC,6BAA6B,EAC7BC,wBAAwB,EACxBC,oBAAoB,GACpB"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { DurationString } from '@perses-dev/core';
|
|
2
|
+
export type { DurationString };
|
|
3
|
+
export interface SuccessResponse<T> {
|
|
4
|
+
status: 'success';
|
|
5
|
+
data: T;
|
|
6
|
+
warnings?: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface ErrorResponse<T> {
|
|
9
|
+
status: 'error';
|
|
10
|
+
data?: T;
|
|
11
|
+
errorType: string;
|
|
12
|
+
error: string;
|
|
13
|
+
}
|
|
14
|
+
export declare type ApiResponse<T> = SuccessResponse<T> | ErrorResponse<T>;
|
|
15
|
+
export declare type DurationSeconds = number;
|
|
16
|
+
export declare type UnixTimestampSeconds = number;
|
|
17
|
+
export declare type ValueTuple = [unixTimeSeconds: UnixTimestampSeconds, sampleValue: string];
|
|
18
|
+
export declare type Metric = Record<string, string>;
|
|
19
|
+
export interface VectorData {
|
|
20
|
+
resultType: 'vector';
|
|
21
|
+
result: Array<{
|
|
22
|
+
metric: Metric;
|
|
23
|
+
value: ValueTuple;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
export interface MatrixData {
|
|
27
|
+
resultType: 'matrix';
|
|
28
|
+
result: Array<{
|
|
29
|
+
metric: Metric;
|
|
30
|
+
values: ValueTuple[];
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
33
|
+
export interface ScalarData {
|
|
34
|
+
resultType: 'scalar';
|
|
35
|
+
result: ValueTuple;
|
|
36
|
+
}
|
|
37
|
+
export interface InstantQueryRequestParameters {
|
|
38
|
+
query: string;
|
|
39
|
+
time?: UnixTimestampSeconds;
|
|
40
|
+
timeout?: DurationString;
|
|
41
|
+
}
|
|
42
|
+
export declare type InstantQueryResponse = ApiResponse<MatrixData | VectorData | ScalarData>;
|
|
43
|
+
export interface RangeQueryRequestParameters {
|
|
44
|
+
query: string;
|
|
45
|
+
start: UnixTimestampSeconds;
|
|
46
|
+
end: UnixTimestampSeconds;
|
|
47
|
+
step: DurationSeconds;
|
|
48
|
+
timeout?: DurationString;
|
|
49
|
+
}
|
|
50
|
+
export declare type RangeQueryResponse = ApiResponse<MatrixData>;
|
|
51
|
+
export interface SeriesRequestParameters {
|
|
52
|
+
'match[]': string[];
|
|
53
|
+
start: UnixTimestampSeconds;
|
|
54
|
+
end: UnixTimestampSeconds;
|
|
55
|
+
}
|
|
56
|
+
export declare type SeriesResponse = ApiResponse<Metric[]>;
|
|
57
|
+
export interface LabelNamesRequestParameters {
|
|
58
|
+
start?: UnixTimestampSeconds;
|
|
59
|
+
end?: UnixTimestampSeconds;
|
|
60
|
+
'match[]'?: string[];
|
|
61
|
+
}
|
|
62
|
+
export declare type LabelNamesResponse = ApiResponse<string[]>;
|
|
63
|
+
export interface LabelValuesRequestParameters {
|
|
64
|
+
labelName: string;
|
|
65
|
+
start?: UnixTimestampSeconds;
|
|
66
|
+
end?: UnixTimestampSeconds;
|
|
67
|
+
'match[]'?: string[];
|
|
68
|
+
}
|
|
69
|
+
export declare type LabelValuesResponse = ApiResponse<string[]>;
|
|
70
|
+
export interface MetricMetadata {
|
|
71
|
+
type: string;
|
|
72
|
+
help: string;
|
|
73
|
+
unit?: string;
|
|
74
|
+
}
|
|
75
|
+
export interface MetricMetadataRequestParameters {
|
|
76
|
+
limit?: number;
|
|
77
|
+
metric?: string;
|
|
78
|
+
}
|
|
79
|
+
export declare type MetricMetadataResponse = ApiResponse<Record<string, MetricMetadata[]>>;
|
|
80
|
+
//# sourceMappingURL=api-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-types.d.ts","sourceRoot":"","sources":["../../src/model/api-types.ts"],"names":[],"mappings":"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"}
|
|
@@ -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=api-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/api-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 { DurationString } from '@perses-dev/core';\n\n// Just reuse dashboard model's type and re-export\nexport type { DurationString };\n\nexport interface SuccessResponse<T> {\n status: 'success';\n data: T;\n warnings?: string[];\n}\n\nexport interface ErrorResponse<T> {\n status: 'error';\n data?: T;\n errorType: string;\n error: string;\n}\n\nexport type ApiResponse<T> = SuccessResponse<T> | ErrorResponse<T>;\n\nexport type DurationSeconds = number;\n\nexport type UnixTimestampSeconds = number;\n\nexport type ValueTuple = [unixTimeSeconds: UnixTimestampSeconds, sampleValue: string];\n\nexport type Metric = Record<string, string>;\n\nexport interface VectorData {\n resultType: 'vector';\n result: Array<{\n metric: Metric;\n value: ValueTuple;\n }>;\n}\n\nexport interface MatrixData {\n resultType: 'matrix';\n result: Array<{\n metric: Metric;\n values: ValueTuple[];\n }>;\n}\n\nexport interface ScalarData {\n resultType: 'scalar';\n result: ValueTuple;\n}\n\nexport interface InstantQueryRequestParameters {\n query: string;\n time?: UnixTimestampSeconds;\n timeout?: DurationString;\n}\n\nexport type InstantQueryResponse = ApiResponse<MatrixData | VectorData | ScalarData>;\n\nexport interface RangeQueryRequestParameters {\n query: string;\n start: UnixTimestampSeconds;\n end: UnixTimestampSeconds;\n step: DurationSeconds;\n timeout?: DurationString;\n}\n\nexport type RangeQueryResponse = ApiResponse<MatrixData>;\n\nexport interface SeriesRequestParameters {\n 'match[]': string[];\n start: UnixTimestampSeconds;\n end: UnixTimestampSeconds;\n}\n\nexport type SeriesResponse = ApiResponse<Metric[]>;\n\nexport interface LabelNamesRequestParameters {\n start?: UnixTimestampSeconds;\n end?: UnixTimestampSeconds;\n 'match[]'?: string[];\n}\n\nexport type LabelNamesResponse = ApiResponse<string[]>;\n\nexport interface LabelValuesRequestParameters {\n labelName: string;\n start?: UnixTimestampSeconds;\n end?: UnixTimestampSeconds;\n 'match[]'?: string[];\n}\n\nexport type LabelValuesResponse = ApiResponse<string[]>;\n\nexport interface MetricMetadata {\n type: string;\n help: string;\n unit?: string;\n}\n\nexport interface MetricMetadataRequestParameters {\n limit?: number;\n metric?: string;\n}\n\nexport type MetricMetadataResponse = ApiResponse<Record<string, MetricMetadata[]>>;\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,WAuGmF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './api-types';
|
|
2
|
+
export * from './parse-sample-values';
|
|
3
|
+
export * from './prometheus-client';
|
|
4
|
+
export * from './prometheus-selectors';
|
|
5
|
+
export * from './templating';
|
|
6
|
+
export * from './time';
|
|
7
|
+
export * from './utils';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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 * from './api-types';
|
|
14
|
+
export * from './parse-sample-values';
|
|
15
|
+
export * from './prometheus-client';
|
|
16
|
+
export * from './prometheus-selectors';
|
|
17
|
+
export * from './templating';
|
|
18
|
+
export * from './time';
|
|
19
|
+
export * from './utils';
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/index.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\nexport * from './api-types';\nexport * from './parse-sample-values';\nexport * from './prometheus-client';\nexport * from './prometheus-selectors';\nexport * from './templating';\nexport * from './time';\nexport * from './utils';\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,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ValueTuple } from './api-types';
|
|
2
|
+
/**
|
|
3
|
+
* ValueTuple from the Prom server, parsed into ms and floating point number
|
|
4
|
+
*/
|
|
5
|
+
export declare type ParsedValueTuple = [unixTimeMs: number, value: number];
|
|
6
|
+
/**
|
|
7
|
+
* Parse a ValueTuple from a PromServer response into the a millisecond-based
|
|
8
|
+
* unix time and a numeric sample value.
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseValueTuple(data: ValueTuple): ParsedValueTuple;
|
|
11
|
+
/**
|
|
12
|
+
* Parses a string sample value from Prometheus, usually included as the
|
|
13
|
+
* second member of a ValueTuple.
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseSampleValue(sampleValue: ValueTuple[1]): number;
|
|
16
|
+
//# sourceMappingURL=parse-sample-values.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-sample-values.d.ts","sourceRoot":"","sources":["../../src/model/parse-sample-values.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;GAEG;AACH,oBAAY,gBAAgB,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAEnE;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,gBAAgB,CAKlE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,CAenE"}
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
/**
|
|
14
|
+
* Parse a ValueTuple from a PromServer response into the a millisecond-based
|
|
15
|
+
* unix time and a numeric sample value.
|
|
16
|
+
*/ export function parseValueTuple(data) {
|
|
17
|
+
const [unixTimeSeconds, sampleValue] = data;
|
|
18
|
+
// Prom returns unix time in seconds, so convert to ms
|
|
19
|
+
return [
|
|
20
|
+
unixTimeSeconds * 1000,
|
|
21
|
+
parseSampleValue(sampleValue)
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Parses a string sample value from Prometheus, usually included as the
|
|
26
|
+
* second member of a ValueTuple.
|
|
27
|
+
*/ export function parseSampleValue(sampleValue) {
|
|
28
|
+
// Account for Prometheus' representation of +/- infinity, otherwise just
|
|
29
|
+
// parse the sample value as a float
|
|
30
|
+
let value;
|
|
31
|
+
switch(sampleValue){
|
|
32
|
+
case '+Inf':
|
|
33
|
+
value = Number.POSITIVE_INFINITY;
|
|
34
|
+
break;
|
|
35
|
+
case '-Inf':
|
|
36
|
+
value = Number.NEGATIVE_INFINITY;
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
value = parseFloat(sampleValue);
|
|
40
|
+
}
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=parse-sample-values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/parse-sample-values.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 { ValueTuple } from './api-types';\n\n/**\n * ValueTuple from the Prom server, parsed into ms and floating point number\n */\nexport type ParsedValueTuple = [unixTimeMs: number, value: number];\n\n/**\n * Parse a ValueTuple from a PromServer response into the a millisecond-based\n * unix time and a numeric sample value.\n */\nexport function parseValueTuple(data: ValueTuple): ParsedValueTuple {\n const [unixTimeSeconds, sampleValue] = data;\n\n // Prom returns unix time in seconds, so convert to ms\n return [unixTimeSeconds * 1000, parseSampleValue(sampleValue)];\n}\n\n/**\n * Parses a string sample value from Prometheus, usually included as the\n * second member of a ValueTuple.\n */\nexport function parseSampleValue(sampleValue: ValueTuple[1]): number {\n // Account for Prometheus' representation of +/- infinity, otherwise just\n // parse the sample value as a float\n let value: number;\n switch (sampleValue) {\n case '+Inf':\n value = Number.POSITIVE_INFINITY;\n break;\n case '-Inf':\n value = Number.NEGATIVE_INFINITY;\n break;\n default:\n value = parseFloat(sampleValue);\n }\n return value;\n}\n"],"names":["parseValueTuple","data","unixTimeSeconds","sampleValue","parseSampleValue","value","Number","POSITIVE_INFINITY","NEGATIVE_INFINITY","parseFloat"],"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;AASjC;;;CAGC,GACD,OAAO,SAASA,eAAe,CAACC,IAAgB,EAAoB;IAClE,MAAM,CAACC,eAAe,EAAEC,WAAW,CAAC,GAAGF,IAAI,AAAC;IAE5C,sDAAsD;IACtD,OAAO;QAACC,eAAe,GAAG,IAAI;QAAEE,gBAAgB,CAACD,WAAW,CAAC;KAAC,CAAC;AACjE,CAAC;AAED;;;CAGC,GACD,OAAO,SAASC,gBAAgB,CAACD,WAA0B,EAAU;IACnE,yEAAyE;IACzE,oCAAoC;IACpC,IAAIE,KAAK,AAAQ,AAAC;IAClB,OAAQF,WAAW;QACjB,KAAK,MAAM;YACTE,KAAK,GAAGC,MAAM,CAACC,iBAAiB,CAAC;YACjC,MAAM;QACR,KAAK,MAAM;YACTF,KAAK,GAAGC,MAAM,CAACE,iBAAiB,CAAC;YACjC,MAAM;QACR;YACEH,KAAK,GAAGI,UAAU,CAACN,WAAW,CAAC,CAAC;KACnC;IACD,OAAOE,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { InstantQueryRequestParameters, InstantQueryResponse, LabelNamesRequestParameters, LabelNamesResponse, LabelValuesRequestParameters, LabelValuesResponse, RangeQueryRequestParameters, RangeQueryResponse } from './api-types';
|
|
2
|
+
export interface PrometheusClient {
|
|
3
|
+
instantQuery(params: InstantQueryRequestParameters): Promise<InstantQueryResponse>;
|
|
4
|
+
rangeQuery(params: RangeQueryRequestParameters): Promise<RangeQueryResponse>;
|
|
5
|
+
labelNames(params: LabelNamesRequestParameters): Promise<LabelNamesResponse>;
|
|
6
|
+
labelValues(params: LabelValuesRequestParameters): Promise<LabelValuesResponse>;
|
|
7
|
+
}
|
|
8
|
+
export interface QueryOptions {
|
|
9
|
+
datasourceUrl: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Calls the `/api/v1/query` endpoint to get metrics data.
|
|
13
|
+
*/
|
|
14
|
+
export declare function instantQuery(params: InstantQueryRequestParameters, queryOptions: QueryOptions): Promise<InstantQueryResponse>;
|
|
15
|
+
/**
|
|
16
|
+
* Calls the `/api/v1/query_range` endpoint to get metrics data.
|
|
17
|
+
*/
|
|
18
|
+
export declare function rangeQuery(params: RangeQueryRequestParameters, queryOptions: QueryOptions): Promise<RangeQueryResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* Calls the `/api/v1/labels` endpoint to get a list of label names.
|
|
21
|
+
*/
|
|
22
|
+
export declare function labelNames(params: LabelNamesRequestParameters, queryOptions: QueryOptions): Promise<LabelNamesResponse>;
|
|
23
|
+
/**
|
|
24
|
+
* Calls the `/api/v1/label/{labelName}/values` endpoint to get a list of values for a label.
|
|
25
|
+
*/
|
|
26
|
+
export declare function labelValues(params: LabelValuesRequestParameters, queryOptions: QueryOptions): Promise<LabelValuesResponse>;
|
|
27
|
+
//# sourceMappingURL=prometheus-client.d.ts.map
|