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