diff --git a/prometheus.md b/prometheus.md index 73a7a37..bc2896f 100644 --- a/prometheus.md +++ b/prometheus.md @@ -102,22 +102,30 @@ sudo systemctl status prometheus ## Docker +```shell +docker run --detach --name prometheus \ + --network proxy_net \ + -p "9090:9090" \ + -v prometheus:/prometheus \ + -v ./prometheus:/etc/prometheus/targets \ + -l "caddy=prometheus.localhost" \ + -l "caddy.reverse_proxy={{upstreams 9090}}" \ + -l "caddy.tls=internal" \ + prom/prometheus:v3.8.0 +``` + prometheus: - container_name: r5a10-prometheus - image: prom/prometheus:${PROMETHEUS_VERSION:-v2.53.0} - restart: no + command: - '--config.file=/etc/prometheus/prometheus.yml' configs: - source: prometheus_config target: /etc/prometheus/prometheus.yml volumes: - - prometheus:/prometheus - /var/run/docker.sock:/var/run/docker.sock:ro - ports: - - 9090:9090 extra_hosts: - host.docker.internal=host-gateway + #/etc/docker/daemon.json #{ # "metrics-addr": "0.0.0.0:9323" diff --git a/prometheus.yml b/prometheus.yml new file mode 100644 index 0000000..45f0f4e --- /dev/null +++ b/prometheus.yml @@ -0,0 +1,25 @@ +global: + scrape_interval: 5s + +scrape_configs: + - job_name: 'prometheus' + scrape_interval: 1m + static_configs: + - targets: ['localhost:9090'] + + - job_name: 'apps_dynamiques' + file_sd_configs: + - files: + - /etc/prometheus/targets/*.yml + + - job_name: docker + docker_sd_configs: + - host: unix:///var/run/docker.sock + refresh_interval: 15s + filters: + - name: label + values: ['prometheus=true'] + relabel_configs: + - source_labels: ['__meta_docker_container_name'] + regex: '/(.*)' + target_label: 'container' \ No newline at end of file diff --git a/prometheus/.gitkeep b/prometheus/.gitkeep new file mode 100644 index 0000000..e69de29