docs: Direct DB Connection configuration

This commit is contained in:
Alexander Zobnin
2017-07-23 11:18:04 +03:00
parent 3f13aab9b8
commit 9334b27eea
5 changed files with 49 additions and 2 deletions

View File

@@ -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';
```

View File

@@ -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