0% ont trouvé ce document utile (0 vote)
237 vues44 pages

Prometheus Grafana

Transféré par

superadmn.jo
Copyright
© © All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd
0% ont trouvé ce document utile (0 vote)
237 vues44 pages

Prometheus Grafana

Transféré par

superadmn.jo
Copyright
© © All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd

Monitoring avec prometheus et grafana

Retour d’expérience

Nicolas Gibelin : UMS Gricad


[email protected]

Version 1.2 (Rev : 109) - 20180424

1/28
Plan

1 Introduction

2 Prometheus

3 Grafana

4 Conclusion

5 Référence

2/28
Contexte

Mi2S

3/28
Contexte

Mi2S

Nagios + Centreon
Netmet / Netmat
Nfsen
Cacti

3/28
Contexte

Mi2S => Gricad : salles du datacentre UGA

Cacti : pour pdus, ups (snmp). . . , mais problèmes (graphes, snmp, templates, rrd,
...)

3/28
Contexte

Mi2S => Gricad : salles du datacentre UGA

Cacti : pour pdus, ups (snmp). . . , mais problèmes (graphes, snmp, templates, rrd,
...)
ajout Influxdb + Grafana

3/28
Contexte

Mi2S => Gricad : salles du datacentre UGA

Cacti : pour pdus, ups (snmp). . . , mais problèmes (graphes, snmp, templates, rrd,
...)
ajout Influxdb + Grafana

Gricad

3/28
Contexte

Mi2S => Gricad : salles du datacentre UGA

Cacti : pour pdus, ups (snmp). . . , mais problèmes (graphes, snmp, templates, rrd,
...)
ajout Influxdb + Grafana

Gricad

Prometheus

3/28
Pourquoi Prometheus ?

Test/lecture dernières versions

Cacti
Nagios et derivés
...

4/28
Pourquoi Prometheus ?

Test/lecture dernières versions

Cacti
Nagios et derivés
...

Veille

Zabbix
Shinken
Prometheus
...
4/28
Pourquoi Prometheus ?

Prometheus: à première vue

Simple
Mise en oeuvre
utilisation
mise à jour
Efficace
Plein d’Exporters (sondes)
Grosse communauté.
Intégré / Supporté (liste complète):
Gitlab : prometheus monitoring[’enable’]
Ceph : ceph mgr module enable prometheus
Openstack : prometheus-openstack-exporter
4/28
Test / Challenge

Mimer la conf snmp de Cacti DC Imag

5/28
Test / Challenge

Mimer la conf snmp de Cacti DC Imag


En combien de temps, sachant:

5/28
Test / Challenge

Mimer la conf snmp de Cacti DC Imag


En combien de temps, sachant:
3 types de pdus
150 Pdus
1 Ups
Tout snmp

5/28
Test / Challenge

Mimer la conf snmp de Cacti DC Imag


En combien de temps, sachant:
3 types de pdus
150 Pdus
1 Ups
Tout snmp
Et en bonus
Grapher dans Grafana
Grapher plus (versus Influxdb)

5/28
Plan

1 Introduction

2 Prometheus

3 Grafana

4 Conclusion

5 Référence

6/28
Prometheus

Architecture de Prometheus

7/28
Serveur Prometheus

Description

Code écrit en Go
Base de donnée de séries temporelles (time series)
Collecte à intervalle régulier: exporters
Fonctionne par ’job’
Similarité des données = stockage par double delta
Langage de requête : PromQL
Évaluation de définitions d’alerte
Évaluation de définitions
API Web, serveur web

8/28
Exporters

Quelques exporters

Officiels (sur le gitHub) :


snmp exporter
job exporter
mysqld exporter
graphite exporter
Autres (liste ici) :
apache exporter
ceph exporter
minecraft exporter

9/28
Installation du serveur

Packages
Votre distribution doit probablement les avoir.

Sinon : Bash
a d d u s e r −−no−c r e a t e −home −−d i s a b l e d −l o g i n p r o m e t h e u s
e x p o r t PVERSION = 2 . 2 . 0
m k d i r −p /home/ s o f t w a r e s / p r o m e t h e u s / p a c k a g e s
m k d i r −p /home/ d a t a / p r o m e t h e u s
cd /home/ s o f t w a r e s / p r o m e t h e u s / p a c k a g e s
wget ” h t t p s : / / g i t h u b . com/ p r o m e t h e u s / p r o m e t h e u s / r e l e a s e s / d o w n l o a d / $ {PVERSION}/
p r o m e t h e u s −$ {PVERSION } . l i n u x −amd64 . t a r . gz ”
t a r z x v f p r o m e t h e u s −$ {PVERSION } . l i n u x −amd64 . t a r . gz
cd . . /
l n − f s p a c k a g e s / p r o m e t h e u s −$ {PVERSION}/ p r o m e t h e u s

10/28
Configuration

/etc/prometheus/prometheus.yml
global :
scrape interval : 15 s
e v a l u a t i o n i n t e r v a l : 15 s

