Projet

Général

Profil

Prometheus-grafana » Historique » Version 3

pizzacoca, 07/03/2020 06:56

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
## Serveur Prometheus
11
12
### Installation
13
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 2 pizzacoca
La configuration se fait via un fichier yaml. Ici un exemple.
30 1 pizzacoca
**/etc/prometheus/prometheus.yml**
31 2 pizzacoca
```
32
# Sample config for Prometheus.
33 1 pizzacoca
34 2 pizzacoca
global:
35
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
36
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
37
  # scrape_timeout is set to the global default (10s).
38
39
  # Attach these labels to any time series or alerts when communicating with
40
  # external systems (federation, remote storage, Alertmanager).
41
  external_labels:
42
      monitor: 'example'
43
44
# Alertmanager configuration
45
alerting:
46
  alertmanagers:
47
  - static_configs:
48
    - targets: ['localhost:9093']
49
50
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
51
rule_files:
52
  # - "first_rules.yml"
53
  # - "second_rules.yml"
54
55
# A scrape configuration containing exactly one endpoint to scrape:
56
# Here it's Prometheus itself.
57
scrape_configs:
58
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
59
  - job_name: 'prometheus'
60
61
    # Override the global default and scrape targets from this job every 5 seconds.
62
    scrape_interval: 5s
63
    scrape_timeout: 5s
64
65
    # metrics_path defaults to '/metrics'
66
    # scheme defaults to 'http'.
67
68
    static_configs:
69
      - targets: ['localhost:9090']
70
71
  - job_name: Mes_machines_virtuelles
72
    static_configs:
73
      - targets: 
74
        - 'domaine.associe.ou.adresse.ip:9100'
75
        - 'XXX.XXX.XXX.XXX:9100'
76
77
78
  - job_name: noeud_pour_autres_machines
79
    # If prometheus-node-exporter is installed, grab stats about the local
80
    # machine by default.
81
    static_configs:
82
        # première syntaxe yaml
83
        #- targets: ['localhost:9100']
84
        # deuxième syntaxe yaml
85
      - targets: 
86
        - 'localhost:9100' # la machine qui s'écoute
87
        - 'XXX.XXX.XXX.XXX:9100'
88
        - 'YYY.YYY.YYY.YYY:9100'
89
```
90
91 1 pizzacoca
### Lancement
92
93
```
94
systemctl start grafana-server
95
```
96
Ou pour relancer
97
```
98
systemctl reload prometheus
99
```