diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 265089d..1666dad 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -18,6 +18,7 @@ pages: - Installation: - 'Installation': 'installation/index.md' - 'Configuration': 'installation/configuration.md' + - 'SQL Data Source Configuration': 'installation/configuration-sql.md' - 'Upgrade': 'installation/upgrade.md' - 'Troubleshooting': 'installation/troubleshooting.md' - User Guides: diff --git a/docs/sources/img/installation-datasource_config.png b/docs/sources/img/installation-datasource_config.png index f5ee615..ab3648d 100644 --- a/docs/sources/img/installation-datasource_config.png +++ b/docs/sources/img/installation-datasource_config.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6b58742637f58519a5fab038db0c15b5525d1d330fe5e4a1de954b72f4f1cc3e -size 225446 +oid sha256:367b5fa51e9d05eb87afedd4ef6ed8ea1ce0e095f94bfdc58ebe6744fbaca71c +size 131343 diff --git a/docs/sources/img/installation-mysql_ds_config.png b/docs/sources/img/installation-mysql_ds_config.png new file mode 100644 index 0000000..3c8d221 --- /dev/null +++ b/docs/sources/img/installation-mysql_ds_config.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0bac25f3d28c74f1f309476120bc67275e15f420e3343f0ff9668ead3a1e6170 +size 227988 diff --git a/docs/sources/installation/configuration-sql.md b/docs/sources/installation/configuration-sql.md new file mode 100644 index 0000000..a1cf37a --- /dev/null +++ b/docs/sources/installation/configuration-sql.md @@ -0,0 +1,22 @@ +# SQL Data Source Configuration + +In order to use _Direct DB Connection_ feature you should configure SQL data source first. + +![Configure MySQL data source](../img/installation-mysql_ds_config.png) + +Select _MySQL_ data source type and provide your database host address and port (3306 is default for MySQL). Fill +database name (usually, `zabbix`) and specify credentials. + +## Security notes + +As you can see in _User Permission_ note, Grafana doesn't restrict any queries to the database. So you should be careful +and create a special user with limited access to Zabbix database. Grafana-Zabbix plugin uses only `SELECT` queries to +`history`, `history_uint`, `trends` and `trends_uint` tables. So it's reasonable to grant only SELECT privileges to +these tables for grafana user. But if you want to use this MySQL data source for querying another data, you can +grant SELECT privileges to entire zabbix database. + +Also, all queries are invoked by grafana-server, so you can restrict connection to only grafana host. + +```sql +GRANT SELECT ON zabbix.* TO 'grafana'@'grafana-host' identified by 'password'; +``` diff --git a/docs/sources/installation/configuration.md b/docs/sources/installation/configuration.md index ae4f78d..9d7135e 100644 --- a/docs/sources/installation/configuration.md +++ b/docs/sources/installation/configuration.md @@ -52,7 +52,23 @@ Direct access is still supported because in some cases it may be useful to acces - **Cache TTL**: plugin caches some api requests for increasing performance. Set this value to desired cache lifetime (this option affect data like items list). +### Direct DB Connection + +Direct DB Connection allows plugin to use existing SQL data source for querying history data directly from Zabbix +database. This way usually faster than pulling data from Zabbix API, especially on the wide time ranges, and reduces +amount of data transfered. + +Read [how to configure](/installation/configuration-sql) SQL data source in Grafana. + +- **Enable**: enable Direct DB Connection. +- **SQL Data Source**: Select SQL Data Source for Zabbix database. + +#### Supported databases + +Now only **MySQL** is supported by Grafana. + ### Alerting + - **Enable alerting**: enable limited alerting support. - **Add thresholds**: get thresholds info from zabbix triggers and add it to graphs. For example, if you have trigger `{Zabbix server:system.cpu.util[,iowait].avg(5m)}>20`, threshold will be set to 20. @@ -65,10 +81,12 @@ or password, wrong api url. ![Test Connection](../img/installation-test_connection.png) ## Import example dashboards + You can import dashboard examples from _Dashboards_ tab in plugin config. ![Import dashboards](../img/installation-plugin-dashboards.png) ## Note about 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: @@ -83,17 +101,20 @@ if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { return; } ``` + before ```php require_once dirname(__FILE__).'/include/func.inc.php'; require_once dirname(__FILE__).'/include/classes/core/CHttpRequest.php'; ``` + [Full fix listing](https://gist.github.com/alexanderzobnin/f2348f318d7a93466a0c). For more details see zabbix issues [ZBXNEXT-1377](https://support.zabbix.com/browse/ZBXNEXT-1377) and [ZBX-8459](https://support.zabbix.com/browse/ZBX-8459). ## Note about Browser Cache + After updating plugin, clear browser cache and reload application page. See details for [Chrome](https://support.google.com/chrome/answer/95582), [Firefox](https://support.mozilla.org/en-US/kb/how-clear-firefox-cache). You need to clear cache