scrape configs :
− job name : . . .

rule files :
# recording rules
# Alerting rules

alerting :
alertmanagers :
− static configs :
− targets :
− l o c a l h o s t :9093

11/28
Lancement du serveur

/etc/systemd/system/prometheus.service
[ Unit ]
D e s c r i p t i o n=P r o m e t h e u s s e r v e r
A f t e r=n e t w o r k . t a r g e t

[ Service ]
W o r k i n g D i r e c t o r y =/home/ s o f t w a r e s / p r o m e t h e u s / p r o m e t h e u s
E x e c S t a r t =/home/ s o f t w a r e s / p r o m e t h e u s / p r o m e t h e u s / p r o m e t h e u s \
−−c o n f i g . f i l e =/ e t c / p r o m e t h e u s / p r o m e t h e u s . yml \
−−s t o r a g e . t s d b . p a t h=/home/ d a t a / p r o m e t h e u s \
−−s t o r a g e . t s d b . r e t e n t i o n =400d
# −a l e r t m a n a g e r . u r l=h t t p : / / l o c a l h o s t : 9 0 9 3 / a l e r t −manager \
U s e r=p r o m e t h e u s

[ Install ]
WantedBy=m u l t i −u s e r . t a r g e t

12/28
Snmp exporter

Autant que vous voulez


Sur différentes machines
Installation idem serveur
Utilise des fichiers de MIB
Fourni un générateur de configuration

13/28
Snmp exporter: configuration mibs

/etc/prometheus/generator.yml
modules :
if mib :
w a l k : [ sysUpTime , i n t e r f a c e s , i f X T a b l e ]

# APC pd us
# Model Number : AP8853
ap8853 :
version : 1
walk :
− sysName # Pdu Name
− 1.3.6.1.4.1.318.1.1.26.6.3.1.5 # Amperage Phase
− 1.3.6.1.4.1.318.1.1.26.4.3.1.5 # Power
− 1.3.6.1.4.1.318.1.1.26.4.3.1.9 # Energy

14/28
Snmp exporter: generation de la configuration

bash
generator generate

15/28
Snmp exporter: generation de la configuration

/etc/prometheus/snmp.yml
ap8853 :
walk :
− 1.3.6.1.2.1.1.5
− 1.3.6.1.4.1.318.1.1.26.4.3.1.5
metrics :
− name : sysName
oid : 1 . 3 . 6 . 1 . 2 . 1 . 1 . 5
type : D is pl ay St ri ng
h e l p : An a d m i n i s t r a t i v e l y −a s s i g n e d name . . .
− name : r P D U 2 D e v i c e S t a t u s P o w e r
oid : 1 . 3 . 6 . 1 . 4 . 1 . 3 1 8 . 1 . 1 . 2 6 . 4 . 3 . 1 . 5
t y p e : gauge
h e l p : The power c o n s u m p t i o n o f t h e Rack PDU l o a d ...
indexes :
− labelname : rPDU2DeviceStatusIndex
t y p e : gauge

15/28
Configuration Prometheus

/etc/prometheus/prometheus.yml
− j o b n a m e : ’ snmp−imag−pdu−ap8853 ’
file sd configs :
− f i l e s : [ ”/ e t c / p r o m e t h e u s /snmp/ imag−pdu−ap8853 . yml ” ]

m e t r i c s p a t h : /snmp

params :
module : [ ap8853 ]

16/28
Configuration Prometheus

/etc/prometheus/snmp/imag-pdu-ap8853.yml
− targets :
− pdu −1. t e s t . f r
− pdu −2. t e s t . f r
labels :
s i t e : ’ Grenoble ’
a l l e y : ’Z ’
rack : ’1 ’

− targets :
− pdu −3. t e s t . f r
− pdu −4. t e s t . f r
labels :
s i t e : ’ Grenoble ’
a l l e y : ’Z ’
rack : ’2 ’

16/28
Attention : bugs

Mauvaise implémentation des MIB sur certains équipements :


snmp.yml : faux mais qui marche
− name : u p s P h a s e O u t p u t P e r c e n t P o w e r
oid : 1 . 3 . 6 . 1 . 4 . 1 . 3 1 8 . 1 . 1 . 1 . 9 . 3 . 3 . 1 . 1 6 . 1
t y p e : gauge
h e l p : The p e r c e n t a g e o f t h e UPS power c a p a c i t y i n Watts . . .
UPS . − 1 . 3 . 6 . 1 . 4 . 1 . 3 1 8 . 1 . 1 . 1 . 9 . 3 . 3 . 1 . 1 6 . 1
indexes :
− labelname : upsPhaseOutputPhaseTableIndex
t y p e : gauge
− labelname : upsPhaseOutputPhaseIndex
t y p e : gauge

17/28
Attention : bugs

Mauvaise implémentation des MIB sur certains équipements :


