zabbix接合Grafana画图
1. Grafana简介
Grafana是一款用Go语言开发的开源数据可视化工具,可以做数据监控和数据统计,带有告警功能。目前使用grafana的公司有很多,如paypal、ebay、intel等。
2. Grafana介绍
Grafana是一个跨平台的开源的度量分析和可视化工具,可以通过将采集的数据查询然后可视化的展示,并及时通知。它主要有以下六大特点:
1、展示方式:快速灵活的客户端图表,面板插件有许多不同方式的可视化指标和日志,官方库中具有丰富的仪表盘插件,比如热图、折线图、图表等多种展示方式;
2、数据源:Graphite,InfluxDB,OpenTSDB,Prometheus,Elasticsearch,CloudWatch和KairosDB等;
3、通知提醒:以可视方式定义最重要指标的警报规则,Grafana将不断计算并发送通知,在数据达到阈值时通过Slack、PagerDuty等获得通知;
4、混合展示:在同一图表中混合使用不同的数据源,可以基于每个查询指定数据源,甚至自定义数据源;
5、注释:使用来自不同数据源的丰富事件注释图表,将鼠标悬停在事件上会显示完整的事件元数据和标记;
6、过滤器:Ad-hoc过滤器允许动态创建新的键/值过滤器,这些过滤器会自动应用于使用该数据源的所有查询。
3. 部署Grafana
Grafana是一个开源的指标量监测和可视化工具,官方网站为:https://grafana.com/。Grafana的安装非常简单,官方就有软件仓库可以直接使用,也可以通过docker镜像等方式直接本地启动。还可以直接下载rpm包、二进制包进行安装。大家可以从 https://grafana.com/grafana/download 下载rpm安装包。
[root@server ~]# wget https://dl.grafana.com/oss/release/grafana-7.3.4-1.x86_64.rpm
[root@server ~]# yum install grafana-7.3.4-1.x86_64.rpm
设置开机自启
[root@server ~]# systemctl daemon-reload
[root@server ~]# systemctl start grafana-server
[root@server ~]# systemctl enable --now grafana-server
Synchronizing state of grafana-server.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable grafana-server
Created symlink /etc/systemd/system/multi-user.target.wants/grafana-server.service → /usr/lib/systemd/system/grafana-server.service.
[root@server ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10050 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10051 0.0.0.0:*
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 128 *:3000 *:*
LISTEN 0 80 *:3306 *:*
安装grafana-zabbix插件(Using grafana-cli tool)
[root@server ~]# grafana-cli plugins list-remote
id: abhisant-druid-datasource version: 0.0.6
id: aceiot-svg-panel version: 0.0.11
id: ae3e-plotly-panel version: 0.4.0
id: agenty-flowcharting-panel version: 0.9.1
id: aidanmountford-html-panel version: 0.0.2
id: akumuli-datasource version: 1.3.12
id: alexanderzobnin-zabbix-app version: 4.1.5
id: alexandra-trackmap-panel version: 1.2.6
id: andig-darksky-datasource version: 1.0.2
id: anodot-datasource version: 2.0.3
id: anodot-panel version: 1.0.5
id: aquaqanalytics-kdbadaptor-datasource version: 1.0.2
id: auxmoney-waterfall-panel version: 1.0.6
id: ayoungprogrammer-finance-datasource version: 1.0.1
id: belugacdn-app version: 1.2.1
id: bessler-pictureit-panel version: 1.0.1
id: bilibala-echarts-panel version: 2.2.4
id: blackmirror1-singlestat-math-panel version: 1.1.8
id: blackmirror1-statusbygroup-panel version: 1.1.2
id: bmchelix-ade-datasource version: 1.0.0
id: bosun-app version: 0.0.29
id: briangann-datatable-panel version: 1.0.3
id: briangann-gauge-panel version: 0.0.9
id: camptocamp-prometheus-alertmanager-datasource version: 1.0.0
id: ccin2p3-riemann-datasource version: 0.1.5
id: citilogics-geoloop-panel version: 1.1.2
id: clarity89-finnhub-datasource version: 0.1.1
id: cloudflare-app version: 0.2.1
id: cloudspout-button-panel version: 7.0.23
id: cognitedata-datasource version: 2.4.0
id: corpglory-progresslist-panel version: 1.0.6
id: dalmatinerdb-datasource version: 1.0.5
id: dalvany-image-panel version: 2.3.0
id: ddurieux-glpi-app version: 1.3.1
id: devicehive-devicehive-datasource version: 2.0.2
id: devopsprodigy-kubegraf-app version: 1.5.2
id: digiapulssi-breadcrumb-panel version: 1.1.7
id: digiapulssi-organisations-panel version: 1.3.1
id: digrich-bubblechart-panel version: 1.2.0
id: dlopes7-appdynamics-datasource version: 2.1.4
id: doitintl-bigquery-datasource version: 2.0.2
id: factry-untimely-panel version: 0.2.0
id: farski-blendstat-panel version: 1.0.3
id: fastweb-openfalcon-datasource version: 1.0.1
id: fatcloud-windrose-panel version: 0.7.1
id: fetzerch-sunandmoon-datasource version: 0.2.1
id: fifemon-graphql-datasource version: 1.3.0
id: flant-statusmap-panel version: 0.4.1
id: foursquare-clouderamanager-datasource version: 0.9.3
id: frser-sqlite-datasource version: 2.0.0
id: fzakaria-simple-annotations-datasource version: 1.0.1
id: gapit-htmlgraphics-panel version: 1.3.3
id: gnocchixyz-gnocchi-datasource version: 1.7.1
id: goshposh-metaqueries-datasource version: 0.0.5
id: gowee-traceroutemap-panel version: 0.3.0
id: grafadruid-druid-datasource version: 1.2.0
id: grafana-azure-data-explorer-datasource version: 3.3.2
id: grafana-azure-monitor-datasource version: 0.3.1
id: grafana-clock-panel version: 1.1.3
id: grafana-datadog-datasource version: 2.3.9
id: grafana-discourse-datasource version: 1.1.0
id: grafana-dynatrace-datasource version: 3.1.2
id: grafana-enterprise-logs-app version: 2.2.0
id: grafana-github-datasource version: 1.0.11
id: grafana-gitlab-datasource version: 0.1.4
id: grafana-googlesheets-datasource version: 1.0.1
id: grafana-image-renderer version: 3.2.0
id: grafana-iot-sitewise-datasource version: 1.1.0
id: grafana-jira-datasource version: 1.0.3
id: grafana-k6cloud-datasource version: 0.1.2
id: grafana-kairosdb-datasource version: 3.0.2
id: grafana-metrics-enterprise-app version: 3.2.1
id: grafana-mongodb-datasource version: 1.1.7
id: grafana-newrelic-datasource version: 2.2.3
id: grafana-oracle-datasource version: 2.0.6
id: grafana-piechart-panel version: 1.6.2
id: grafana-polystat-panel version: 1.2.6
id: grafana-salesforce-datasource version: 0.9.2
id: grafana-saphana-datasource version: 1.0.1
id: grafana-servicenow-datasource version: 2.1.6
id: grafana-simple-json-datasource version: 1.4.2
id: grafana-singlestat-panel version: 1.0.0
id: grafana-snowflake-datasource version: 1.2.0
id: grafana-splunk-datasource version: 2.1.0
id: grafana-splunk-monitoring-datasource version: 1.0.0
id: grafana-strava-datasource version: 1.3.0
id: grafana-synthetic-monitoring-app version: 0.8.13
id: grafana-timestream-datasource version: 1.2.0
id: grafana-wavefront-datasource version: 1.0.6
id: grafana-worldmap-panel version: 0.3.3
id: grafana-x-ray-datasource version: 1.3.2
id: gretamosa-topology-panel version: 1.0.1
id: gridprotectionalliance-openhistorian-datasource version: 1.0.3
id: gridprotectionalliance-osisoftpi-datasource version: 1.1.1
id: groonga-datasource version: 1.1.4
id: hadesarchitect-cassandra-datasource version: 1.0.0
id: hawkular-datasource version: 1.1.2
id: humio-datasource version: 3.2.4
id: ibm-apm-datasource version: 0.9.1
id: innius-grpc-datasource version: 1.0.3
id: innius-video-panel version: 1.0.5
id: instana-datasource version: 3.3.1
id: integrationmatters-comparison-panel version: 1.1.0
id: isaozler-paretochart-panel version: 0.3.1
id: jasonlashua-prtg-datasource version: 4.0.4
id: jdbranham-diagram-panel version: 1.7.2
id: jeanbaptistewatenberg-percent-panel version: 1.0.6
id: larona-epict-panel version: 2.0.4
id: lightstep-metrics-datasource version: 1.0.0
id: linksmart-hds-datasource version: 1.0.2
id: linksmart-sensorthings-datasource version: 1.3.1
id: macropower-analytics-panel version: 2.0.0
id: magnesium-wordcloud-panel version: 1.2.4
id: marcuscalidus-svg-panel version: 0.3.4
id: marcusolsson-calendar-panel version: 0.5.0
id: marcusolsson-csv-datasource version: 0.6.1
id: marcusolsson-dynamictext-panel version: 1.7.2
id: marcusolsson-gantt-panel version: 0.7.4
id: marcusolsson-hexmap-panel version: 0.3.1
id: marcusolsson-hourly-heatmap-panel version: 1.0.0
id: marcusolsson-json-datasource version: 1.3.0
id: marcusolsson-static-datasource version: 1.4.3
id: marcusolsson-treemap-panel version: 0.9.2
id: meteostat-meteostat-datasource version: 0.1.5
id: michaeldmoore-annunciator-panel version: 1.1.0
id: michaeldmoore-multistat-panel version: 1.7.2
id: michaeldmoore-scatter-panel version: 1.0.0
id: monasca-datasource version: 1.0.1
id: monitoringartist-monitoringart-datasource version: 1.0.1
id: moogsoft-aiops-app version: 8.0.1
id: mtanda-google-calendar-datasource version: 1.0.5
id: mtanda-heatmap-epoch-panel version: 0.1.8
id: mtanda-histogram-panel version: 0.1.7
id: mxswat-separator-panel version: 1.0.1
id: natel-discrete-panel version: 0.1.1
id: natel-influx-admin-panel version: 0.0.6
id: natel-plotly-panel version: 0.0.7
id: natel-usgs-datasource version: 0.0.3
id: neocat-cal-heatmap-panel version: 0.0.4
id: novalabs-annotations-panel version: 0.0.2
id: novatec-sdg-panel version: 4.0.3
id: ntop-ntopng-datasource version: 1.0.1
id: oci-logs-datasource version: 1.1.0
id: oci-metrics-datasource version: 2.2.4
id: opennms-helm-app version: 6.0.0
id: ovh-warp10-datasource version: 2.2.1
id: paytm-kapacitor-datasource version: 0.1.3
id: percona-percona-app version: 1.0.1
id: petrslavotinek-carpetplot-panel version: 0.1.2
id: pierosavi-imageit-panel version: 1.0.5
id: pixie-pixie-datasource version: 0.0.1
id: pr0ps-trackmap-panel version: 2.1.2
id: praj-ams-datasource version: 1.2.1
id: pue-solr-datasource version: 1.0.3
id: pyroscope-datasource version: 1.0.0
id: pyroscope-panel version: 1.0.1
id: quasardb-datasource version: 3.8.3
id: rackerlabs-blueflood-datasource version: 0.0.3
id: radensolutions-netxms-datasource version: 1.2.3
id: redis-app version: 1.2.0
id: redis-datasource version: 1.5.0
id: redis-explorer-app version: 1.1.0
id: ryantxu-ajax-panel version: 0.1.0
id: ryantxu-annolist-panel version: 0.0.2
id: satellogic-3d-globe-panel version: 0.1.1
id: savantly-heatmap-panel version: 0.2.1
id: sbueringer-consul-datasource version: 0.2.1
id: scadavis-synoptic-panel version: 1.0.5
id: sebastiangunreben-cdf-panel version: 0.2.2
id: sidewinder-datasource version: 0.2.1
id: simpod-json-datasource version: 0.2.3
id: skydive-datasource version: 1.2.1
id: smartmakers-trafficlight-panel version: 1.0.1
id: sni-pnp-datasource version: 1.0.8
id: sni-thruk-datasource version: 1.0.6
id: snuids-radar-panel version: 1.4.5
id: snuids-svg-panel version: 1.0.0
id: snuids-trafficlights-panel version: 1.4.6
id: speakyourcode-button-panel version: 0.2.2
id: spotify-heroic-datasource version: 0.0.2
id: sskgo-perfcurve-panel version: 1.4.0
id: stagemonitor-elasticsearch-app version: 0.83.3
id: streamr-datasource version: 1.5.0
id: teamviewer-datasource version: 1.0.2
id: tencentcloud-monitor-app version: 2.2.2
id: thalysantana-appcenter-datasource version: 1.0.0
id: thiagoarrais-matomotracking-panel version: 0.2.3
id: udoprog-heroic-datasource version: 0.1.1
id: vertamedia-clickhouse-datasource version: 2.3.1
id: vertica-grafana-datasource version: 0.1.1
id: verticle-flowhook-datasource version: 0.1.2
id: volkovlabs-image-panel version: 1.0.1
id: vonage-status-panel version: 1.0.11
id: voxter-app version: 0.0.2
id: williamvenner-timepickerbuttons-panel version: 4.1.1
id: woutervh-mapbox-panel version: 1.0.0
id: xginn8-pagerduty-datasource version: 0.2.2
id: yesoreyeram-boomtable-panel version: 1.4.1
id: yesoreyeram-boomtheme-panel version: 0.1.1
id: yesoreyeram-infinity-datasource version: 0.7.8
id: yeya24-chaosmesh-datasource version: 0.2.2
id: zuburqan-parity-report-panel version: 1.2.2
Restart grafana after installing plugins . <service grafana-server restart>
[root@server ~]# grafana-cli plugins install alexanderzobnin-zabbix-app
installing alexanderzobnin-zabbix-app @ 4.1.5
from: https://grafana.com/api/plugins/alexanderzobnin-zabbix-app/versions/4.1.5/download
into: /var/lib/grafana/plugins
✔ Installed alexanderzobnin-zabbix-app successfully
Restart grafana after installing plugins . <service grafana-server restart>
[root@server ~]# systemctl restart grafana-server
插件默认安装在/var/lib/grafana/plugins目录下
http://IP:3000/ 打开grafana界面,打开后输入admin/admin登录,登陆后按提示更改admin密码。
zabbix数据源
首先需要使能zabbix插件,在grafana左边栏-设置子菜单中点击-“Plugins”,在插件列表中找到并点击zabbix(如果没找到,说明你的插件安装未成功)。点击“enable”按钮正式启用zabbix插件
1.API地址填写:设置Zabbix API地址http://ip:port/api_jsonrpc.php
例如http://192.168.10.10:80/api_jsonrpc.php
或http://192.168.10.10:80/zabbix/api_jsonrpc.php
这个URL的前半部分其实就是你的zabbix访问地址,因人而异。后半部分可能有无/zabbix.
2.连接API的用户名密码:grafana需要获取所有的组和主机
需要注意:
1、这里API信息填写好以后,点击连接可能会报错:Could not connect to given url!
这种情况要检查URL前后两部分,前半部分根据zabbix WEB访问地址写,后半部分可以在主机后台找下api_jsonrpc.php
添加可视化面板
我们尝试把zabbix中的监控数据可视化。
在左边栏找到create dashboard–add new panel
面板介绍
1、选择数据源,此处下拉框中选择“zabbix”。
2、鼠标放在Group、Host、Appilication(可选)、item时,会弹出你zabbix中的数据。按需选择就好了。
3、右侧是一些图表呈现效果设置项,主要还是根据需要选择图表样式,此处选择graph。
这里我们插一个标签上去
![在这里插入图片描述](https://www.icode9.com/i/ll/?i=1d8fe4a7566b42eaa4dfb12d6241f82d.png?,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_