Projet

Général

Profil

Prometheus-grafana » Historique » Version 2

pizzacoca, 07/03/2020 06:53

1 1 pizzacoca
# Prometheus-grafana
2
3
**[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)** .
4
5
Prometheus existe aussi sous la forme de paquets pour debian10, ce que nous allons utiliser.
6
7
8
## Serveur Prometheus
9
10
### Installation
11
12
**/etc/apt/sources.list**
13
```
14
deb https://packages.grafana.com/enterprise/deb stable main
15
```
16
17
Il est nécessaire d'ajouter la clef gpg pour ce dépôt.
18
```
19
gpg --receive-key 8C8C34C524098CB6
20
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8C8C34C524098CB6
21
apt update
22
apt install grafana-enterprise
23
```
24
25
### Configuration
26
27 2 pizzacoca
La configuration se fait via un fichier yaml. Ici un exemple.
28 1 pizzacoca
**/etc/prometheus/prometheus.yml**
29 2 pizzacoca
```
30
# Sample config for Prometheus.
31 1 pizzacoca
32 2 pizzacoca
global:
33
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
34
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
35
  # scrape_timeout is set to the global default (10s).
36
37
  # Attach these labels to any time series or alerts when communicating with
38
  # external systems (federation, remote storage, Alertmanager).
39
  external_labels:
40
      monitor: 'example'
41
42
# Alertmanager configuration
43
alerting:
44
  alertmanagers:
45
  - static_configs:
46
    - targets: ['localhost:9093']
47
48
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
49
rule_files:
50
  # - "first_rules.yml"
51
  # - "second_rules.yml"
52
53
# A scrape configuration containing exactly one endpoint to scrape:
54
# Here it's Prometheus itself.
55
scrape_configs:
56
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
57
  - job_name: 'prometheus'
58
59
    # Override the global default and scrape targets from this job every 5 seconds.
60
    scrape_interval: 5s
61
    scrape_timeout: 5s
62
63
    # metrics_path defaults to '/metrics'
64
    # scheme defaults to 'http'.
65
66
    static_configs:
67
      - targets: ['localhost:9090']
68
69
  - job_name: Mes_machines_virtuelles
70
    static_configs:
71
      - targets: 
72
        - 'domaine.associe.ou.adresse.ip:9100'
73
        - 'XXX.XXX.XXX.XXX:9100'
74
75
76
  - job_name: noeud_pour_autres_machines
77
    # If prometheus-node-exporter is installed, grab stats about the local
78
    # machine by default.
79
    static_configs:
80
        # première syntaxe yaml
81
        #- targets: ['localhost:9100']
82
        # deuxième syntaxe yaml
83
      - targets: 
84
        - 'localhost:9100' # la machine qui s'écoute
85
        - 'XXX.XXX.XXX.XXX:9100'
86
        - 'YYY.YYY.YYY.YYY:9100'
87
```
88
89 1 pizzacoca
### Lancement
90
91
```
92
systemctl start grafana-server
93
```
94
Ou pour relancer
95
```
96
systemctl reload prometheus
97
```