From de396a5c9329dc452cb09773d3c1842d1c31efe9 Mon Sep 17 00:00:00 2001 From: Kyle Sammons Date: Tue, 13 Feb 2024 16:12:07 -0800 Subject: [PATCH 1/2] Fix the histogram rendering in Grafana 10 --- docker-compose.yaml | 2 +- src/pages/explore.tsx | 15 +++++++++++++-- 2 files changed, 14 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..891ef36 100644 --- a/src/pages/explore.tsx +++ b/src/pages/explore.tsx @@ -870,10 +870,21 @@ const histogramPanel = PanelBuilders.timeseries() const histogramResultTransformation: CustomTransformOperator = () => (source: Observable) => { return source.pipe( map((data: DataFrame[]) => { + // debugger; 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); From 2245ecd87644cb2bdbb682025c1f871c93f8296b Mon Sep 17 00:00:00 2001 From: Kyle Sammons Date: Tue, 13 Feb 2024 16:31:35 -0800 Subject: [PATCH 2/2] Remove debugger statement --- src/pages/explore.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/explore.tsx b/src/pages/explore.tsx index 891ef36..92f9de8 100644 --- a/src/pages/explore.tsx +++ b/src/pages/explore.tsx @@ -870,7 +870,6 @@ const histogramPanel = PanelBuilders.timeseries() const histogramResultTransformation: CustomTransformOperator = () => (source: Observable) => { return source.pipe( map((data: DataFrame[]) => { - // debugger; if (data.length > 0 && data[0].meta['shards']) { let counter = 0;