snmp.yml : bon mais que ne marche pas
− name : u p s P h a s e O u t p u t P e r c e n t P o w e r
oid : 1 . 3 . 6 . 1 . 4 . 1 . 3 1 8 . 1 . 1 . 1 . 9 . 3 . 3 . 1 . 1 6
t y p e : gauge
h e l p : The p e r c e n t a g e o f t h e UPS power c a p a c i t y i n Watts . . .
UPS . − 1 . 3 . 6 . 1 . 4 . 1 . 3 1 8 . 1 . 1 . 1 . 9 . 3 . 3 . 1 . 1 6
indexes :
− labelname : upsPhaseOutputPhaseTableIndex
t y p e : gauge
− labelname : upsPhaseOutputPhaseIndex
t y p e : gauge

17/28
Attention : bugs

Mauvaise implémentation des MIB sur certains équipements :

> snmpwalk −v 1 −c p u b l i c ups . t e s t . f r 1.3.6.1.4.1.318.1.1.1.9.3.3.1.16

PowerNet−MIB : : u p s P h a s e O u t p u t P e r c e n t P o w e r . 1 . 1 . 1 = INTEGER : 42
PowerNet−MIB : : u p s P h a s e O u t p u t P e r c e n t P o w e r . 1 . 1 . 2 = INTEGER : 40
PowerNet−MIB : : u p s P h a s e O u t p u t P e r c e n t P o w e r . 1 . 1 . 3 = INTEGER : 39

Ici, un ”.1” de trop qui n’est pas un indexe


Pour plus de détails : Issue 273

17/28
Alerts

/etc/prometheus/prometheus.yml
rule files :
− / e t c / p r o m e t h e u s / r u l e s / node . r u l e s . yml

18/28
Alerts

/etc/prometheus/rules/node.rules.yml
groups :
− name : A l e r t s n o d e s
rules :
− alert : DiskWillFillIn4Hours
e x p r : p r e d i c t l i n e a r ( n o d e f i l e s y s t e m f r e e { j o b =”node ” } [ 1 h ] , 4 ∗ 3 6 0 0 ) < 0
f o r : 5m
labels :
severity : critical
annotations :
t i t l e : ’ { { $ l a b e l s . m o u n t p o i n t }} i s a l m o s t f u l l on
{{ $ l a b e l s . i n s t a n c e } } : {{ $ v a l u e | h u m a n i z e }}% ’

18/28
Alertmanager

/etc/prometheus/prometheus.yml
alerting :
alertmanagers :
− static configs :
− targets :
− host :9093

19/28
Alertmanager

gestionnaire d’alerte
route :
\# On e n v o i e t o u t v e r s s l a c k p a r d \ ’ e f a u t
receiver : slack
[...]
receivers :
− name : ’ s l a c k ’
slack configs :
− a p i u r l : ” h t t p s : / / h o o k s . s l a c k . com/ s e r v i c e s / x x x / x x x / x x x x x x ”
c h a n n e l : ’\# p r o m e t h e u s ’

Exemple tiré de [1]

19/28
PromQL

Le langage de query du moteur :


La doc

Les bases
Opérateurs
Fonctions

20/28
Prometheus

Démo
Ou sur le site de Prometheus Live Demo

21/28
Plan

1 Introduction

2 Prometheus

3 Grafana

4 Conclusion

5 Référence

22/28
Grafana

Démo
Ou sur le site de Play Grafana

23/28
Plan

1 Introduction

2 Prometheus

3 Grafana

4 Conclusion

5 Référence

24/28
Conclusion

Conclusion : 2 mois après début des tests

Challenge :
1.0 journée Prometheus = équivalent Cacti
0.5 journée = nouveaux dashboards Grafana
0.5 journée = bug matériel et résolution (patch)
Les +
Conf par fichier
Supporté par Ceph, Openstack . . .
Bien interfacé avec Grafana (dashboard existants)
M.A.J facile
Ajout d’équipement snmp facile
Langage puissant
Stockage optimisé : 150pdus*30s*118metrics*2 mois = 3x109 data = 3Go

25/28
Plan

1 Introduction

2 Prometheus

3 Grafana

4 Conclusion

5 Référence

26/28
Références

[1] Yannig, “Découverte de l’outil de supervision prometheus,” Jan. 2018. [Online]. Available:
http://linuxfr.org/news/decouverte-de-l-outil-de-supervision-prometheus

[2] B. B. Rabenstein, “Configuring prometheus for high performance,” Mar. 2017. [Online]. Available:
https://schd.ws/hosted files/cloudnativeeu2017/ce/Slides.pdf

[3] D. Lee, “Visualize your data with grafana,” 2017. [Online]. Available: https:
//www.percona.com/live/e17/sites/default/files/slides/Visualize%20Your%20Data%20With%20Grafana%20-%20FileId%20-%20115450.pdf

[4] A. Kulkarni, “What the heck is time-series data (and why do i need a time-series database)?” 2017. [Online]. Available:
https://www.percona.com/live/17/sessions/what-heck-time-series-data-and-why-do-i-need-time-series-database

27/28
Questions ?

?
28/28

Vous aimerez peut-être aussi