Merge branch 'master' into backend-functions
@@ -239,15 +239,9 @@ jobs:
|
|||||||
docker:
|
docker:
|
||||||
- image: circleci/python:2.7
|
- image: circleci/python:2.7
|
||||||
steps:
|
steps:
|
||||||
- run:
|
|
||||||
name: install git lfs
|
|
||||||
command: 'curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash'
|
|
||||||
- run: sudo apt-get install git-lfs
|
|
||||||
- run: git lfs install
|
|
||||||
- run: sudo pip install --upgrade pip
|
- run: sudo pip install --upgrade pip
|
||||||
- run: sudo pip install mkdocs
|
- run: sudo pip install mkdocs
|
||||||
- checkout
|
- checkout
|
||||||
- run: git lfs fetch --all
|
|
||||||
- run: cd docs && mkdocs build --clean
|
- run: cd docs && mkdocs build --clean
|
||||||
- persist_to_workspace:
|
- persist_to_workspace:
|
||||||
root: .
|
root: .
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## [4.1.5] - 2021-05-18
|
||||||
|
### Fixed
|
||||||
|
- Fix compatibility with Zabbix 5.4, [#1188](https://github.com/alexanderzobnin/grafana-zabbix/issues/1188)
|
||||||
|
|
||||||
## [4.1.4] - 2021-03-09
|
## [4.1.4] - 2021-03-09
|
||||||
### Fixed
|
### Fixed
|
||||||
- `Field/Standard options/Display name` stopped working in 4.1 release, [#1130](https://github.com/alexanderzobnin/grafana-zabbix/issues/1130)
|
- `Field/Standard options/Display name` stopped working in 4.1 release, [#1130](https://github.com/alexanderzobnin/grafana-zabbix/issues/1130)
|
||||||
|
|||||||
@@ -1,4 +1,13 @@
|
|||||||
# SQL Data Source Configuration
|
# Direct DB Data Source Configuration
|
||||||
|
|
||||||
|
## Security notes
|
||||||
|
|
||||||
|
Grafana-Zabbix plugin can use MySQL, Postgres or InfluxDB (if Zabbix configured to store history data in InfluxDB) data sources to query history and trend data directly from Zabbix database. In order to execute queries, plugin needs only read access to the `history`, `history_uint`, `trends` and `trends_uint` tables. To make connection more secure and prevent unnecessary data disclosure, it's highly recommended to grant read access to only that tables. But if you want to use this 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. Here's MySQL example:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
GRANT SELECT ON zabbix.* TO 'grafana'@'grafana-host' identified by 'password';
|
||||||
|
```
|
||||||
|
|
||||||
## MySQL
|
## MySQL
|
||||||
|
|
||||||
@@ -9,29 +18,12 @@ In order to use _Direct DB Connection_ feature you should configure SQL data sou
|
|||||||
Select _MySQL_ data source type and provide your database host address and port (3306 is default for MySQL). Fill
|
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.
|
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';
|
|
||||||
```
|
|
||||||
|
|
||||||
## PostgreSQL
|
## PostgreSQL
|
||||||
|
|
||||||
Select _PostgreSQL_ data source type and provide your database host address and port (5432 is default). Fill
|
Select _PostgreSQL_ data source type and provide your database host address and port (5432 is default). Fill
|
||||||
database name (usually, `zabbix`) and specify credentials.
|
database name (usually, `zabbix`) and specify credentials.
|
||||||
|
|
||||||

|

|
||||||
### Security notes
|
|
||||||
|
|
||||||
Make sure you use read-only user for Zabbix database.
|
|
||||||
|
|
||||||
## InfluxDB
|
## InfluxDB
|
||||||
|
|
||||||
|
|||||||
@@ -4,53 +4,48 @@ page_description: Plugin configuration instructions for Grafana-Zabbix.
|
|||||||
# Configuration
|
# Configuration
|
||||||
|
|
||||||
## Enable plugin
|
## Enable plugin
|
||||||
|
|
||||||
Go to the plugins in Grafana side panel, select _Apps_ tab, then select _Zabbix_, open _Config_
|
Go to the plugins in Grafana side panel, select _Apps_ tab, then select _Zabbix_, open _Config_
|
||||||
tab and enable plugin.
|
tab and enable plugin.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Configure Zabbix data source
|
## Configure Zabbix data source
|
||||||
|
|
||||||
After enabling plugin you can add Zabbix data source.
|
After enabling plugin you can add Zabbix data source.
|
||||||
|
|
||||||
To add new Zabbix data source open _Data Sources_ in side panel, click _Add data source_ and
|
To add new Zabbix data source open _Data Sources_ in side panel, click _Add data source_ and select _Zabbix_ from dropdown list.
|
||||||
select _Zabbix_ from dropdown list.
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### HTTP settings
|
### HTTP settings
|
||||||
|
|
||||||
- **Url**: set Zabbix API url (full path with `api_jsonrpc.php`).
|
- **URL**: set Zabbix API url (full path with `api_jsonrpc.php`).
|
||||||
- **Access**:
|
- **Access**: Set to `Server (default)`.
|
||||||
- **Proxy**: access via Grafana backend
|
|
||||||
- **Direct**: access from browser.
|
|
||||||
- **Http Auth**: configure if you use proxy authentication.
|
- **Http Auth**: configure if you use proxy authentication.
|
||||||
- **Basic Auth**:
|
- **Basic Auth**:
|
||||||
- **With Credentials**:
|
- **With Credentials**:
|
||||||
|
|
||||||
Proxy access means that the Grafana backend will proxy all requests from the browser, and send them on to the Data Source. This is useful because it can eliminate CORS (Cross Origin Site Resource) issues, as well as eliminate the need to disseminate authentication details to the Data Source to the browser.
|
|
||||||
|
|
||||||
Direct access is still supported because in some cases it may be useful to access a Data Source directly depending on the use case and topology of Grafana, the user, and the Data Source.
|
|
||||||
|
|
||||||
### Zabbix API details
|
### Zabbix API details
|
||||||
|
|
||||||
- **User** and **Password**: setup login for access to Zabbix API. Also check user's permissions
|
- **Username** and **Password**: setup login for access to Zabbix API. Also check user's permissions
|
||||||
in Zabbix if you can't get any groups and hosts in Grafana.
|
in Zabbix if you cannot get any groups and hosts in Grafana.
|
||||||
- **Trends**: enable if you use Zabbix 3.x or patch for trends
|
- **Trends**: enable if you use Zabbix 3.x or newer. This option is
|
||||||
support in Zabbix 2.x ([ZBXNEXT-1193](https://support.zabbix.com/browse/ZBXNEXT-1193)). This option
|
|
||||||
strictly recommended for displaying long time periods (more than few days, depending of your item's
|
strictly recommended for displaying long time periods (more than few days, depending of your item's
|
||||||
updating interval in Zabbix) because few days of item history contains tons of points. Using trends
|
updating interval in Zabbix), because few days of item history contains tons of points. Using trends
|
||||||
will increase Grafana performance.
|
will increase Grafana performance.
|
||||||
- **After**: time after which trends will be used.
|
- **After**: time after which trends will be used.
|
||||||
Best practice is to set this value to your history storage period (7d, 30d, etc). Default is **7d** (7 days).
|
Best practice is to set this value to your history storage period (7d, 30d, etc). Default is **7d** (7 days).
|
||||||
You can set the time in Grafana format. Valid time specificators are:
|
You can set the time in Grafana format. Valid time specificators are:
|
||||||
- **h** - hours
|
- **h** - hours
|
||||||
- **d** - days
|
- **d** - days
|
||||||
- **M** - months
|
- **M** - months
|
||||||
- **Range**: Time range width after which trends will be used instead of history.
|
- **Range**: Time range width after which trends will be used instead of history.
|
||||||
It's better to set this value in range of 4 to 7 days to prevent loading large amount of history data.
|
It's better to set this value in range of 4 to 7 days to prevent loading large amount of history data.
|
||||||
Default is 4 days.
|
Default is 4 days.
|
||||||
- **Cache TTL**: plugin caches some api requests for increasing performance. Set this
|
- **Cache TTL**: plugin caches some api requests for increasing performance. Set this
|
||||||
value to desired cache lifetime (this option affect data like items list).
|
value to desired cache lifetime (this option affect data like items list).
|
||||||
|
- **Timeout**: Zabbix connection timeout in seconds. Default is 30.
|
||||||
|
|
||||||
### Direct DB Connection
|
### Direct DB Connection
|
||||||
|
|
||||||
@@ -70,47 +65,18 @@ Read [how to configure](./direct_db_datasource) SQL data source in Grafana.
|
|||||||
|
|
||||||
### Other
|
### Other
|
||||||
|
|
||||||
|
- **Disable acknowledges for read-only users**: disable ability to acknowledge problems from Grafana for non-editors.
|
||||||
|
|
||||||
- **Disable data alignment**: disable time series data alignment. This feature aligns points based on item update interval. For instance, if value collected once per minute, then timestamp of the each point will be set to the start of corresponding minute. This alignment required for proper work of the stacked graphs. If you don't need stacked graphs and want to get exactly the same timestamps as in Zabbix, then you can disable this feature. Also, data alignment can be toggled for each query individually, in the query options.
|
- **Disable data alignment**: disable time series data alignment. This feature aligns points based on item update interval. For instance, if value collected once per minute, then timestamp of the each point will be set to the start of corresponding minute. This alignment required for proper work of the stacked graphs. If you don't need stacked graphs and want to get exactly the same timestamps as in Zabbix, then you can disable this feature. Also, data alignment can be toggled for each query individually, in the query options.
|
||||||
|
|
||||||
Then click _Add_ - datasource will be added and you can check connection using
|
Then click _Add_ - data source will be added and you can check connection using _Test Connection_ button. This feature can help to find some mistakes like invalid user name or password, wrong api url.
|
||||||
_Test Connection_ button. This feature can help to find some mistakes like invalid user name
|
|
||||||
or password, wrong api url.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## Import example dashboards
|
## Import example dashboards
|
||||||
|
|
||||||
You can import dashboard examples from _Dashboards_ tab in plugin config.
|
You can import dashboard examples from _Dashboards_ tab in the data source config.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## 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:
|
|
||||||
|
|
||||||
```php
|
|
||||||
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
|
|
||||||
|
|
||||||
```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
|
## Note about Browser Cache
|
||||||
|
|
||||||
After updating plugin, clear browser cache and reload application page. See details
|
After updating plugin, clear browser cache and reload application page. See details
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ Grafana in couple with Grafana-Zabbix plugin allows to create great dashboards.
|
|||||||
features:
|
features:
|
||||||
|
|
||||||
- Rich graphing features
|
- Rich graphing features
|
||||||
|
- Select multiple metrics [by using Regex](../guides/gettingstarted/#multiple-items-on-one-graph)
|
||||||
- Create interactive and reusable dashboards with [template variables](../guides/templating/)
|
- Create interactive and reusable dashboards with [template variables](../guides/templating/)
|
||||||
- Show events on graphs with [Annotations](http://docs.grafana.org/reference/annotations/)
|
- Show events on graphs with [Annotations](http://docs.grafana.org/reference/annotations/)
|
||||||
- Select multiple metrics [by using Regex](../guides/gettingstarted/#multiple-items-on-one-graph)
|
|
||||||
- Display active problems with Triggers panel
|
|
||||||
- Transform and shape your data with [metric processing functions](../reference/functions/) (Avg, Median, Min, Max, Multiply, Summarize, Time shift, Alias)
|
- Transform and shape your data with [metric processing functions](../reference/functions/) (Avg, Median, Min, Max, Multiply, Summarize, Time shift, Alias)
|
||||||
- Find problems faster with [Alerting](../reference/alerting/) feature
|
- Mix metrics from multiple data sources in the same dashboard or panel
|
||||||
- Mix metrics from multiple data sources in the same dashboard or even graph
|
- Create [alerts](../reference/alerting/) in Grafana
|
||||||
|
- Display triggers with Problems panel
|
||||||
- Discover and share [dashboards](https://grafana.com/dashboards) in the official library
|
- Discover and share [dashboards](https://grafana.com/dashboards) in the official library
|
||||||
|
|||||||
4
docs/sources/img/.gitattributes
vendored
@@ -1,4 +0,0 @@
|
|||||||
*.png filter=lfs diff=lfs merge=lfs -text
|
|
||||||
*.jpg filter=lfs diff=lfs merge=lfs -text
|
|
||||||
*.psd filter=lfs diff=lfs merge=lfs -text
|
|
||||||
*.svg filter=lfs diff=lfs merge=lfs -text
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 109 KiB |
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 596 KiB |
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 405 KiB |
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 480 KiB |
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 535 KiB |
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 443 KiB |
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 440 KiB |
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 705 KiB |
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 459 KiB |
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 377 KiB |
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 530 KiB |
|
Before Width: | Height: | Size: 130 B After Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 107 KiB |
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 82 KiB |
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 82 KiB |
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 128 KiB |
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 95 KiB |
|
Before Width: | Height: | Size: 130 B After Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 130 B After Width: | Height: | Size: 14 KiB |
@@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:32e4945bd571cb260a27822d073344539e65e4d31ba0f4908386916f41317560
|
|
||||||
size 197334
|
|
||||||
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 195 KiB |
|
Before Width: | Height: | Size: 130 B After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 501 KiB |
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 626 KiB |
@@ -3,7 +3,12 @@ page_description: Installation instructions for Grafana-Zabbix.
|
|||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
|
## Choosing plugin version
|
||||||
|
|
||||||
|
Currently (in version `4.x.x`) Grafana-Zabbix plugin supports Zabbix versions `4.x` and `5.x`. Zabbix `3.x` is not supported anymore. Generally, latest plugin should work with latest Grafana version, but if you have any compatibility issue, try to downgrade to previous minor release of Grafana. It's also helpful to report (but use search first to avoid duplicating issues) compatibility issues to the [GitHub](https://github.com/alexanderzobnin/grafana-zabbix/issues).
|
||||||
|
|
||||||
## Using grafana-cli tool
|
## Using grafana-cli tool
|
||||||
|
|
||||||
Get list of available plugins
|
Get list of available plugins
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@@ -25,6 +30,12 @@ Read more about installing plugins in [Grafana docs](https://grafana.com/docs/pl
|
|||||||
|
|
||||||
**WARNING!** The only reliable installation method is `grafana-cli`. Any other way should be treated as a workaround and doesn't provide any backward-compatibility guaranties.
|
**WARNING!** The only reliable installation method is `grafana-cli`. Any other way should be treated as a workaround and doesn't provide any backward-compatibility guaranties.
|
||||||
|
|
||||||
|
## From github releases
|
||||||
|
|
||||||
|
Starting from version 4.0, each plugin release on GitHub contains packaged plugin. To install it, go to [releases](https://github.com/alexanderzobnin/grafana-zabbix/releases) page, pick release you want to get and click on `Assests`. Built plugin packaged into `zip` archive having name `alexanderzobnin-zabbix-app-x.x.x.zip`. Download it, unpack into your Grafana plugins directory and restart grafana server. Each plugin package contains [digital signature](https://grafana.com/docs/grafana/latest/plugins/plugin-signatures/) which allows Grafana to verify that plugin was published by it's owner and files are not modified.
|
||||||
|
|
||||||
|
**Note**: `since` plugin version 4.0, `grafana-cli` downloads plugin from GitHub release. So downloading plugin package manually, you get the same package as via `grafana-cli`.
|
||||||
|
|
||||||
## From github repo
|
## From github repo
|
||||||
**WARNING!** This way doesn't work anymore (`dist/` folder was removed from git). Use `grafana-cli` or build plugin from sources.
|
**WARNING!** This way doesn't work anymore (`dist/` folder was removed from git). Use `grafana-cli` or build plugin from sources.
|
||||||
|
|
||||||
|
|||||||
@@ -2,32 +2,42 @@ page_title: Run Grafana-Zabbix from master
|
|||||||
page_description: Building instructions for Grafana-Zabbix.
|
page_description: Building instructions for Grafana-Zabbix.
|
||||||
|
|
||||||
# Run from master
|
# Run from master
|
||||||
|
|
||||||
If you want to build a package yourself, or contribute - here is a guide for how to do that.
|
If you want to build a package yourself, or contribute - here is a guide for how to do that.
|
||||||
|
|
||||||
### Dependencies
|
## Prerequisites
|
||||||
|
|
||||||
- NodeJS LTS
|
- [NodeJS](https://nodejs.org/) LTS
|
||||||
|
- [Go](https://golang.org/) version 1.14 or above
|
||||||
|
|
||||||
### Building plugin
|
## Building
|
||||||
|
|
||||||
|
### Install dependencies
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install -g yarn
|
make install
|
||||||
yarn install --pure-lockfile
|
|
||||||
yarn build
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### To build plugin and rebuild on file change
|
### Build plugin (for all platforms)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn watch
|
make dist
|
||||||
|
```
|
||||||
|
|
||||||
|
### To run frontend and rebuild on file change
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make run-frontend
|
||||||
|
```
|
||||||
|
|
||||||
|
### To run backend and rebuild on file change
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make run-backend
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run tests
|
### Run tests
|
||||||
```bash
|
|
||||||
yarn test
|
|
||||||
```
|
|
||||||
|
|
||||||
### Run tests on file change
|
|
||||||
```bash
|
```bash
|
||||||
yarn jest
|
make test
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -5,6 +5,6 @@ page_description: Upgrade instructions for Grafana-Zabbix.
|
|||||||
|
|
||||||
## Upgrade from 2.x
|
## Upgrade from 2.x
|
||||||
|
|
||||||
After [enabling](configuration.md#enable-plugin) Zabbix App go to _Data Sources_, open your configured Zabbix
|
After [enabling](../../configuration/#enable-plugin) Zabbix App go to _Data Sources_, open your configured Zabbix
|
||||||
data source end select _Zabbix_ from _Type_ list again. This is needed because plugin id was changed
|
data source end select _Zabbix_ from _Type_ list again. This is needed because plugin id was changed
|
||||||
in Grafana 3.0.
|
in Grafana 3.0.
|
||||||
|
|||||||
@@ -1,41 +1,12 @@
|
|||||||
# Alerting
|
# Alerting
|
||||||
|
|
||||||
Since version 4.0 [Grafana](https://grafana.com/) has its own alerting engine.
|
## Alerting overview
|
||||||
|
|
||||||
> Alerting in Grafana allows you to attach rules to your dashboard panels. When you save the dashboard Grafana will extract the alert rules into a separate alert rule storage and schedule them for evaluation.
|
Grafana-Zabbix plugin introduces [alerting](https://grafana.com/docs/grafana/latest/alerting/) feature support in 4.0 release. Work still in progress, so current alerting support has some limitations:
|
||||||
|
|
||||||
> In the alert tab of the graph panel you can configure how often the alert rule should be evaluated and the conditions that need to be met for the alert to change state and trigger its notifications.
|
- Only `Metrics` query mode supported.
|
||||||
|
- Queries with data processing functions are not supported.
|
||||||
|
|
||||||
Read more about alerting feature in [Grafana docs](http://docs.grafana.org/alerting/rules/).
|
## Creating alerts
|
||||||
|
|
||||||
On the other hand, Zabbix has its own alerting system with triggers, events and notifications. And the best way is to
|
In order to create alert, open panel query editor and switch to the `Alert` tab. Click `Create Alert` button, configure alert and save dashboard. Refer to [Grafana](https://grafana.com/docs/grafana/latest/alerting/create-alerts/) documentation for more details about alerts configuration.
|
||||||
combine benefits of these systems into Zabbix plugin for Grafana. So how it works you'll ask? Grafana alerting feature
|
|
||||||
consists of two main parts:
|
|
||||||
|
|
||||||
- **Alerting execution engine**
|
|
||||||
The alert rules are evaluated in the Grafana backend in a scheduler and query execution engine that is part of core
|
|
||||||
Grafana. Only some data sources are supported right now. They include Graphite, Prometheus, InfluxDB and OpenTSDB.
|
|
||||||
- **Alerting visualisations**
|
|
||||||
Alerts highlight panels with problems and it can easily be found on the dashboard.
|
|
||||||
|
|
||||||
So Zabbix plugin doesn't use execution engine and doesn't allow to configure rules in Grafana. But it fetches information
|
|
||||||
about triggers related to metrics at particular panel and fires alert state for these panels.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
So there are three possible cases for each panel:
|
|
||||||
|
|
||||||
1. Panel contains Zabbix items which are used in triggers:
|
|
||||||
- At least one of these related triggers is in the PROBLEM state.
|
|
||||||
In this case panel will be highlighted with the red glow and broken heart icon.
|
|
||||||
- All triggers are in the OK state.
|
|
||||||
Panel will be displayed with green heart icon without highlighting.
|
|
||||||
1. There aren't triggers related to items on panel.
|
|
||||||
Panel will be displayed without any changes.
|
|
||||||
|
|
||||||
Note, that only triggers with severity above than configured at Data Source config page will be used for panel state
|
|
||||||
calculation.
|
|
||||||
|
|
||||||
Also plugin can extract thresholds from trigger expression and set it on graph. You can enable this feature
|
|
||||||
in Data Source config. Thresholds are parts of panel JSON data, so it will be stored in backend if you save dashboard,
|
|
||||||
but plugin marks this thresholds with special tag, so it will be changed or deleted if you change it in Zabbix.
|
|
||||||
|
|||||||
@@ -167,7 +167,10 @@ func (ds *ZabbixDatasourceInstance) getItems(ctx context.Context, groupFilter st
|
|||||||
}
|
}
|
||||||
|
|
||||||
apps, err := ds.getApps(ctx, groupFilter, hostFilter, appFilter)
|
apps, err := ds.getApps(ctx, groupFilter, hostFilter, appFilter)
|
||||||
if err != nil {
|
// Apps not supported in Zabbix 5.4 and higher
|
||||||
|
if isAppMethodNotFoundError(err) {
|
||||||
|
apps = []map[string]interface{}{}
|
||||||
|
} else if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var appids []string
|
var appids []string
|
||||||
@@ -505,3 +508,12 @@ func isNotAuthorized(err error) bool {
|
|||||||
strings.Contains(message, "Not authorised.") ||
|
strings.Contains(message, "Not authorised.") ||
|
||||||
strings.Contains(message, "Not authorized.")
|
strings.Contains(message, "Not authorized.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isAppMethodNotFoundError(err error) bool {
|
||||||
|
if err == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
message := err.Error()
|
||||||
|
return message == `Method not found. Incorrect API "application".`
|
||||||
|
}
|
||||||
|
|||||||
@@ -122,6 +122,7 @@
|
|||||||
<label class="gf-form-label query-keyword width-7">Application</label>
|
<label class="gf-form-label query-keyword width-7">Application</label>
|
||||||
<input type="text"
|
<input type="text"
|
||||||
ng-model="ctrl.target.application.filter"
|
ng-model="ctrl.target.application.filter"
|
||||||
|
ng-disabled="ctrl.appFilterDisabled()"
|
||||||
bs-typeahead="ctrl.getApplicationNames"
|
bs-typeahead="ctrl.getApplicationNames"
|
||||||
ng-blur="ctrl.onTargetBlur()"
|
ng-blur="ctrl.onTargetBlur()"
|
||||||
data-min-length=0
|
data-min-length=0
|
||||||
|
|||||||
@@ -512,4 +512,8 @@ export class ZabbixQueryController extends QueryCtrl {
|
|||||||
this.init();
|
this.init();
|
||||||
this.targetChanged();
|
this.targetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
appFilterDisabled() {
|
||||||
|
return !this.zabbix.supportsApplications();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,12 +46,14 @@ export class ZabbixAPIConnector {
|
|||||||
//////////////////////////
|
//////////////////////////
|
||||||
|
|
||||||
request(method: string, params?: any) {
|
request(method: string, params?: any) {
|
||||||
return this.backendAPIRequest(method, params).then(response => {
|
if (!this.version) {
|
||||||
return response?.data?.result;
|
return this.initVersion().then(() => this.request(method, params));
|
||||||
});
|
}
|
||||||
|
|
||||||
|
return this.backendAPIRequest(method, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
backendAPIRequest(method: string, params: any = {}) {
|
async backendAPIRequest(method: string, params: any = {}) {
|
||||||
const requestOptions: BackendSrvRequest = {
|
const requestOptions: BackendSrvRequest = {
|
||||||
url: this.backendAPIUrl,
|
url: this.backendAPIUrl,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -74,14 +76,15 @@ export class ZabbixAPIConnector {
|
|||||||
requestOptions.headers.Authorization = this.requestOptions.basicAuth;
|
requestOptions.headers.Authorization = this.requestOptions.basicAuth;
|
||||||
}
|
}
|
||||||
|
|
||||||
return getBackendSrv().datasourceRequest(requestOptions);
|
const response = await getBackendSrv().datasourceRequest(requestOptions);
|
||||||
|
return response?.data?.result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Zabbix API version
|
* Get Zabbix API version
|
||||||
*/
|
*/
|
||||||
getVersion() {
|
getVersion() {
|
||||||
return this.request('apiinfo.version');
|
return this.backendAPIRequest('apiinfo.version');
|
||||||
}
|
}
|
||||||
|
|
||||||
initVersion(): Promise<string> {
|
initVersion(): Promise<string> {
|
||||||
@@ -147,7 +150,11 @@ export class ZabbixAPIConnector {
|
|||||||
return this.request('host.get', params);
|
return this.request('host.get', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getApps(hostids): Promise<any[]> {
|
async getApps(hostids): Promise<any[]> {
|
||||||
|
if (semver.gte(this.version, '5.4.0')) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
output: 'extend',
|
output: 'extend',
|
||||||
hostids: hostids
|
hostids: hostids
|
||||||
|
|||||||
@@ -19,4 +19,6 @@ export interface ZabbixConnector {
|
|||||||
getApps: (groupFilter?, hostFilter?, appFilter?) => any;
|
getApps: (groupFilter?, hostFilter?, appFilter?) => any;
|
||||||
getItems: (groupFilter?, hostFilter?, appFilter?, itemFilter?, options?) => any;
|
getItems: (groupFilter?, hostFilter?, appFilter?, itemFilter?, options?) => any;
|
||||||
getSLA: (itservices, timeRange, target, options?) => any;
|
getSLA: (itservices, timeRange, target, options?) => any;
|
||||||
|
|
||||||
|
supportsApplications: () => boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
import semver from 'semver';
|
||||||
import * as utils from '../utils';
|
import * as utils from '../utils';
|
||||||
import responseHandler from '../responseHandler';
|
import responseHandler from '../responseHandler';
|
||||||
import { CachingProxy } from './proxy/cachingProxy';
|
import { CachingProxy } from './proxy/cachingProxy';
|
||||||
@@ -29,7 +30,7 @@ const REQUESTS_TO_CACHE = [
|
|||||||
|
|
||||||
const REQUESTS_TO_BIND = [
|
const REQUESTS_TO_BIND = [
|
||||||
'getHistory', 'getTrend', 'getMacros', 'getItemsByIDs', 'getEvents', 'getAlerts', 'getHostAlerts',
|
'getHistory', 'getTrend', 'getMacros', 'getItemsByIDs', 'getEvents', 'getAlerts', 'getHostAlerts',
|
||||||
'getAcknowledges', 'getITService', 'getVersion', 'acknowledgeEvent', 'getProxies', 'getEventAlerts',
|
'getAcknowledges', 'getITService', 'acknowledgeEvent', 'getProxies', 'getEventAlerts',
|
||||||
'getExtendedEventData', 'getScripts', 'executeScript', 'getValueMappings'
|
'getExtendedEventData', 'getScripts', 'executeScript', 'getValueMappings'
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -40,6 +41,7 @@ export class Zabbix implements ZabbixConnector {
|
|||||||
getHistoryDB: any;
|
getHistoryDB: any;
|
||||||
dbConnector: any;
|
dbConnector: any;
|
||||||
getTrendsDB: any;
|
getTrendsDB: any;
|
||||||
|
version: string;
|
||||||
|
|
||||||
getHistory: (items, timeFrom, timeTill) => Promise<any>;
|
getHistory: (items, timeFrom, timeTill) => Promise<any>;
|
||||||
getTrend: (items, timeFrom, timeTill) => Promise<any>;
|
getTrend: (items, timeFrom, timeTill) => Promise<any>;
|
||||||
@@ -54,7 +56,6 @@ export class Zabbix implements ZabbixConnector {
|
|||||||
getEventAlerts: (eventids) => Promise<any>;
|
getEventAlerts: (eventids) => Promise<any>;
|
||||||
getExtendedEventData: (eventids) => Promise<any>;
|
getExtendedEventData: (eventids) => Promise<any>;
|
||||||
getMacros: (hostids: any[]) => Promise<any>;
|
getMacros: (hostids: any[]) => Promise<any>;
|
||||||
getVersion: () => Promise<string>;
|
|
||||||
getValueMappings: () => Promise<any>;
|
getValueMappings: () => Promise<any>;
|
||||||
|
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
@@ -168,6 +169,17 @@ export class Zabbix implements ZabbixConnector {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getVersion() {
|
||||||
|
if (!this.version) {
|
||||||
|
this.version = await this.zabbixAPI.initVersion();
|
||||||
|
}
|
||||||
|
return this.version;
|
||||||
|
}
|
||||||
|
|
||||||
|
supportsApplications() {
|
||||||
|
return this.version ? semver.lt(this.version, '5.4.0') : true;
|
||||||
|
}
|
||||||
|
|
||||||
getItemsFromTarget(target, options) {
|
getItemsFromTarget(target, options) {
|
||||||
const parts = ['group', 'host', 'application', 'item'];
|
const parts = ['group', 'host', 'application', 'item'];
|
||||||
const filters = _.map(parts, p => target[p].filter);
|
const filters = _.map(parts, p => target[p].filter);
|
||||||
@@ -218,7 +230,12 @@ export class Zabbix implements ZabbixConnector {
|
|||||||
/**
|
/**
|
||||||
* Get list of applications belonging to given groups and hosts.
|
* Get list of applications belonging to given groups and hosts.
|
||||||
*/
|
*/
|
||||||
getAllApps(groupFilter, hostFilter) {
|
async getAllApps(groupFilter, hostFilter) {
|
||||||
|
await this.getVersion();
|
||||||
|
if (!this.supportsApplications()) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
return this.getHosts(groupFilter, hostFilter)
|
return this.getHosts(groupFilter, hostFilter)
|
||||||
.then(hosts => {
|
.then(hosts => {
|
||||||
const hostids = _.map(hosts, 'hostid');
|
const hostids = _.map(hosts, 'hostid');
|
||||||
@@ -226,11 +243,14 @@ export class Zabbix implements ZabbixConnector {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getApps(groupFilter?, hostFilter?, appFilter?): Promise<AppsResponse> {
|
async getApps(groupFilter?, hostFilter?, appFilter?): Promise<AppsResponse> {
|
||||||
|
await this.getVersion();
|
||||||
|
const skipAppFilter = !this.supportsApplications();
|
||||||
|
|
||||||
return this.getHosts(groupFilter, hostFilter)
|
return this.getHosts(groupFilter, hostFilter)
|
||||||
.then(hosts => {
|
.then(hosts => {
|
||||||
const hostids = _.map(hosts, 'hostid');
|
const hostids = _.map(hosts, 'hostid');
|
||||||
if (appFilter) {
|
if (appFilter && !skipAppFilter) {
|
||||||
return this.zabbixAPI.getApps(hostids)
|
return this.zabbixAPI.getApps(hostids)
|
||||||
.then(apps => filterByQuery(apps, appFilter));
|
.then(apps => filterByQuery(apps, appFilter));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||