From 98faa391f04dc6d3594f05e048c76b1bc5ef7cff Mon Sep 17 00:00:00 2001 From: Aykhan Shahsuvarov Date: Fri, 11 Apr 2025 00:41:27 +0400 Subject: [PATCH] Add prometheus --- prometheus/.gitignore | 2 ++ prometheus/data/config/prometheus.yaml | 18 ++++++++++ prometheus/docker-compose.yml | 48 ++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 prometheus/.gitignore create mode 100644 prometheus/data/config/prometheus.yaml create mode 100644 prometheus/docker-compose.yml diff --git a/prometheus/.gitignore b/prometheus/.gitignore new file mode 100644 index 0000000..5f2aa29 --- /dev/null +++ b/prometheus/.gitignore @@ -0,0 +1,2 @@ +/data/* +!/data/config \ No newline at end of file diff --git a/prometheus/data/config/prometheus.yaml b/prometheus/data/config/prometheus.yaml new file mode 100644 index 0000000..428bee7 --- /dev/null +++ b/prometheus/data/config/prometheus.yaml @@ -0,0 +1,18 @@ +global: + scrape_interval: 10s + +scrape_configs: + - job_name: "node_exporter" + scrape_interval: 2s + static_configs: + - targets: ["node_exporter:9100"] + + - job_name: "cadvisor" + scrape_interval: 2s + static_configs: + - targets: ["cadvisor:8080"] + + - job_name: caddy + scrape_interval: 2s + static_configs: + - targets: ["caddy:2019"] diff --git a/prometheus/docker-compose.yml b/prometheus/docker-compose.yml new file mode 100644 index 0000000..3a2c892 --- /dev/null +++ b/prometheus/docker-compose.yml @@ -0,0 +1,48 @@ +networks: + prometheus: + external: false + grafana: + name: grafana + driver: bridge + external: true + +services: + prometheus: + image: prom/prometheus:v3.2.1 + container_name: prometheus + networks: + - prometheus + - grafana + command: "--config.file=/etc/prometheus/prometheus.yaml --storage.tsdb.retention.time=10d storage.tsdb.retention.size=5GB" + volumes: + - ./data/config/prometheus.yaml:/etc/prometheus/prometheus.yaml:ro + - prometheus-data:/prometheus + + node_exporter: + image: quay.io/prometheus/node-exporter:v1.9.1 + container_name: node_exporter + networks: + - prometheus + command: + - "--path.rootfs=/host" + pid: host + volumes: + - "/:/host:ro,rslave" + + cadvisor: + image: gcr.io/cadvisor/cadvisor:v0.49.1 + container_name: cadvisor + networks: + - prometheus + volumes: + - "/:/rootfs:ro" + - "/var/run:/var/run:ro" + - "/sys:/sys:ro" + - "/var/lib/docker/:/var/lib/docker:ro" + - "/dev/disk/:/dev/disk:ro" + privileged: true + devices: + - "/dev/kmsg:/dev/kmsg" + +volumes: + prometheus-data: