-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
Graphite: Expand metric names for variables #33694
Conversation
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.
Is this for V8.0?
Co-authored-by: achatterjee-grafana <[email protected]>
Co-authored-by: achatterjee-grafana <[email protected]>
Yes! Sorry, forgot about the milestone. Updated and adding "add to changelog" label. |
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.
Added change suggestions.
Co-authored-by: achatterjee-grafana <[email protected]>
Co-authored-by: achatterjee-grafana <[email protected]>
Co-authored-by: achatterjee-grafana <[email protected]>
Co-authored-by: achatterjee-grafana <[email protected]>
Co-authored-by: achatterjee-grafana <[email protected]>
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.
Doc looks ok, we can refine it further if needed.
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.
looks good to me 👍 !
* Allow expanding metrics names in variable queries * Simplify docs * Update docs/sources/datasources/graphite.md Co-authored-by: achatterjee-grafana <[email protected]> * Update docs/sources/datasources/graphite.md Co-authored-by: achatterjee-grafana <[email protected]> * Update docs/sources/datasources/graphite.md Co-authored-by: achatterjee-grafana <[email protected]> * Update docs/sources/datasources/graphite.md Co-authored-by: achatterjee-grafana <[email protected]> * Update docs/sources/datasources/graphite.md Co-authored-by: achatterjee-grafana <[email protected]> * Update docs/sources/datasources/graphite.md Co-authored-by: achatterjee-grafana <[email protected]> * Update docs/sources/datasources/graphite.md Co-authored-by: achatterjee-grafana <[email protected]> * Clean up docs Co-authored-by: achatterjee-grafana <[email protected]>
* Allow expanding metrics names in variable queries * Simplify docs * Update docs/sources/datasources/graphite.md Co-authored-by: achatterjee-grafana <[email protected]> * Update docs/sources/datasources/graphite.md Co-authored-by: achatterjee-grafana <[email protected]> * Update docs/sources/datasources/graphite.md Co-authored-by: achatterjee-grafana <[email protected]> * Update docs/sources/datasources/graphite.md Co-authored-by: achatterjee-grafana <[email protected]> * Update docs/sources/datasources/graphite.md Co-authored-by: achatterjee-grafana <[email protected]> * Update docs/sources/datasources/graphite.md Co-authored-by: achatterjee-grafana <[email protected]> * Update docs/sources/datasources/graphite.md Co-authored-by: achatterjee-grafana <[email protected]> * Clean up docs Co-authored-by: achatterjee-grafana <[email protected]>
What this PR does / why we need it:
Variable query for Graphite allows to search for metrics, however it's quite limited because results contain possible values but occurring only at the last level of the query (please check the example below). This PR introduces "expand" function allowing to use expand API to get the full name of matching metrics. In combination with regex it will allow to extract any part of the metric name.
Example:
Metrics:
prod.servers.server001.cpu
prod.servers.server002.cpu
test.servers.server001.cpu
Search results: (normal query is already available, expanded query support is added in this PR)
*
expand(*)
*.servers
expand(*.servers)
test.servers
expand(test.servers)
*.servers.*
expand(*.servers.*)
test.servers.*
expand(test.servers.*)
*.servers.*.cpu
expand(*.servers.*.cpu)
Why is it important?
The available implementation allows to handle only simpler (though most common) cases where only the last part of the metric should become a variable value. However, it's not possible extract other parts of metric names.
Imagine you needed a dropdown to select the environment (
prod
ortest
in the example above). Normal search could capture the top level name but only of all metrics you have. Let's say besidesprod.*
andtest.*
metrics you hadstatsd.*
. With normal query "statsd" would also be captured. With "expand" it's possible to write do this:Query:
expand(*.servers)
Regex:
/^(\w+).*/
Expand will first find only metrics that have
servers
in the second level and then regex will capture only environment names.How to test it?
Run:
make devenv sources=graphite
Send some sample data: https://gist.github.com/ifrost/ada07138775d5295fba169d27abddf8d
Create a dashboard with following query:
$env.servers.$server.cpu
Create variables:
env
:and
server
:Which issue(s) this PR fixes:
Fixes #2343
Special notes for your reviewer: Same example is included in updated docs.