Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

@nrhtr

Description

@nrhtr

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions