User Tools

Site Tools


сервис_grafana

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
сервис_grafana [2021/04/20 07:54]
val [Настройка уведомлений]
сервис_grafana [2025/04/28 18:04] (current)
val [Grafana dashboard]
Line 1: Line 1:
 ====== Сервис Grafana ====== ====== Сервис Grafana ======
  
-  * [[https://​grafana.com/​docs/​grafana/​latest/​installation/​debian/​|Install on Debian or Ubuntu]] 
   * [[https://​geekflare.com/​prometheus-grafana-setup-for-linux/​|A Guide to Monitor Linux Server using Prometheus and Grafana]]   * [[https://​geekflare.com/​prometheus-grafana-setup-for-linux/​|A Guide to Monitor Linux Server using Prometheus and Grafana]]
   * [[https://​techexpert.tips/​ru/​grafana-ru/​%D0%BD%D0%B0%D1%81%D1%82%D1%80%D0%BE%D0%B9%D0%BA%D0%B0-%D1%83%D0%B2%D0%B5%D0%B4%D0%BE%D0%BC%D0%BB%D0%B5%D0%BD%D0%B8%D0%B9-%D0%BF%D0%BE-%D1%8D%D0%BB%D0%B5%D0%BA%D1%82%D1%80%D0%BE%D0%BD%D0%BD%D0%BE-2/​|Настройка уведомлений по электронной почте Grafana]]   * [[https://​techexpert.tips/​ru/​grafana-ru/​%D0%BD%D0%B0%D1%81%D1%82%D1%80%D0%BE%D0%B9%D0%BA%D0%B0-%D1%83%D0%B2%D0%B5%D0%B4%D0%BE%D0%BC%D0%BB%D0%B5%D0%BD%D0%B8%D0%B9-%D0%BF%D0%BE-%D1%8D%D0%BB%D0%B5%D0%BA%D1%82%D1%80%D0%BE%D0%BD%D0%BD%D0%BE-2/​|Настройка уведомлений по электронной почте Grafana]]
 +  * [[https://​grafana.com/​docs/​grafana/​next/​administration/​organization-preferences/?​cta=...#​change-grafana-ui-theme|Смена "​темы"​]]
  
 ===== Установка ===== ===== Установка =====
  
-<​code>​ 
-# apt install -y apt-transport-https software-properties-common wget 
  
-# wget -q -O - https://packages.grafana.com/​gpg.key ​sudo apt-key add -+  * [[https://​grafana.com/​docs/​grafana/​latest/​installation/​debian/​|Install on Debian or Ubuntu]]
  
-# echo "deb https://​packages.grafana.com/​oss/​deb stable main" | tee -a /​etc/​apt/​sources.list.d/​grafana.list 
  
-# apt update 
  
-apt install ​grafana+==== Docker ==== 
 + 
 +  * [[Технология Docker]] 
 + 
 +<​code>​ 
 +id=$(docker create ​grafana/​grafana-oss) 
 + 
 +# docker cp $id:/​etc/​grafana/​ - > etc_grafana.tar 
 +# tar -xvf etc_grafana.tar -C /etc 
 +  или 
 +# docker cp $id:/​etc/​grafana/​ /​etc/​grafana/​ 
 + 
 +# docker rm -v $id
  
-systemctl enable ​grafana-server.service+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 run -d -p 3000:3000 --name grafana grafana/​grafana-oss
  
-systemctl start grafana-server+docker update ​--restart=always grafana
 </​code>​ </​code>​
  
   * l:admin p:admin   * l:admin p:admin
   * [[http://​server.corpX.un:​3000]]   * [[http://​server.corpX.un:​3000]]
-  * [[http://​192.168.X.10:​3000]]  +  * [[http://​192.168.X.10:​3000]] 
-  * [[http://​10.5.N.100+X:3000]] + 
 +==== Kubernetes ==== 
 + 
 +  * [[Сервис VictoriaMetrics]] 
 + 
 +<​code>​ 
 +kube1# helm repo add grafana https://​grafana.github.io/​helm-charts 
 +kube1# helm repo update 
 + 
 +kube1:~/vm# cat my-grafana-values.yaml 
 +</​code><​code>​ 
 +  datasources:​ 
 +    datasources.yaml:​ 
 +      apiVersion: 1 
 +      datasources:​ 
 +        - name: victoriametrics 
 +          type: prometheus 
 +          orgId: 1 
 +          url: http://vmsingle-victoria-metrics-single-server:​8428 
 +          access: proxy 
 +          isDefault: true 
 +          updateIntervalSeconds: ​10 
 +          editable: true 
 + 
 +  dashboardProviders:​ 
 +   ​dashboardproviders.yaml: 
 +     ​apiVersion:​ 1 
 +     ​providers:​ 
 +     - name: '​default'​ 
 +       ​orgId:​ 1 
 +       ​folder:​ ''​ 
 +       type: file 
 +       ​disableDeletion:​ true 
 +       ​editable:​ true 
 +       ​options:​ 
 +         path: /​var/​lib/​grafana/​dashboards/​default 
 + 
 +  dashboards:​ 
 +    default: 
 +      victoriametrics:​ 
 +        gnetId: 10229 
 +        revision: 22 
 +        datasource: victoriametrics 
 +      kubernetes:​ 
 +        gnetId: 14205 
 +        revision: 1 
 +        datasource: victoriametrics 
 +      node-exporter:​ 
 +        gnetId: 1860 
 +        revision: 37 
 +        datasource: victoriametrics 
 +</​code><​code>​ 
 +kube1:~/vm# helm upgrade -i my-grafana grafana/​grafana -f my-grafana-values.yaml -n vm --create-namespace 
 + 
 +kube1# kubectl get secret -n vm my-grafana -o jsonpath="​{.data.admin-password}"​ | base64 --decode ; echo 
 + 
 +cmder> kubectl -n vm port-forward svc/​my-grafana ​3000:80 
 +</​code>​
  
 ===== Интеграция с Prometheus ===== ===== Интеграция с Prometheus =====
  
 <​code>​ <​code>​
-Configuratin->​Data Source->​Prometheus ​+Configuratin/​Connections->Data Source->​Prometheus ​
   URL: http://​localhost:​9090   URL: http://​localhost:​9090
 +       ​http://​192.168.X.10:​9090 ​ Если grafana в docker
 </​code>​ </​code>​
  
Line 38: Line 108:
  
   * [[https://​grafana.com/​grafana/​dashboards|Official & community built dashboards]]   * [[https://​grafana.com/​grafana/​dashboards|Official & community built dashboards]]
 +  * [[https://​grafana.com/​grafana/​dashboards/​1860-node-exporter-full/​|Node Exporter Full]]
 +  * [[https://​grafana.com/​grafana/​dashboards/​20417-cloudnativepg/​|CloudNativePG]]
  
 ==== Import dashboard ==== ==== Import dashboard ====
Line 48: Line 120:
  
 ==== Create dashboard ==== ==== Create dashboard ====
 +
 +  * !!! Не забыть сохранить !!!
 +  * Лучше в folder1 (понадобится для alert)
  
 <​code>​ <​code>​
-Create+New dasboard->​Add visualization
     Name: router     Name: router
       Add New Panel       Add New Panel
-        ​Panel Title: ​FastEthernet1/connection to ISP+       
 +        ​Panel Title: ​FastEthernet0/connection to WAN 
 +          или 
 +        Panel Title: Port-channel1 connection to LAN 
 +        ​
         Query: A         Query: A
-          Metrics: 8*rate(if_in_octets{ifDescr="​FastEthernet1/1",​instance="​router"​}[1m]) +          ​Code         
-          Legend: in bps+            ​Metrics: 8*rate(ifInOctets{ifDescr="​FastEthernet0/0",​instance="​router"​}[1m])/1000000 
 +              или 
 +            Metrics: rate(ifOutOctets{ifDescr="​Port-channel1",​instance="​router"​}[1m])/​125000 
 +          ​Options->​Legend->Custom: in Mbps 
         Query: B         Query: B
-          Metrics: 8*rate(if_out_octets{ifDescr="​FastEthernet1/1",​instance="​router"​}[1m]) +          ​Code         
-          Legend: out bps+            ​Metrics: 8*irate(ifOutOctets{ifDescr="​FastEthernet0/0",​instance="​router"​}[1m])/1000000 
 +              или 
 +            Metrics: irate(ifInOctets{ifDescr="​Port-channel1",​instance="​router"​}[1m])/​125000 ​         ​ 
 +          ​Options->​Legend->Custom: out Mbps
 </​code>​ </​code>​
 ===== Настройка уведомлений ===== ===== Настройка уведомлений =====
  
 +==== Настройка модуля smtp ====
 <​code>​ <​code>​
 # cat /​etc/​grafana/​grafana.ini # cat /​etc/​grafana/​grafana.ini
Line 69: Line 156:
 [smtp] [smtp]
 enabled = true enabled = true
-host = mail.isp.un:25 +host = server.corpX.un:​25 ​  #if docker, and may be, better use ip 
-from_address = grafana@server.corpX.un+from_address = grafana@corpX.un
 ehlo_identity = server.corpX.un ehlo_identity = server.corpX.un
 startTLS_policy = NoStartTLS startTLS_policy = NoStartTLS
Line 76: Line 163:
 </​code><​code>​ </​code><​code>​
 # service grafana-server restart # service grafana-server restart
-</​code><​code>​ +  или 
-Alerting->​Notification Channels ... +# docker restart grafana 
 +</​code>​ 
 + 
 +==== Настройка получателей ==== 
 + 
 +<​code>​ 
 +Alerting->​Notification Channels/Contact points ​... 
   userX/​Email/​userX@isp.un   userX/​Email/​userX@isp.un
 +  student/​Email/​student@corpX.un
 +</​code>​
  
 +==== Настройка уведомлений ====
 +
 +=== Версия 11 === 
 +
 +<​code>​
 +A:
 +Define query and alert condition -> 
 +  Options -> Time Range: Last 15 minutes
 +  ​
 +B: Delete ​
 + 
 +C (можно дать другое имя, оно будет в сообщении):​ Set as Alert Conditions
 +  Input: A
 +  Function: Last
 +
 +D: Threshold
 +  Input: C
 +  IS Above: 1
 +</​code>​
 +
 +=== Версия 7 === 
 +<​code>​
 Dashboard->​Panel (name)->​Edit->​Alert->​...->​ Dashboard->​Panel (name)->​Edit->​Alert->​...->​
   Evaluate every: 15s For 1m   Evaluate every: 15s For 1m
-  WHEN avg() OF query(A,1m,now) IS ABOVE 1000000 +  WHEN avg() OF query(B,1m,now) IS ABOVE 8 
-  Send To: userX+  Send To: userX/student
  
 Apply->​Save Dashboard!!!! Apply->​Save Dashboard!!!!
 </​code>​ </​code>​
сервис_grafana.1618894479.txt.gz · Last modified: 2021/04/20 07:54 by val