Identify hosts in multi-node panels - #63
Draft
kapantzak wants to merge 2 commits into
Draft
Conversation
Series were named from result.labels, which carries machine-readable ids,
with a node lookup that only applied when grouping by node. Grouping by a
label produced the same legend entry for every host (e.g. "/"), so a panel
covering several nodes could not be read.
- name series from view.dimensions.names, the human-readable counterpart
that is index-aligned with result.labels
- attach Grafana field labels from view.dimensions.labels plus the node
identity, so {{node}} legend overrides and transformations work
- request the group-by-labels option, without which those labels are absent
from the response
- allow several groupings in one query, so a single query can separate
series per node and per label at the same time
- keep accepting the single-string groupBy of already saved dashboards
- scope the chart-data event per query, so sibling editor rows stop
overwriting each other's dimension and filter options
Grouping by dimension leaves the node out of the series id, so a query pinned to a single node produced a legend with no way to tell which host it came from - two such queries in one panel were identical. Fall back to the only node in summary.nodes when the id carries none: with one node in scope every series belongs to it, while several nodes mean the series really is a cross-node aggregate and stays unlabelled. summary.nodes is the only valid source - agents names whichever agent served the query, which is routinely a different node.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A panel covering several nodes could not show which host each series belonged to. Reported in support ticket 835: disk usage of
/across 13 hosts produced 13 indistinguishable series.The series name came from
result.labels, which carries machine-readable ids, and the only translation was a machine-GUID lookup againstsummary.nodes:That lookup only matches when grouping by node (where the id is the machine GUID). Grouping by a label makes the id the label value, so every host came back as
/. On top of that,Grouping bywas single-select, so "per node and per mount point" was not expressible, and no Grafana field labels were emitted, so legend overrides had nothing to work with.What the API already provides
Verified against
netdata/cloud-charts-service(internal/model/data.go,internal/aggregation/data_v2_metadata.go) and a recorded response fixture in that repo:result.labels["time", ...ids]— machine-readableview.dimensions.names"time"view.dimensions.labels{ "<key>": [[values], ...] }, same alignment — only when the request sends thegroup-by-labelsoptionaggregations.metrics[].group_byaccepts combined values (["node","label"]) alongsidegroup_by_label.Changes
view.dimensions.namesinstead of the raw ids (src/shared/utils/series.ts).Field.labelsfromview.dimensions.labelsplus the node identity, so{{node}}legend overrides, joins and transformations work.group-by-labelsoption, without which those labels are absent.Grouping byis now a multi-select mapping togroup_by/group_by_label(src/shared/utils/grouping.ts).groupBywritten by already saved dashboards (normalizeGroupBy), so no dashboard migration is needed.CHART_DATA.<refId>), so sibling editor rows stop overwriting each other's dimension and filter option lists.Netdata joins the group-by parts of an id with
,(and@forinstance@machine_guid) without escaping, so ids cannot be split back apart reliably. Label values are therefore read straight fromview.dimensions.labels, and the node is found by matching any separated part against a known machine GUID.Result
One query — Nodes = all 13, Grouping by =
node+mount_point, Filter bymount_point=/— yields 13 series named/,web01…/,web13, each carrying{mount_point: "/", node: "web01"}.Verification
Notes for reviewers
src/shared/hooks/useFetch*.test.tssuites fail withSyntaxError: Unexpected token 'export', a jest ESM-transform issue viamarked←@grafana/data. Left alone deliberately; it is whybuildGroupinglives in its own dependency-free module rather than being exported from the hook.Grouping byusesMultiSelectrather thanSelect isMulti, which is what typechecks correctly for a multi-value handler.