User Tools

Site Tools


сервис_grafana

Сервис Grafana

Установка

Debian 10/Ubuntu 20

# apt install -y apt-transport-https software-properties-common wget

# wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -

# echo "deb https://packages.grafana.com/oss/deb stable main" | tee -a /etc/apt/sources.list.d/grafana.list

# apt update

# apt install grafana

# systemctl enable grafana-server.service

# systemctl start grafana-server

Docker

# id=$(docker create grafana/grafana-oss)

# docker cp $id:/etc/grafana/ - > etc_grafana.tar

# docker rm -v $id

# tar -xvf etc_grafana.tar -C /etc

# docker run -d -p 3000:3000 -v /etc/grafana:/etc/grafana --name grafana grafana/grafana-oss:7.5.4-ubuntu
  или
# docker run -d -p 3000:3000 -v /etc/grafana:/etc/grafana --name grafana grafana/grafana-oss

# docker update --restart=always grafana

Интеграция с Prometheus

Configuratin->Data Source->Prometheus 
  URL: http://localhost:9090
       http://192.168.X.10:9090  Если grafana в docker

Grafana dashboard

Import dashboard

+ Import->Import via grafana.com
    prometheus-node-exporter: 1860
    prometheus-blackbox-exporter: 7587
  Data Source: Prometheus

Create dashboard

  • !!! Не забыть сохранить !!!
+ Create
    Name: router
      Add New Panel
      
        Panel Title: FastEthernet1/0 connection to LAN
          или
        Panel Title: Port-channel1 connection to LAN
        
        Query: A
        
          Metrics: 8*rate(if_in_octets{ifDescr="FastEthernet1/0",instance="router"}[1m])/1000000
            или
          Metrics: 8*rate(if_in_octets{ifDescr="Port-channel1",instance="router"}[1m])/1000000
          
          Legend: in Mbps
        Query: B
        
          Metrics: 8*rate(if_out_octets{ifDescr="FastEthernet1/0",instance="router"}[1m])/1000000
            или
          Metrics: 8*rate(if_out_octets{ifDescr="Port-channel1",instance="router"}[1m])/1000000
          
          Legend: out Mbps

Настройка уведомлений

Настройка модуля smtp

# cat /etc/grafana/grafana.ini
...
[smtp]
enabled = true
host = mail.isp.un:25
;host = localhost:25
;host = server.corpX.un:25   #if docker
from_address = grafana@server.corpX.un
ehlo_identity = server.corpX.un
startTLS_policy = NoStartTLS
...
# service grafana-server restart
  или
# docker restart grafana

grafana 7.X.X

  • Можно было задавать порог срабатывания прямо на графике!
Alerting->Notification Channels ... 
  userX/Email/userX@isp.un
  student/Email/student@corp13.un

Dashboard->Panel (name)->Edit->Alert->...->
  Evaluate every: 15s For 1m
  WHEN avg() OF query(B,1m,now) IS ABOVE 8
  Send To: userX/student

Apply->Save Dashboard!!!!
сервис_grafana.txt · Last modified: 2022/03/14 11:45 by val