-
Notifications
You must be signed in to change notification settings - Fork 485
Adds support for host tags #2140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
itsmylife
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return uniqueHostTags; | ||
| } | ||
|
|
||
| /** Get the label for a host tag option |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /** Get the label for a host tag option | |
| /** | |
| * Get the label for a host tag option |
| @@ -1,4 +1,7 @@ | |||
| import _ from 'lodash'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can import uniqBy just using import { uniqBy } from 'lodash';. What do you think?
| } | ||
|
|
||
| /** Get the label for a host tag option | ||
| * Zabbix chaneged some of the operator labels in version 7.0.0 but the value equivalents remained the same. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * Zabbix chaneged some of the operator labels in version 7.0.0 but the value equivalents remained the same. | |
| * Zabbix changed some of the operator labels in version 7.0.0 but the value equivalents remained the same. |
| export function processHostTags(hosts: Host[]): Tag[] { | ||
| const hostTags = hosts.map((host) => host.tags || []).flat(); | ||
| // deduplicate tags | ||
| const uniqueHostTags = _.uniqBy(hostTags, (tag) => `${tag.tag}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't tag.tag is already string? Why are we using backticks?
| useEffect(() => { | ||
| onHostTagFilterChange(hostTagFilters); | ||
| }, [hostTagFilters]); | ||
| return ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return ( | |
| return ( |
| evalTypeValue?: ZabbixTagEvalType; | ||
| onHostTagFilterChange?: (hostTags: HostTagFilter[]) => void; | ||
| onHostTagEvalTypeChange?: (evalType: ZabbixTagEvalType) => void; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } | |
| } | |
| <Input | ||
| value={filter.value} | ||
| onChange={(evt: FormEvent<HTMLInputElement>) => | ||
| setHostTagFilterValue(index, evt?.currentTarget?.value) | ||
| } | ||
| width={19} | ||
| /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A short placeholder would be useful. At first glance I've missed what I need to do with the input field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my each keystroke it sends another request to the backend. Can we have a debounce logic?


Sumary
When dealing with multiple hosts, it can be hard for customers filter through and figure out which host to query metric data from. This PR aims to make this easier by adding support for host tags so that there is another layer of filtering / grouping applied for hosts.
Detailed explanation
Adds new UI components to allow adding one or more host tag filter, and a switch to choose between
AND/ORandORoperators when using more than one filter following Zabbix's UI:Screen.Recording.2025-12-09.at.3.19.14.PM.mov
Screen.Recording.2025-12-09.at.3.21.14.PM.mov
Modifies the existing
getHostsfunction to make a call to the backend with a few additional parameters toextend(essentially extract) the host tags for a given selected group. No backend changes were required for this.Why
To make it easier for customers to query metric data when dealing with multiple hosts.
How to test
Metrics/.*/for Groups, checking the returnedHoststhey should all be thereAND/ORtoORyou should see how the values returned forHostchangesFuture work
Adding variable support for host tags once this is completed.
Fixes: https://github.com/orgs/grafana/projects/457/views/40?pane=issue&itemId=3609900134&issue=grafana%7Coss-big-tent-squad%7C126 and #927