-
Notifications
You must be signed in to change notification settings - Fork 14
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
Support metrics with special characters in query builder #131
Comments
Sorry guys ... I got it all wrong in #128 :D Actually how it should be is to just escape the names from query builder: Like for our case:
vs
So just escape the names and take them into account when parsing or selecting the metrics from dropdown. (based on idea from: https://stackoverflow.com/questions/52537029/escape-special-characters-in-prometheus-metric-names) |
* add support metrics with special symbols #131 * refactor: change CompletionType from type to enum
Support metrics with special characters has been added at datasource starting from v0.6.0. Closing the feature request as done. |
Looks great, thank you! |
@Loori-R I tried and it's actually a lot better. However for such metrics we are unable to select label filters in dropdown. Raw query works (and we have 4 labels (color, host, ...):
When changing from raw query to builder it populates the fields correctly. Just dropdown does not resolve all the possible labels. Like when filtering labels or fetching them it does not take \ into account ? |
hi @Loori-R , I found that the query builder doesn't support label names containing dot. In the following example, |
Hello, @chenlujjj! Thanks for your message. It looks like we missed handling special characters in labels. I've reopened it. |
Hello @Loori-R , @hagen1778 , Thanks for your work, seems you have fixed it, cool! May I know when the fix will be released so that we can install it into our Grafana ? Does it also fix the auto-completion and syntax highlighting when the label names contain dots? |
Hi @chenlujjj ! Can you try to install the latest release? It contains the bug fix which should solve your issue. |
Hello @dmitryk-dk , @Loori-R , the new release do fix the issue of query builder, thanks. However, there are still problems with auto-completion and syntax highlighting:
|
@chenlujjj thank you! We will take a look into this issue |
hi @dmitryk-dk wondering what's the progress of this issue ? |
Hi! Sorry for the delay. We will take a look as soon as possible, maybe by the end of next week. |
As mentioned in #128, the query builder generates invalid code when the metric name contains special characters, such as slash (/) or dash (-), and quite possibly others.
When picking a metric with special characters (e.g.
foo/bar
) from the drop-down, the builder should write the query as{__name__="foo/bar"}
instead of justfoo/bar
. When switching back from Code to Builder, the label filter__name__=
should also be translated to the Metric drop-down.I suppose the distinction for the metric names could be done by a regex. Prometheus docs state that a valid metric name should match
[a-zA-Z_:][a-zA-Z0-9_:]*
. The expression for compatible metric names could be a bit broader than that, like[a-z-A-Z0-9_:.]
or something like that. Anything not matching this expression would be written as a label filter.(Beware of quotes in metric names - if anyone should be crazy enough to have them.)
The text was updated successfully, but these errors were encountered: