HowTo : graph Icinga SLA with Grafana

  1. Requirements: SLA Availability Reporting for Icinga

  2. Add in Grafana a MySQL datasource:

Type: MySQL
Host: icinga:3306
Database: icinga
User: grafanaReader
Password: password

  1. Create GRANTS on the Icinga DB:

CREATE USER ‘grafanaReader’ IDENTIFIED BY ‘password’;
GRANT SELECT ON icinga.icinga_objects TO ‘grafanaReader’;
GRANT SELECT ON icinga.icinga_hosts TO ‘grafanaReader’;
GRANT EXECUTE ON FUNCTION icinga.icinga_sla_state_availability TO ‘grafanaReader’;

  1. Create a new dashboard (example: SLA) with 3 variables with mysql as datasource:

$host : SELECT alias FROM icinga_host
$service: SELECT name2 FROM icinga_objects WHERE name1=‘$host’ and is_active=1;
$objectid: SELECT object_id FROM icinga_objects WHERE name1=“$host” AND name2=“$service”;

  1. Add a Single Stats panel with this query:

SELECT icinga_sla_state_availability( $objectid, 0, DATE_FORMAT($__timeFrom(), ‘%Y-%m-%d’),DATE_FORMAT($__timeTo()
, ‘%Y-%m-%d’), 4747) * 100 AS state_ok FROM icinga_objects WHERE name1=“$host” AND name2=“$service”

  1. Customize