diff --git a/docs/sources/configuration/index.md b/docs/sources/configuration/index.md index 602b7c3..c96c3ec 100644 --- a/docs/sources/configuration/index.md +++ b/docs/sources/configuration/index.md @@ -61,11 +61,11 @@ amount of data transfered. Read [how to configure](./sql_datasource) SQL data source in Grafana. - **Enable**: enable Direct DB Connection. -- **SQL Data Source**: Select SQL Data Source for Zabbix database. +- **Data Source**: Select Data Source for Zabbix history database. #### Supported databases -**MySQL** and **PostgreSQL** are supported by Grafana. +**MySQL**, **PostgreSQL**, **InfluxDB** are supported as sources of historical data for the plugin. ### Alerting diff --git a/docs/sources/reference/direct-db-connection.md b/docs/sources/reference/direct-db-connection.md index 16112a6..ec91ed5 100644 --- a/docs/sources/reference/direct-db-connection.md +++ b/docs/sources/reference/direct-db-connection.md @@ -1,6 +1,6 @@ # Direct DB Connection -Since version 4.3 Grafana can use MySQL as a native data source. The Grafana-Zabbix plugin can use this data source for querying data directly from a Zabbix database. +Since version 4.3 Grafana can use MySQL as a native data source. The idea of Direct DB Connection is that Grafana-Zabbix plugin can use this data source for querying data directly from a Zabbix database. One of the most resource intensive queries for Zabbix API is the history query. For long time intervals `history.get` returns a huge amount of data. In order to display it, the plugin should adjust time series resolution @@ -10,6 +10,8 @@ time series, but that data should be loaded and processed on the client side fir Also, many users see better performance from direct database queries versus API calls. This could be the result of several reasons, such as the additional PHP layer and additional SQL queries (user permissions checks). +Direct DB Connection feature allows using database transparently for querying historical data. Now Grafana-Zabbix plugin supports few databases for history queries: MySQL, PostgreSQL and InfluxDB. Regardless of the database type, idea and data flow remain the same. + ## Data Flow This chart illustrates how the plugin uses both Zabbix API and the MySQL data source for querying different types @@ -76,6 +78,18 @@ ORDER BY time ASC As you can see, the Grafana-Zabbix plugin uses aggregation by a given time interval. This interval is provided by Grafana and depends on the panel width in pixels. Thus, Grafana displays the data in the proper resolution. +## InfluxDB +Zabbix supports loadable modules which makes possible to write history data into an external database. There's a [module](https://github.com/i-ky/effluence) for InfluxDB written by [@i-ky](https://github.com/i-ky) which can export history into InfluxDB in real-time. + +InfluxDB Query Example: +```sql +SELECT MEAN("value") +FROM "history" +WHERE ("itemid" = '10073' OR "itemid" = '10074') + AND "time" >= 1540000000000s AND "time" <= 1540000000060s +GROUP BY time(10s), "itemid" fill(none) +``` + ## Functions usage with Direct DB Connection There's only one function that directly affects the backend data. This function is `consolidateBy`. Other functions work on the client side and transform data that comes from the backend. So you should clearly understand that this is pre-aggregated data (by AVG, MAX, MIN, etc).