阿里雲ECS部署Grafana接入zabbix

韜雲發表於2017-06-06

Grafana接入zabbix部署

阿里雲ECS部署Grafana接入zabbix
Grafana 是 Graphite 和 InfluxDB 儀表盤和圖形編輯器。Grafana 是開源的,功能齊全的度量儀表盤和圖形編輯器,支援 Graphite,InfluxDB 和 OpenTSDB。

關於zabbix及相關服務軟體版本:


Linux: ECS_CentOS 7.2

nginx: 1.9.15

一、購買ECS


購買一臺ECS

二、安裝nginx

安裝依賴包:

yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre* make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel

建立nginx使用者:

useradd nginx -s /sbin/nologin -M

下載nginx軟體包並進入到目錄中:

wget http://nginx.org/download/nginx-1.9.15.tar.gz && tar xvf nginx-1.9.15.tar.gz && cd nginx-1.9.15

編譯:

./configure --prefix=/usr/local/product/nginx1.9.14 --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --with-pcre

make && make install

ln -s /usr/local/product/nginx1.9.14 /usr/local/nginx    ==>建立軟連結

引數解釋:

--with-http_stub_status_module:支援nginx狀態查詢
--with-http_ssl_module:支援https
--with-http_spdy_module:支援google的spdy,想了解請百度spdy,這個必須有ssl的支援
--with-pcre:為了支援rewrite重寫功能,必須制定pcre

三、安裝Grafana

mkdir /opt/grafana && cd /opt/grafana
wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.3.2.linux-x64.tar.gz 
tar -zxvf grafana-4.3.2.linux-x64.tar.gz
mv grafana-4.3.2 grafana
cd grafana/bin/
#檢視可以安裝的外掛
./grafana-cli plugins list-remote
#安裝zabbix外掛
./grafana-cli plugins install alexanderzobnin-zabbix-app
#安裝餅圖外掛
./grafana-cli plugins install grafana-piechart-panel
#啟動,並後臺執行
./grafana-server -homepath /opt/grafana/grafana &

四、Grafana管理網站配置(nginx):

編輯nginx虛擬主機:

[root@grafana conf]# mkdir extra
[root@grafana conf]# cd extra/
[root@grafana extra]# vim grafana.conf
server {
    listen       80;
    server_name  grafana.dtstack.com;
    access_log /data/logs/zabbix/grafana.dtstack.com.access.log main;

    location / {
        index  index.html;
    proxy_pass http://127.0.0.1:3000;
    proxy_set_header   Host             $host;
    proxy_set_header   X-Real-IP        $remote_addr;
    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
    
    }
 }

編輯nginx.conf配置檔案:

[root@grafana conf]# cat nginx.conf

user  nginx;
worker_processes  1;

#error_log  logs/error.log warning;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        logs/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  `$remote_addr - $remote_user [$time_local] "$request" `
                      `$status $body_bytes_sent "$http_referer" `
                      `"$http_user_agent" "$http_x_forwarded_for"`;

    access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
    include extra/*.conf;

}

新增/etc/hosts檔案:

192.168.119.140 grafana.dtstack.com

訪問Grafana

訪問http://grafana.dtstack.com  admin/admin

五、新增資料來源:

啟用zabbix外掛
資料來源配置 - 資料來源
    Name:      zabbix
    Default:   ️
    Type:      Zabbix

    ## Http settings
    URL:     http://zabbix.dtstack.com/api_jsonrpc.php
    Access:  proxy

    ## Zabbix API details
    Username: xxxxxx
    Password: xxxxxx


相關文章