-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
Prometheus Datasource: Improve Prom query variable editor #58292
Conversation
Drone build failed: https://drone.grafana.net/grafana/grafana-enterprise/41131 |
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.
After I check this locally I will approve it.
const labelNamesRegex = /^label_names\(\)\s*$/; | ||
const labelValuesRegex = /^label_values\((?:(.+),\s*)?([a-zA-Z_][a-zA-Z0-9_]*)\)\s*$/; | ||
const metricNamesRegex = /^metrics\((.+)\)\s*$/; | ||
const queryResultRegex = /^query_result\((.+)\)\s*$/; |
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.
Are those all the options that we can use? I remember we can use scalar()
too.
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.
While scalar() is a function provided by Prometheus, these are function created by Grafana to list variables. The scalar() function can be used in the query_result() function like so, query_result(scalar(<some prom query>))
Drone build failed: https://drone.grafana.net/grafana/grafana-enterprise/41931 |
Drone build failed: https://drone.grafana.net/grafana/grafana-enterprise/41935 |
This pull request was removed from the 9.3.0-beta1 milestone because 9.3.0-beta1 is currently being released. |
@itsmylife I think I will have to remove the flavor and version check for that function label_values! |
public/app/plugins/datasource/prometheus/components/VariableQueryEditor.tsx
Outdated
Show resolved
Hide resolved
public/app/plugins/datasource/prometheus/migrations/variableMigration.ts
Outdated
Show resolved
Hide resolved
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 2 weeks if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
…not set there flavor and version
…ev named getTagKeys()
…eryEditor.tsx Co-authored-by: Galen Kistler <109082771+gtk-grafana@users.noreply.github.com>
da6da15
to
f37e340
Compare
* add prom query var editor with tests and migrations * fix migration, now query not expr * fix label_values migration * remove comments * fix label_values() variables order * update UI and use more clear language * fix tests * use null coalescing operators * allow users to query label values with label and metric if they have not set there flavor and version * use enums instead of numbers for readability * fix label&metrics switch * update type in qv editor * reuse datasource function to get all label names, getLabelNames(), prev named getTagKeys() * use getLabelNames in the query var editor * make label_values() variables label and metric more readable in the migration * fix tooltip for label_values to remove API reference * clean up tooltips and allow newlines in query_result function * change function wording and exprType to query type/qryType for readability * update prometheus query variable docs * Update public/app/plugins/datasource/prometheus/components/VariableQueryEditor.tsx Co-authored-by: Galen Kistler <109082771+gtk-grafana@users.noreply.github.com> --------- Co-authored-by: Galen Kistler <109082771+gtk-grafana@users.noreply.github.com>
Fixes #59559 (allow newlines in Prom query result variable query editor)
Fixes https://github.com/grafana/observability-metrics-squad/issues/48
What is this feature?
This changes the prometheus query variable editor to a group of selects and inputs to better explain the functions, arguments, and endpoint calls used in the prometheus variable queries.
Previous single input:
New function select and variable inputs:
Full proposal here.
Why do we need this feature?
This is in line with the Grafana 10 goal of "Getting Started." More clarity around creating variables in Prometheus will help onboard new customers.
Who is this feature for?
This feature is for anyone using the Prometheus datasource plugin who wants to create template variables.
This is for all users of prometheus datasource plugin, from expert to beginner.
Special notes for your reviewer:
label_names()