prettier: ran on all files again, sorry. now settings are defined in package.json

This commit is contained in:
Torkel Ödegaard
2017-12-21 08:39:31 +01:00
parent af34f9977e
commit 3a1f52d8a2
262 changed files with 3996 additions and 7431 deletions

View File

@@ -1,4 +1,4 @@
import _ from "lodash";
import _ from 'lodash';
export default class PrometheusMetricFindQuery {
datasource: any;
@@ -19,10 +19,7 @@ export default class PrometheusMetricFindQuery {
var label_values_query = this.query.match(label_values_regex);
if (label_values_query) {
if (label_values_query[1]) {
return this.labelValuesQuery(
label_values_query[2],
label_values_query[1]
);
return this.labelValuesQuery(label_values_query[2], label_values_query[1]);
} else {
return this.labelValuesQuery(label_values_query[2], null);
}
@@ -47,9 +44,9 @@ export default class PrometheusMetricFindQuery {
if (!metric) {
// return label values globally
url = "/api/v1/label/" + label + "/values";
url = '/api/v1/label/' + label + '/values';
return this.datasource._request("GET", url).then(function(result) {
return this.datasource._request('GET', url).then(function(result) {
return _.map(result.data.data, function(value) {
return { text: value };
});
@@ -57,25 +54,19 @@ export default class PrometheusMetricFindQuery {
} else {
var start = this.datasource.getPrometheusTime(this.range.from, false);
var end = this.datasource.getPrometheusTime(this.range.to, true);
url =
"/api/v1/series?match[]=" +
encodeURIComponent(metric) +
"&start=" +
start +
"&end=" +
end;
url = '/api/v1/series?match[]=' + encodeURIComponent(metric) + '&start=' + start + '&end=' + end;
return this.datasource._request("GET", url).then(function(result) {
return this.datasource._request('GET', url).then(function(result) {
var _labels = _.map(result.data.data, function(metric) {
return metric[label] || "";
return metric[label] || '';
}).filter(function(label) {
return label !== "";
return label !== '';
});
return _.uniq(_labels).map(function(metric) {
return {
text: metric,
expandable: true
expandable: true,
};
});
});
@@ -83,9 +74,9 @@ export default class PrometheusMetricFindQuery {
}
metricNameQuery(metricFilterPattern) {
var url = "/api/v1/label/__name__/values";
var url = '/api/v1/label/__name__/values';
return this.datasource._request("GET", url).then(function(result) {
return this.datasource._request('GET', url).then(function(result) {
return _.chain(result.data.data)
.filter(function(metricName) {
var r = new RegExp(metricFilterPattern);
@@ -94,7 +85,7 @@ export default class PrometheusMetricFindQuery {
.map(function(matchedMetricName) {
return {
text: matchedMetricName,
expandable: true
expandable: true,
};
})
.value();
@@ -103,45 +94,37 @@ export default class PrometheusMetricFindQuery {
queryResultQuery(query) {
var end = this.datasource.getPrometheusTime(this.range.to, true);
return this.datasource
.performInstantQuery({ expr: query }, end)
.then(function(result) {
return _.map(result.data.data.result, function(metricData) {
var text = metricData.metric.__name__ || "";
delete metricData.metric.__name__;
text +=
"{" +
_.map(metricData.metric, function(v, k) {
return k + '="' + v + '"';
}).join(",") +
"}";
text += " " + metricData.value[1] + " " + metricData.value[0] * 1000;
return this.datasource.performInstantQuery({ expr: query }, end).then(function(result) {
return _.map(result.data.data.result, function(metricData) {
var text = metricData.metric.__name__ || '';
delete metricData.metric.__name__;
text +=
'{' +
_.map(metricData.metric, function(v, k) {
return k + '="' + v + '"';
}).join(',') +
'}';
text += ' ' + metricData.value[1] + ' ' + metricData.value[0] * 1000;
return {
text: text,
expandable: true
};
});
return {
text: text,
expandable: true,
};
});
});
}
metricNameAndLabelsQuery(query) {
var start = this.datasource.getPrometheusTime(this.range.from, false);
var end = this.datasource.getPrometheusTime(this.range.to, true);
var url =
"/api/v1/series?match[]=" +
encodeURIComponent(query) +
"&start=" +
start +
"&end=" +
end;
var url = '/api/v1/series?match[]=' + encodeURIComponent(query) + '&start=' + start + '&end=' + end;
var self = this;
return this.datasource._request("GET", url).then(function(result) {
return this.datasource._request('GET', url).then(function(result) {
return _.map(result.data.data, function(metric) {
return {
text: self.datasource.getOriginalMetricName(metric),
expandable: true
expandable: true,
};
});
});