Skip to content

Commit

Permalink
Fix the histogram rendering in Grafana 10 (#52)
Browse files Browse the repository at this point in the history
* Fix the histogram rendering in Grafana 10

* Remove debugger statement
  • Loading branch information
kyle-sammons authored Feb 14, 2024
1 parent dead011 commit 7d4ec4e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 12 additions & 2 deletions src/pages/explore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7d4ec4e

Please sign in to comment.