grafana安裝和配置
grafana安裝很是簡單:(https://grafana.com/grafana/download)html
對於有apt的服務器:nginx
# apt install -y software-properties-common # only for debian9 sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main" wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add - apt update apt install grafana
配置:docker
配置文件爲 /etc/grafana/grafana.ini
,注意以下內容:bash
... [server] domain = www.parclabcn.com enforce_domain = true root_url = %(protocol)s://%(domain)s/grafana ... [security] admin_password = xxxx
而後訪問 www.parclabcn.com/grafana 登陸,用戶名admin,密碼爲上面設置的admin_password。服務器
或者用docker:dom
首先複製一個grafana的配置文件到 /root/docker-grafana/grafana.ini
(docker cp),而後作和上述一樣的修改。url
拉取鏡像並運行:spa
docker run -d \ --name=grafana \ --restart=always \ -v /etc/localtime:/etc/localtime:ro \ -v /root/docker-grafana/grafana.ini:/etc/grafana/grafana.ini \ -p 3000:3000 \ grafana/grafana:6.4.3
Nginx設置以下:
location /grafana { root html; index index.html index.htm; add_header 'Access-Control-Allow-Origin' '*'; add_header Access-Control-Allow-Methods GET,POST,OPTIONS,DELETE; add_header 'Access-Control-Allow-Headers' 'userId,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; proxy_pass http://127.0.0.1:3000; rewrite ^/grafana/(.*) /$1 break; proxy_set_header Host $host; #server_name_in_redirect off; #proxy_set_header Host $host:$server_port; #proxy_set_header X-Real-IP $remote_addr; #proxy_set_header REMOTE-HOST $remote_addr; #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
訪問 ip/grafana 便可看到grafana界面。 .net
參考:(配置都不全對,僅作參考) http://www.javashuo.com/article/p-smtzfysx-hp.html (nginx配置不對,少了rewrite) https://my.oschina.net/kcw/blog/2980304 (grafana的root_url不對)rest