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

Variables: Host-filter with multiple values #247

Open
CVT-Adam opened this issue Apr 15, 2024 · 2 comments
Open

Variables: Host-filter with multiple values #247

CVT-Adam opened this issue Apr 15, 2024 · 2 comments

Comments

@CVT-Adam
Copy link

CVT-Adam commented Apr 15, 2024

I am attempting to use a grafana variable in a dashboard to pull out several host that have a similar name.

variable is edfahost and definition is host: {"host_name_regex":{"value":".*EDFA.*","negated":false}}.

In grafana the variable works in that the preview is pulling the 3 host correctly from my system. The issue comes when I attempt to use it in a graph as a filter -> hostname - $edfahost. To me it looks like the "host": "{822-ERNE-GLEN-EDFA,822-ERNE-VALD-EDFA,835-VALD-ERNE-EDFA}" portion shown below is the issue. If i use the checkmk swagger interactive api and hone this exact data down to just one host it works just fine but as soon as there is multiple host it fails.

checkmk: 2.2.0p22
grafana-checkmk-datasource: 3.2.1
grafana: 10.4.1

{
  "request": {
    "method": "POST",
    "url": "api/datasources/proxy/uid/GufJd9F4k/rest/check_mk/api/1.0/domain-types/metric/actions/filter/invoke",
    "data": {
      "filter": {
        "host": {
          "host": "{822-ERNE-GLEN-EDFA,822-ERNE-VALD-EDFA,835-VALD-ERNE-EDFA}"
        },
        "service": {
          "service": "Booster AMP"
        }
      },
      "aggregation": "off",
      "type": "single_metric",
      "time_range": {
        "start": "2024-04-14T17:21:44.000Z",
        "end": "2024-04-15T17:18:44.000Z"
      },
      "metric_id": "BoosterTemperature"
    },
    "hideFromInspector": false
  },
  "response": {
    "time_range": {
      "start": "2024-04-14T17:21:44+00:00",
      "end": "2024-04-15T17:18:44+00:00"
    },
    "step": 60,
    "metrics": []
  }
}
@BenediktSeidl BenediktSeidl changed the title Host viable not submitting correctly through checkmk api from grafana Variables: Host-filter with multiple values Apr 16, 2024
@BenediktSeidl
Copy link
Contributor

There is currently no support for multi-value-selection of variables in the host filter field.

As far as I can see you are using a commercial edition of checkmk, then you can use the following workaround: Instead of the "Hostname" Filter you can use the "Hostname Regex" and use the following as the value: ${variable_name:regex} then Grafana will build a regex for you: https://grafana.com/docs/grafana/latest/dashboards/variables/variable-syntax/#regex and Checkmk should return the metrics for multiple hosts.

I've edited the formatting of your post and modified the title, I hope this does not alter the intention of your issue.

I'm not 100% sure, but it seems to me you might use {$variable_name}, but the correct syntax is ${variable_name}.

@fabriceverkor
Copy link

On my side, I'm using 2.2.0p14.cre. So ${variable_name:regex} does not work.
We were using Pnp4Nagios plugin instead, but it not working anymore (sni/grafana-pnp-datasource#77). So were stucked for the moment.

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

3 participants