Open source Enterprise Grafana Cloud

Configure the Zabbix data source

This document explains how to configure the Zabbix data source in Grafana, including authentication, trends, Direct DB Connection, and provisioning.

Before you begin

Before configuring the data source, ensure you have:

  • Grafana permissions: Organization administrator role.
  • Zabbix API URL: The full URL to your Zabbix API endpoint, including the api_jsonrpc.php path (for example, http://zabbix.example.com/api_jsonrpc.php).
  • Zabbix credentials: A username and password for a Zabbix user, or an API token. Verify the user has permissions to access the host groups and hosts you want to query in Grafana.

Add the data source

  1. Click Connections in the left-side menu.
  2. Click Add new connection.
  3. Type Zabbix in the search bar.
  4. Select Zabbix.
  5. Click Add new data source.

Configure connection settings

SettingDescription
NameThe display name for this data source instance.
DefaultToggle to make this the default data source for new panels.
URLThe full URL of your Zabbix API endpoint, including api_jsonrpc.php. For example: http://zabbix.example.com/api_jsonrpc.php.

Configure authentication

The Zabbix data source supports two authentication methods. Select the method in the Auth type drop-down under the Zabbix Connection section.

User and password

Use a Zabbix user account to authenticate with the API.

SettingDescription
UsernameThe Zabbix username.
PasswordThe Zabbix password. Stored securely in Grafana.

API token

Use a Zabbix API token to authenticate. API tokens are available in Zabbix 5.4 and later.

SettingDescription
API TokenThe Zabbix API token. Stored securely in Grafana.

Trends store aggregated historical data (average, minimum, and maximum per hour) and are recommended for displaying long time ranges. Enable trends to improve query performance when viewing data older than your history retention period. Find these settings under Additional settings > Trends.

SettingDescription
Enable TrendsToggle to enable querying trends data for long time ranges.
AfterTime after which trends are used instead of history. Set this to your history storage period. Default: 7d. Valid time specifiers: h (hours), d (days), M (months).
RangeTime range width after which trends are used instead of history. Set this between 4 and 7 days to prevent loading large amounts of history data. Default: 4d.

Configure Zabbix API settings

These settings control caching and connection behavior for the Zabbix API. Find them under Additional settings > Zabbix API.

SettingDescription
Cache TTLHow long the plugin caches metric names in memory. Default: 1h.
TimeoutZabbix API connection timeout in seconds. Default: 30.

Query timeout

Under Additional settings > Query Options, you can set the maximum execution time for database queries initiated by the plugin.

SettingDescription
Query TimeoutMaximum execution time in seconds for database queries. Queries exceeding this limit are automatically terminated. Default: 60.

Configure Direct DB Connection

Direct DB Connection lets the plugin query history and trend data directly from the Zabbix database through an existing Grafana SQL or InfluxDB data source. This bypasses the Zabbix API for historical data, which is faster on wide time ranges and reduces the amount of data transferred.

Find these settings under Additional settings > Direct DB Connection.

SettingDescription
Enable Direct DB ConnectionToggle to enable direct database queries for history data.
Data SourceSelect an existing MySQL, PostgreSQL, or InfluxDB data source configured in Grafana that points to your Zabbix database.
Retention Policy(InfluxDB only) The retention policy name for fetching long-term stored data. Leave blank if you use only the default retention policy.

Set up a database data source

Before enabling Direct DB Connection, you need a MySQL, PostgreSQL, or InfluxDB data source in Grafana that connects to your Zabbix database. The plugin uses this data source to execute history and trend queries.

To add a database data source:

  1. Click Connections in the left-side menu.
  2. Click Add new connection.
  3. Select MySQL, PostgreSQL, or InfluxDB.
  4. Configure the connection to your Zabbix database. The database name is typically zabbix.
  5. Click Save & test.

For detailed configuration, refer to the MySQL, PostgreSQL, or InfluxDB data source documentation.

Database security

The plugin needs only read access to the history, history_uint, trends, and trends_uint tables. To minimize data exposure, grant read access to only those tables. All queries run from the Grafana server, so you can also restrict connections to the Grafana host.

MySQL example:

SQL
GRANT SELECT ON zabbix.history TO 'grafana'@'<GRAFANA_HOST>' IDENTIFIED BY '<PASSWORD>';
GRANT SELECT ON zabbix.history_uint TO 'grafana'@'<GRAFANA_HOST>' IDENTIFIED BY '<PASSWORD>';
GRANT SELECT ON zabbix.trends TO 'grafana'@'<GRAFANA_HOST>' IDENTIFIED BY '<PASSWORD>';
GRANT SELECT ON zabbix.trends_uint TO 'grafana'@'<GRAFANA_HOST>' IDENTIFIED BY '<PASSWORD>';

If you also want to use this data source for other queries, you can grant SELECT privileges to the entire Zabbix database:

SQL
GRANT SELECT ON zabbix.* TO 'grafana'@'<GRAFANA_HOST>' IDENTIFIED BY '<PASSWORD>';

Configure other settings

These settings are under Additional settings > Other.

SettingDescription
Disable acknowledges for read-only usersPrevents non-editor users from acknowledging problems in Grafana.
Disable data alignmentDisables automatic alignment of time series points to the start of their collection interval. Data alignment is required for stacked graphs to render correctly. You can also toggle this per query in the query options.

Verify the connection

Click Save & test to verify the connection. A successful test displays the message “Zabbix API version” followed by the detected version number. If Direct DB Connection is enabled, the message also includes the database connector type.

If the test fails, refer to the troubleshooting guide for common connection issues and solutions.

Provision the data source

You can define and configure the Zabbix data source in YAML files as part of Grafana’s provisioning system. For more information about provisioning, refer to Provision Grafana.

The following example provisions a Zabbix data source with Direct DB Connection using a MySQL database:

YAML
apiVersion: 1

datasources:
  - name: Zabbix
    type: alexanderzobnin-zabbix-datasource
    url: http://<ZABBIX_HOST>/zabbix/api_jsonrpc.php
    jsonData:
      authType: userLogin
      username: <ZABBIX_USERNAME>
      trends: true
      trendsFrom: '7d'
      trendsRange: '4d'
      cacheTTL: '1h'
      dbConnectionEnable: true
      dbConnectionDatasourceName: <DB_DATASOURCE_NAME>
      dbConnectionRetentionPolicy: ''
      disableReadOnlyUsersAck: false
      disableDataAlignment: false
    secureJsonData:
      password: <ZABBIX_PASSWORD>
    version: 1
    editable: false

  - name: MySQL Zabbix
    type: mysql
    url: <MYSQL_HOST>:3306
    user: <MYSQL_USER>
    jsonData:
      database: zabbix
    secureJsonData:
      password: <MYSQL_PASSWORD>

Provisioning configuration options

The following table lists all available jsonData and secureJsonData fields for the Zabbix data source:

FieldTypeDescription
authTypejsonDataAuthentication method. Values: userLogin (default) or token.
usernamejsonDataZabbix username (for userLogin authentication).
passwordsecureJsonDataZabbix password (for userLogin authentication).
apiTokensecureJsonDataZabbix API token (for token authentication).
trendsjsonDataEnable trends. Default: true.
trendsFromjsonDataTime after which trends are used. Default: 7d.
trendsRangejsonDataTime range width for switching to trends. Default: 4d.
cacheTTLjsonDataCache lifetime for metric names. Default: 1h.
timeoutjsonDataZabbix API connection timeout in seconds. Default: 30.
queryTimeoutjsonDataMaximum execution time for database queries in seconds. Default: 60.
dbConnectionEnablejsonDataEnable Direct DB Connection. Default: false.
dbConnectionDatasourceNamejsonDataName of the Grafana data source for the Zabbix database.
dbConnectionRetentionPolicyjsonDataInfluxDB retention policy name for long-term data.
disableReadOnlyUsersAckjsonDataDisable acknowledges for read-only users. Default: false.
disableDataAlignmentjsonDataDisable time series data alignment. Default: false.

For detailed MySQL and PostgreSQL provisioning options, refer to the MySQL provisioning and PostgreSQL provisioning documentation.

Provision with Terraform

You can provision the Zabbix data source using the Grafana Terraform provider. The following example creates a Zabbix data source with user and password authentication:

hcl
resource "grafana_data_source" "zabbix" {
  type = "alexanderzobnin-zabbix-datasource"
  name = "Zabbix"
  url  = "http://<ZABBIX_HOST>/zabbix/api_jsonrpc.php"

  json_data_encoded = jsonencode({
    username             = "<ZABBIX_USERNAME>"
    trends               = true
    trendsFrom           = "7d"
    trendsRange          = "4d"
    cacheTTL             = "1h"
    dbConnectionEnable   = false
    disableDataAlignment = false
  })

  secure_json_data_encoded = jsonencode({
    password = "<ZABBIX_PASSWORD>"
  })
}

For more information about the Grafana Terraform provider, refer to the Grafana provider documentation.

Next steps