Grafana Action Icons in CheckMK

 

 

Grafana allows for dynamic datasource queries by making use of variables. This functionality gives the ability to create graph/dashboard templates that may be re-used. For instance, switching your view between a production or development environment while maintaining the same underlying queries.

In CheckMK it is possible to create custom action buttons on hosts or services. Leveraging this, quick links can be created to integrate external resources such as ticketing systems, or in this case, Grafana.

This article will provide a simple example of such an integration by creating a dashboard template and an action icon for a host.

Grafana Setup

First, we will set up a variable for "hostname". For simplicity here we will use a "Constant".
These can be found in the dashboard settings.

2019-08-09-095441_1329x562_scrot.png

Building the Query

Once the variables are in place, they will need to be inserted into a query so we can use them.
These values of the variables are interpolated in Grafana before the query is run against the datasource.

For this dashboard, we will create a single graph for CPU utilization.

2019-08-09-095931_1057x282_scrot.png

In the query "[[hostname]]" will be expanded to what is set for the "hostname" variable.
This can be set via a drop down menu on the dashboard, or in the URL simply by appending "&var-hostname=myhostname".

Note that these graphs are blank by default as there will be no variable initially set.

2019-08-09-101423_1301x524_scrot.png


Creating a Check_MK Action.

An "action" will need to be created in CheckMK. This action can be applied to specific hosts or services by using rules.

Actions are managed under "Global Settings" > "User Interface" > "Custom Icons and Actions".

2019-08-09-105059_1036x641_scrot.png

CheckMK allows several macros to be used in actions. Such as host name, service name.
In the action above, we are creating a link to our host dashboard and setting the host name variable in the URL.

Once the action has been created we can now apply it to hosts.

These rules can be found under "Host and Service Parameters" > "Monitoring Configuration" > "Various" > "Custom icons or actions for hosts in status GUI".

When creating the rule, we choose from our list of configured actions.

2019-08-09-104736_1116x144_scrot.png

Once applied, this action icon will show up on our selected hosts.
2019-08-09-104938_559x84_scrot.png
Following this link will navigate to the Grafana dashboard with the host name variable set.
2019-08-09-105134_972x452_scrot.png

 

 

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.