Skip to content
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 for "multi-select" values in Grafana #1

Open
nrhtr opened this issue Feb 22, 2020 · 0 comments
Open

Support for "multi-select" values in Grafana #1

nrhtr opened this issue Feb 22, 2020 · 0 comments

Comments

@nrhtr
Copy link

nrhtr commented Feb 22, 2020

Hi,

I noticed that hisser doesn't appear to support queries like {serverA,serverB}.cpu.usage
This is particularly useful for selecting multiple values in Grafana drop-down lists.

I was able to get this "working" with the following patch, although I imagine there's a much better way to go about this (it also probably misses a lot of edge cases):

diff --git a/hisser/metrics.py b/hisser/metrics.py
index 6f947bb..20cefd5 100644
--- a/hisser/metrics.py
+++ b/hisser/metrics.py
@@ -200,6 +200,8 @@ class MetricIndex:
         for idx, part in enumerate(query.split('.')):
             if '*' in part or '[' in part:
                 queries.append(('.{}'.format(idx), '=~', '!' + part))
+            elif '{' in part:
+                queries.append(('.{}'.format(idx), '=~', ':' + part.strip('{}')))
             else:
                 queries.append(('.{}'.format(idx), '=', part))

Is this something you'd look to support going forward?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant