Skip to content

Installation

Alexander Zobnin edited this page Jan 5, 2016 · 14 revisions

Grafana 1.9.x

Download latest 1.x.x release and unpack into <your grafana installation>/plugins/datasource/. Then edit Grafana config.js:

  • Add dependencies

    plugins: {
      panels: [],
      dependencies: ['datasource/zabbix/datasource', 'datasource/zabbix/queryCtrl'],
    }
    
  • Add datasource and setup your Zabbix API url, username and password

    datasources: {
      ...
      },
      zabbix: {
        type: 'ZabbixAPIDatasource',
        url: 'http://www.zabbix.org/zabbix/api_jsonrpc.php',
        username: 'guest',
        password: ''
      }
    },
    

Grafana 2.0.x

Download source code from last 2.0.x release or master branch and put zabbix directory into <your grafana-2 installation>/public/app/plugins/datasource/.

  • Edit plugin.json (located in zabbix directory) and set your username and password

    {
      "pluginType": "datasource",
      "name": "Zabbix",
    
      "type": "zabbix",
      "serviceName": "ZabbixAPIDatasource",
    
      "module": "plugins/datasource/zabbix/datasource",
    
      "partials": {
        "config": "app/plugins/datasource/zabbix/partials/config.html",
        "query": "app/plugins/datasource/zabbix/partials/query.editor.html",
        "annotations": "app/plugins/datasource/zabbix/partials/annotations.editor.html"
      },
    
      "username": "guest",
      "password": "",
    
      "metrics": true,
      "annotations": true
    }
    
    
  • Important! Check paths in partials section and ensure that it correctly set.

  • Restart grafana server.

  • Add zabbix datasource in Grafana's "Data Sources" menu (see Data Sources docs for more info).

  • Set Zabbix API url (specify full path to api_jsonrpc.php, for example http://www.zabbix.org/zabbix/api_jsonrpc.php).

  • Important! Change Access to direct!

add datasource

Grafana 2.1.x and 2.5.x

Download last 2.x.x release for relative Grafana version zabbix directory into <your grafana installation>/public/app/plugins/datasource/.

Open Data Sources in side panel, click Add new and select Zabbix from Type dropdown list.

add new zabbix datasource

Set Zabbix api url (full path with api_jsonrpc.php), set user and password for access to api and set other options if needed. Then click Add - datasource will be added and you can check connection using Test Connection button.

edit zabbix datasource

Test Connection

This feature can help to find some mistakes like invalid user name or password, wrong api url.

Test Connection - error

Updating from Grafana 2.0

If you update plugin and Grafana from 2.0.x versions to 2.1.x you can replace plugin.json file by new version from sources. No more needed to edit this file to configure datasource - all settings now at datasource configuration page in Grafana. In 2.5.x you must do it because plugin.json has breaking changes.

Trends support

If you use patch for trends support (ZBXNEXT-1193), you must enable this feature at datasource configuration page:

edit zabbix datasource

Use trends from option define period when switch to trends from history. You can set the time in Grafana format: 7d for 7 days or for example 2d for 2 days. Valid time specificators are:
h - hours
d - days
M - months

Note for Zabbix 2.2 or less

Zabbix API (api_jsonrpc.php) before zabbix 2.4 don't allow cross-domain requests (CORS). And you can get HTTP error 412 (Precondition Failed). To fix it add this code to api_jsonrpc.php immediately after the copyright

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Content-Type');
header('Access-Control-Allow-Methods: POST');
header('Access-Control-Max-Age: 1000');

if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
	return;
}

before

require_once dirname(__FILE__).'/include/func.inc.php';
require_once dirname(__FILE__).'/include/classes/core/CHttpRequest.php';

Full fix listing. For more info see zabbix issues ZBXNEXT-1377 and ZBX-8459.

Note about browser cache

After updating plugin, clear browser cache and reload application page. See details for Chrome, Firefox. You need to clear cache only, not cookies, history and other data.