Grafana

grafana

简介

grafana是监控的一个前端展示工具可以通过docker来部署

grafana的展示模板

通过导入模板的json或输入模板的ID就可以导入模板,但是输入ID的方式有时候会不成功。

docker 启动

使用docker-compose

  • 首次登录地址: http://127.0.0.1:3000/,帐号密码admin,admin
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
[root@dev127 cig]# cat docker-compose.yml
version: '3.1'
volumes:
  grafana_data: {}
 
services:
 influxdb:
  image: tutum/influxdb:0.9
  restart: always
  environment:
    - PRE_CREATE_DB=cadvisor
  ports:
    - "8083:8083"
    - "8086:8086"
  volumes:
    - /data/influxdb:/data

 cadvisor:
  image: google/cadvisor
  restart: always
  ports:
    - "8082:8080"
  volumes:
    - /:/rootfs:ro
    - /var/run:/var/run:rw
    - /sys:/sys:ro
    - /var/lib/docker/:/var/lib/docker:ro
 
 grafana:
  user: "104"
  image: grafana/grafana
  user: "104"
  restart: always
  links:
    - influxdb:influxsrv
  ports:
    - "3000:3000"
  volumes:
    - grafana_data:/var/lib/grafana
  environment:
    - HTTP_USER=admin
    - HTTP_PASS=admin
    - INFLUXDB_HOST=influxsrv
    - INFLUXDB_PORT=8086
    - INFLUXDB_NAME=cadvisor
    - INFLUXDB_USER=root
    - INFLUXDB_PASS=root

直接通过命令来启动

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#!/bin/bash
basedir=$(cd `dirname $0`;pwd)

docker stop grafana
docker rm grafana
docker run \ 
       -d --name grafana  -p 3000:3000 \ 
       -e "GF_SERVER_ROOT_URL=http://grafana.server.name" \
       -e "GF_SECURITY_ADMIN_PASSWORD=123456" \
       grafana/grafana grafana