tech:notes_prometheus
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| tech:notes_prometheus [2025/04/04 19:46] – Jean-Baptiste | tech:notes_prometheus [2026/07/16 11:45] (Version actuelle) – Jean-Baptiste | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| + | {{tag> | ||
| + | |||
| + | # Notes Prometheus | ||
| + | |||
| + | Voir : | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * PromQL | ||
| + | * https:// | ||
| + | |||
| + | |||
| + | Voir aussi : | ||
| + | * Prometheus VictoriaMetrics victoriadb | ||
| + | * Alertmanager (as part of Prometheus) | ||
| + | * https:// | ||
| + | |||
| + | Voir Identity correlation / CorrelationId | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | ## Serveur | ||
| + | |||
| + | ~~~bash | ||
| + | #docker run -p 9090:9090 -v ~/ | ||
| + | |||
| + | mkdir -p prometheus/ | ||
| + | #sudo docker run -p 9090:9090 -v ~/ | ||
| + | podman run -p 9090:9090 -v ~/ | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | Config | ||
| + | |||
| + | `prometheus.yml` | ||
| + | ~~~yaml | ||
| + | # my global config | ||
| + | global: | ||
| + | scrape_interval: | ||
| + | evaluation_interval: | ||
| + | # scrape_timeout is set to the global default (10s). | ||
| + | |||
| + | # Alertmanager configuration | ||
| + | alerting: | ||
| + | alertmanagers: | ||
| + | - static_configs: | ||
| + | - targets: | ||
| + | # - alertmanager: | ||
| + | |||
| + | # Load rules once and periodically evaluate them according to the global ' | ||
| + | rule_files: | ||
| + | # - " | ||
| + | # - " | ||
| + | |||
| + | # A scrape configuration containing exactly one endpoint to scrape: | ||
| + | # Here it's Prometheus itself. | ||
| + | scrape_configs: | ||
| + | # The job name is added as a label `job=< | ||
| + | - job_name: ' | ||
| + | |||
| + | # metrics_path defaults to '/ | ||
| + | # scheme defaults to ' | ||
| + | |||
| + | # static_configs: | ||
| + | # - targets: [' | ||
| + | | ||
| + | - job_name: ' | ||
| + | file_sd_configs: | ||
| + | - files: [ "/ | ||
| + | ~~~ | ||
| + | |||
| + | `prometheus/ | ||
| + | ~~~yaml | ||
| + | - targets: [ " | ||
| + | labels: | ||
| + | # Vous pouvez ajouter ce que vous voulez pour taguer la machine | ||
| + | host: " | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Exporter (client) | ||
| + | |||
| + | Voir aussi : | ||
| + | * check-mk-agent | ||
| + | |||
| + | |||
| + | Créer un compte **node_exporter** | ||
| + | |||
| + | `/ | ||
| + | ~~~ini | ||
| + | [Unit] | ||
| + | Description=node_exporter | ||
| + | Wants=network-online.target | ||
| + | After=network-online.target | ||
| + | |||
| + | [Service] | ||
| + | User=node_exporter | ||
| + | Group=node_exporter | ||
| + | Restart=on-failure | ||
| + | Type=simple | ||
| + | ExecStart=/ | ||
| + | |||
| + | [Install] | ||
| + | WantedBy=multi-user.target | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | |||
| + | # Grafana | ||
| + | |||
| + | Prometheus | ||
| + | |||
| + | |||
| + | Voir | ||
| + | |||
| + | ~~~bash | ||
| + | docker run -d --name=grafana -p 3000:3000 grafana/ | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | # Voir https:// | ||
| + | |||
| + | `docker-compose.yml` | ||
| + | ~~~yaml | ||
| + | version: ' | ||
| + | services: | ||
| + | grafana: | ||
| + | image: grafana/ | ||
| + | ports: | ||
| + | - 3000:3000 | ||
| + | volume: | ||
| + | - " | ||
| + | ~~~ | ||
| + | |||
| + | Run Grafana container with persistent storage (recommended) | ||
| + | |||
| + | Create a persistent volume for your data in / | ||
| + | ~~~bash | ||
| + | docker volume create grafana-storage | ||
| + | ~~~ | ||
| + | |||
| + | Start grafana | ||
| + | ~~~bash | ||
| + | docker run -d -p 3000:3000 --name=grafana -v grafana-storage:/ | ||
| + | ~~~ | ||
| + | |||
| + | Run Grafana container using bind mounts | ||
| + | |||
| + | You may want to run Grafana in Docker but use folders on your host for the database or configuration. When doing so, it becomes important to start the container with a user that is able to access and write to the folder you map into the container. | ||
| + | |||
| + | ~~~bash | ||
| + | mkdir data # creates a folder for your data | ||
| + | ID=$(id -u) # saves your user id in the ID variable | ||
| + | |||
| + | # starts grafana with your user id and using the data folder | ||
| + | #docker run -d --user $ID --volume " | ||
| + | |||
| + | podman run --volume " | ||
| + | |||
| + | ~~~ | ||
| + | |||
| + | |||
| + | |||
