Commit a6920eb2 by Mitsuhiro Tanda Committed by Torkel Ödegaard

(prometheus) replace each by for (#8881)

parent 32f9a42d
...@@ -205,11 +205,11 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS ...@@ -205,11 +205,11 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
return _.includes(tagKeys, k); return _.includes(tagKeys, k);
}).value(); }).value();
_.each(series.values, function(value) { for (let value of series.values) {
if (value[1] === '1') { if (value[1] === '1') {
var event = { var event = {
annotation: annotation, annotation: annotation,
time: Math.floor(value[0]) * 1000, time: Math.floor(parseFloat(value[0])) * 1000,
title: self.renderTemplate(titleFormat, series.metric), title: self.renderTemplate(titleFormat, series.metric),
tags: tags, tags: tags,
text: self.renderTemplate(textFormat, series.metric) text: self.renderTemplate(textFormat, series.metric)
...@@ -217,7 +217,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS ...@@ -217,7 +217,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
eventList.push(event); eventList.push(event);
} }
}); }
}); });
return eventList; return eventList;
...@@ -253,22 +253,22 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS ...@@ -253,22 +253,22 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
var stepMs = parseInt(options.step) * 1000; var stepMs = parseInt(options.step) * 1000;
var baseTimestamp = start * 1000; var baseTimestamp = start * 1000;
_.each(md.values, function(value) { for (let value of md.values) {
var dp_value = parseFloat(value[1]); var dp_value = parseFloat(value[1]);
if (_.isNaN(dp_value)) { if (_.isNaN(dp_value)) {
dp_value = null; dp_value = null;
} }
var timestamp = value[0] * 1000; var timestamp = parseFloat(value[0]) * 1000;
for (var t = baseTimestamp; t < timestamp; t += stepMs) { for (let t = baseTimestamp; t < timestamp; t += stepMs) {
dps.push([null, t]); dps.push([null, t]);
} }
baseTimestamp = timestamp + stepMs; baseTimestamp = timestamp + stepMs;
dps.push([dp_value, timestamp]); dps.push([dp_value, timestamp]);
}); }
var endTimestamp = end * 1000; var endTimestamp = end * 1000;
for (var t = baseTimestamp; t <= endTimestamp; t += stepMs) { for (let t = baseTimestamp; t <= endTimestamp; t += stepMs) {
dps.push([null, t]); dps.push([null, t]);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment