From 7d4ec4e42e173c08edf5ddccf9f1ca54dc8bd81d Mon Sep 17 00:00:00 2001 From: Kyle Sammons <1023070+kyle-sammons@users.noreply.github.com> Date: Tue, 13 Feb 2024 17:02:15 -0800 Subject: [PATCH] Fix the histogram rendering in Grafana 10 (#52) * Fix the histogram rendering in Grafana 10 * Remove debugger statement --- docker-compose.yaml | 2 +- src/pages/explore.tsx | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 3841968..c87b52e 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -6,7 +6,7 @@ services: build: context: ./.config args: - grafana_version: ${GRAFANA_VERSION:-9.5.3} + grafana_version: ${GRAFANA_VERSION:-10.3.1} ports: - 3000:3000/tcp volumes: diff --git a/src/pages/explore.tsx b/src/pages/explore.tsx index c1c6087..92f9de8 100644 --- a/src/pages/explore.tsx +++ b/src/pages/explore.tsx @@ -872,8 +872,18 @@ const histogramResultTransformation: CustomTransformOperator = () => (source: Ob map((data: DataFrame[]) => { if (data.length > 0 && data[0].meta['shards']) { let counter = 0; - for (let i = data[1].fields[1].values['buffer'].length - 1; i >= 0; i--) { - counter += data[1].fields[1].values['buffer'][i]; + + // In Grafana 9, the values live in `values['buffer']`. + // In Grafana 10, they're just in `values` + let buffer: any = []; + if (data[1].fields[1].values['buffer']) { + buffer = data[1].fields[1].values['buffer'] + } else { + buffer = data[1].fields[1].values + } + + for (let i = buffer.length - 1; i >= 0; i--) { + counter += buffer[i]; } resultsCounter.setResults(counter); histogramNodeStats.setCount(data[0].meta['shards'].total, data[0].meta['shards'].failed);