Using CMK Status Data in Grafana

Sometimes you want status data (Host Up/Down, Service OK/Warn/Crit) from CMK in your Grafana dashboards, but as of now CMK does not provide this data with its Grafana plugin.
But there is a workaround.

You need an automation user as described in Users, roles and permissions - Authorization and user configuration and the Grafana CSV datasource plugin CSV plugin for Grafana | Grafana Labs

After installing the Grafana plugin, create a new CSV Datasource in Grafana.

For “URL” use the URL to your CMK instance’s view.py. For example https://mycmkserver.com/myinstance/check_mk/view.py
For “Custom query parameters” insert output_format=csv&_username=myautomationuser&_secret=mysecret&view_name=allhosts
replaceing _username and _secret values with your automation user’s credentials.

This would return status data for “all hosts”. You can change the view_name to any CMK view or you can omit it here and configure it inside the Grafana panel.

Save the datasource and start by creating/editing a dashboard and adding a panel.

Inside the Grafana panel choose the CSV Datasource you created previously and set the “Delimiter” to “Semicolon”!

If you omitted the view_name in the datasource you can add it in “Params” here.


You can add other CMK URL parameters, like hostgroups etc. here as Key/Value pairs.

Note: As status data does not have timestamps, you can mostly just use the “Table” visualization for displaying the data.

7 Likes

Thanks for sharing, that’s a really good approach.

The instructions have worked so far, but unfortunately I don’t understand how I can find out the key and value information. view_all and hosts work, what other variations are there? Especially if I want to display certain servers and not all hosts and all servives. Do any of you have an idea? Thanks a lot

Basically you can use any view, that you can “Export”, “Export CSV”.
I use “Display”, “This page without navigation” to see the URL Parameters for views.

Thanks for your reply.
What i dont get what i have to type in at Key and Value.

For example is this the URL link for one specific Host

http://(Server)/monitoring/check_mk/view.py?

host=(hostname)site=monitoring&view_name=host

And this for a specific service for one host

host=(hostname)&service=Memory&site=monitoring&view_name=service

Thank you!

I’m not exactly sure what you’re trying to accomplish.
For getting status data from a single host, I would use something like this

For a single service

that was exactly what I was looking for.
I didn’t know that I could insert several lines for parameters
Thanks a lot.