Move prometheus to on disk

This commit is contained in:
Javier Feliz 2025-07-13 05:00:22 -04:00
parent b5ce914073
commit 3c64a12f85
7 changed files with 18 additions and 14 deletions

View File

@ -6,8 +6,8 @@
# - docker/install # - docker/install
# - docker/portainer # - docker/portainer
# - observability/grafana # - observability/grafana
# - observability/prometheus - observability/prometheus
- observability/beszel-hub # - observability/beszel-hub
tasks: tasks:
# - name: Deploy promlens # - name: Deploy promlens
# community.docker.docker_container: # community.docker.docker_container:

View File

@ -4,7 +4,7 @@
become: true become: true
roles: roles:
# - role: observability/prometheus-node-exporter # - role: observability/prometheus-node-exporter
- role: observability/beszel-agent # - role: observability/beszel-agent
# - role: docker/install # - role: docker/install
# - role: docker/portainer # - role: docker/portainer
# - role: server/setup/sshkey # - role: server/setup/sshkey

View File

@ -6,7 +6,7 @@
- name: Generate Prometheus config from template - name: Generate Prometheus config from template
ansible.builtin.template: ansible.builtin.template:
src: templates/prometheus.yml.j2 src: templates/prometheus.yml.j2
dest: "{{ container_data_base_path }}/prometheus/prometheus.yml" dest: "/home/docker/prometheus/prometheus.yml"
- name: Restart prometheus container - name: Restart prometheus container
community.docker.docker_container: community.docker.docker_container:

View File

@ -1,7 +1,7 @@
#jinja2: trim_blocks: True, lstrip_blocks: True #jinja2: trim_blocks: True, lstrip_blocks: True
global: global:
scrape_interval: "15s" scrape_interval: "5s"
scrape_configs: scrape_configs:
- job_name: node - job_name: node
@ -11,5 +11,5 @@ scrape_configs:
{% for host in groups['vms'] %} {% for host in groups['vms'] %}
- targets: ['{{ hostvars[host].ansible_host }}:9100'] - targets: ['{{ hostvars[host].ansible_host }}:9100']
labels: labels:
instance_name: '{{ host }}' name: '{{ host }}'
{% endfor %} {% endfor %}

View File

@ -3,6 +3,7 @@
name: beszel name: beszel
image: henrygd/beszel:latest image: henrygd/beszel:latest
restart_policy: unless-stopped restart_policy: unless-stopped
state: started
ports: ports:
- 8090:8090 - 8090:8090
volumes: volumes:
@ -10,11 +11,12 @@
- ./beszel_socket:/beszel_socket - ./beszel_socket:/beszel_socket
- name: Deploy local agent - name: Deploy local agent
community.docker.docker_config: community.docker.docker_container:
name: beszel-agent name: beszel-agent
image: henrygd/beszel-agent:latest image: henrygd/beszel-agent:latest
restart_policy: unless-stopped restart_policy: unless-stopped
network_mode: host network_mode: host
state: started
volumes: volumes:
- ./beszel_socket:/beszel_socket - ./beszel_socket:/beszel_socket
- /var/run/docker.sock:/var/run/docker.sock:ro - /var/run/docker.sock:/var/run/docker.sock:ro

View File

@ -4,6 +4,7 @@
image: quay.io/prometheus/node-exporter:latest image: quay.io/prometheus/node-exporter:latest
command: "--path.rootfs=/host" command: "--path.rootfs=/host"
state: started state: started
restart: true
network_mode: host network_mode: host
pid_mode: host pid_mode: host
restart_policy: unless-stopped restart_policy: unless-stopped

View File

@ -1,12 +1,12 @@
- name: Create data folder on NAS - name: Create data folder
ansible.builtin.include_role: ansible.builtin.file:
role: docker/container-data dest: "/home/docker/prometheus/data"
vars: state: directory
dir_name: "prometheus" mode: '0777'
- name: Set facts - name: Set facts
ansible.builtin.set_fact: ansible.builtin.set_fact:
data_dir: "{{ container_data_base_path }}/prometheus" data_dir: "/home/docker/prometheus"
- name: Create config file - name: Create config file
ansible.builtin.file: ansible.builtin.file:
@ -19,11 +19,12 @@
name: prometheus name: prometheus
image: prom/prometheus image: prom/prometheus
state: started state: started
restart: true
restart_policy: unless-stopped restart_policy: unless-stopped
# env: # env:
# GF_SERVER_ROOT_URL: "https://dash.lan.thegrind.dev" # GF_SERVER_ROOT_URL: "https://dash.lan.thegrind.dev"
ports: ports:
- '9090:9090' - '9090:9090'
volumes: volumes:
- "{{ data_dir }}:/prometheus" - "{{ data_dir }}/data:/prometheus"
- "{{ data_dir }}/prometheus.yml:/etc/prometheus/prometheus.yml" - "{{ data_dir }}/prometheus.yml:/etc/prometheus/prometheus.yml"