From edfc35424cda1b9e52d46ed7ccb45d0292d85991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Farkas?= Date: Wed, 12 Jul 2023 14:18:14 +0200 Subject: [PATCH] [v10.0.x] Elasticsearch: Fix histogram colors in backend mode (#71447) Elasticsearch: Fix histogram colors in backend mode (#71442) elastic: backend-mode: fix histogram colors (cherry picked from commit fdb825700751e54fd001989fe31af7eb1393ad3b) --- .../app/plugins/datasource/elasticsearch/datasource.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/elasticsearch/datasource.ts b/public/app/plugins/datasource/elasticsearch/datasource.ts index 8f280972dc7..266c513397d 100644 --- a/public/app/plugins/datasource/elasticsearch/datasource.ts +++ b/public/app/plugins/datasource/elasticsearch/datasource.ts @@ -32,6 +32,7 @@ import { Field, LogRowContextQueryDirection, LogRowContextOptions, + FieldType, } from '@grafana/data'; import { BackendSrvRequest, DataSourceWithBackend, getBackendSrv, getDataSourceSrv, config } from '@grafana/runtime'; import { queryLogsVolume } from 'app/core/logsModel'; @@ -683,7 +684,7 @@ export class ElasticDatasource { range: request.range, targets: request.targets, - extractLevel: (dataFrame) => getLogLevelFromKey(dataFrame.name || ''), + extractLevel, } ); } @@ -1282,3 +1283,9 @@ function createContextTimeRange(rowTimeEpochMs: number, direction: string, inter } } } + +function extractLevel(dataFrame: DataFrame): LogLevel { + const valueField = dataFrame.fields.find((f) => f.type === FieldType.number); + const name = valueField?.labels?.['level'] ?? ''; + return getLogLevelFromKey(name); +}