mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Prometheus: annotation: fix only first frame was process error & typo. (#43486)
This commit is contained in:
@@ -694,13 +694,13 @@ export class PrometheusDatasource
|
||||
})
|
||||
.pipe(
|
||||
map((rsp: FetchResponse<BackendDataSourceResponse>) => {
|
||||
return this.processsAnnotationResponse(options, rsp.data);
|
||||
return this.processAnnotationResponse(options, rsp.data);
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
processsAnnotationResponse = (options: any, data: BackendDataSourceResponse) => {
|
||||
processAnnotationResponse = (options: any, data: BackendDataSourceResponse) => {
|
||||
const frames: DataFrame[] = toDataQueryResponse({ data: data }).data;
|
||||
if (!frames || !frames.length) {
|
||||
return [];
|
||||
@@ -711,7 +711,10 @@ export class PrometheusDatasource
|
||||
|
||||
const step = rangeUtil.intervalToSeconds(annotation.step || ANNOTATION_QUERY_STEP_DEFAULT) * 1000;
|
||||
const tagKeysArray = tagKeys.split(',');
|
||||
const frame = frames[0];
|
||||
|
||||
const eventList: AnnotationEvent[] = [];
|
||||
|
||||
for (const frame of frames) {
|
||||
const timeField = frame.fields[0];
|
||||
const valueField = frame.fields[1];
|
||||
const labels = valueField?.labels || {};
|
||||
@@ -746,7 +749,6 @@ export class PrometheusDatasource
|
||||
|
||||
// Instead of creating singular annotation for each active event we group events into region if they are less
|
||||
// or equal to `step` apart.
|
||||
const eventList: AnnotationEvent[] = [];
|
||||
let latestEvent: AnnotationEvent | null = null;
|
||||
|
||||
for (const timestamp of activeValuesTimestamps) {
|
||||
@@ -777,6 +779,7 @@ export class PrometheusDatasource
|
||||
latestEvent.timeEnd = activeValuesTimestamps[activeValuesTimestamps.length - 1];
|
||||
eventList.push(latestEvent);
|
||||
}
|
||||
}
|
||||
|
||||
return eventList;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user