add annotation option to treat series value as timestamp

This commit is contained in:
Mitsuhiro Tanda
2018-05-01 12:49:18 +09:00
parent e4496080ff
commit 2926725bab
3 changed files with 57 additions and 3 deletions

View File

@@ -487,15 +487,21 @@ export class PrometheusDatasource {
.value();
for (const value of series.values) {
if (value[1] === '1') {
const valueIsTrue = value[1] === '1'; // e.g. ALERTS
if (valueIsTrue || annotation.useValueForTime) {
const event = {
annotation: annotation,
time: Math.floor(parseFloat(value[0])) * 1000,
title: self.resultTransformer.renderTemplate(titleFormat, series.metric),
tags: tags,
text: self.resultTransformer.renderTemplate(textFormat, series.metric),
};
if (annotation.useValueForTime) {
event['time'] = Math.floor(parseFloat(value[1]));
} else {
event['time'] = Math.floor(parseFloat(value[0])) * 1000;
}
eventList.push(event);
}
}