Prometheus-grafana » Historique » Version 5
pizzacoca, 07/03/2020 07:06
1 | 1 | pizzacoca | # Prometheus-grafana |
---|---|---|---|
2 | |||
3 | 3 | pizzacoca | > Prometheus est une supervision client / serveur. |
4 | > Le serveur est consultable sous localhost:9093 |
||
5 | > Les clients produisent une page localhost:9100 que le serveur écoute |
||
6 | 1 | pizzacoca | **[Prometheus](https://prometheus.io/)** est sous licence **[Apache 2](https://www.apache.org/licenses/LICENSE-2.0)** . Les sources sont disponibles sous **[github](https://github.com/prometheus)** . |
7 | |||
8 | Prometheus existe aussi sous la forme de paquets pour debian10, ce que nous allons utiliser. |
||
9 | |||
10 | 4 | pizzacoca | ## Installation de Prometheus |
11 | 1 | pizzacoca | |
12 | 4 | pizzacoca | ### Installation coté serveur |
13 | 1 | pizzacoca | |
14 | **/etc/apt/sources.list** |
||
15 | ``` |
||
16 | deb https://packages.grafana.com/enterprise/deb stable main |
||
17 | ``` |
||
18 | |||
19 | Il est nécessaire d'ajouter la clef gpg pour ce dépôt. |
||
20 | ``` |
||
21 | gpg --receive-key 8C8C34C524098CB6 |
||
22 | apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8C8C34C524098CB6 |
||
23 | apt update |
||
24 | apt install grafana-enterprise |
||
25 | ``` |
||
26 | |||
27 | ### Configuration |
||
28 | |||
29 | 4 | pizzacoca | > Le travail d'écoute du serveur se découpe en nodes. Plusieurs machines peuvent être dans un node. |
30 | > Il sera intéressant de regrouper les machines dont nous voulons récupérer les mêmes informations dans un même node. |
||
31 | > Les machines tournant sous des OS différents devront probablement être placées sous des nodes différents pour permettre une exploitation avec Grafana. |
||
32 | |||
33 | 2 | pizzacoca | La configuration se fait via un fichier yaml. Ici un exemple. |
34 | 1 | pizzacoca | **/etc/prometheus/prometheus.yml** |
35 | 2 | pizzacoca | ``` |
36 | # Sample config for Prometheus. |
||
37 | 1 | pizzacoca | |
38 | 2 | pizzacoca | global: |
39 | scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. |
||
40 | evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. |
||
41 | # scrape_timeout is set to the global default (10s). |
||
42 | |||
43 | # Attach these labels to any time series or alerts when communicating with |
||
44 | # external systems (federation, remote storage, Alertmanager). |
||
45 | external_labels: |
||
46 | monitor: 'example' |
||
47 | |||
48 | # Alertmanager configuration |
||
49 | alerting: |
||
50 | alertmanagers: |
||
51 | - static_configs: |
||
52 | - targets: ['localhost:9093'] |
||
53 | |||
54 | # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. |
||
55 | rule_files: |
||
56 | # - "first_rules.yml" |
||
57 | # - "second_rules.yml" |
||
58 | |||
59 | # A scrape configuration containing exactly one endpoint to scrape: |
||
60 | # Here it's Prometheus itself. |
||
61 | scrape_configs: |
||
62 | # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. |
||
63 | - job_name: 'prometheus' |
||
64 | |||
65 | # Override the global default and scrape targets from this job every 5 seconds. |
||
66 | scrape_interval: 5s |
||
67 | scrape_timeout: 5s |
||
68 | |||
69 | # metrics_path defaults to '/metrics' |
||
70 | # scheme defaults to 'http'. |
||
71 | |||
72 | static_configs: |
||
73 | - targets: ['localhost:9090'] |
||
74 | |||
75 | - job_name: Mes_machines_virtuelles |
||
76 | static_configs: |
||
77 | - targets: |
||
78 | - 'domaine.associe.ou.adresse.ip:9100' |
||
79 | - 'XXX.XXX.XXX.XXX:9100' |
||
80 | |||
81 | |||
82 | - job_name: noeud_pour_autres_machines |
||
83 | # If prometheus-node-exporter is installed, grab stats about the local |
||
84 | # machine by default. |
||
85 | static_configs: |
||
86 | # première syntaxe yaml |
||
87 | #- targets: ['localhost:9100'] |
||
88 | # deuxième syntaxe yaml |
||
89 | - targets: |
||
90 | - 'localhost:9100' # la machine qui s'écoute |
||
91 | - 'XXX.XXX.XXX.XXX:9100' |
||
92 | - 'YYY.YYY.YYY.YYY:9100' |
||
93 | ``` |
||
94 | |||
95 | 1 | pizzacoca | ### Lancement |
96 | |||
97 | ``` |
||
98 | systemctl start grafana-server |
||
99 | ``` |
||
100 | Ou pour relancer |
||
101 | ``` |
||
102 | systemctl reload prometheus |
||
103 | ``` |
||
104 | 4 | pizzacoca | |
105 | ### Client Prometheus |
||
106 | 5 | pizzacoca | |
107 | Ce client est un serveur qui exporte les métriques sous localhost:9100 |
||
108 | ``` |
||
109 | apt install prometheus-node-exporter |
||
110 | ``` |
||
111 | |||
112 | # Grafana |
||
113 | |||
114 | apt install grafana-enterprise |
||
115 | systemctl start grafana-server |