Skip to content

Commit 6940145

Browse files
committed
Configure Prometheus in Ansible
1 parent 2a943a6 commit 6940145

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

files/prometheus.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
3+
scrape_configs:
4+
- job_name: prometheus
5+
static_configs:
6+
- targets: ['localhost:9090']
7+
8+
- job_name: node
9+
static_configs:
10+
- targets: ['localhost:9100']
11+
12+
- job_name: caddy
13+
static_configs:
14+
- targets: ['localhost:2019']

website.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,28 @@
172172
enabled: true
173173
state: started
174174

175+
# Monitoring setup
176+
# ################
177+
- name: Configure Prometheus
178+
ansible.builtin.copy:
179+
src: prometheus.yml
180+
dest: /etc/prometheus/prometheus.yml
181+
mode: 0644
182+
notify:
183+
- Restart Prometheus
184+
185+
- name: Enable prometheus node exporter service
186+
ansible.builtin.systemd:
187+
name: prometheus-node-exporter.service
188+
enabled: true
189+
state: started
190+
191+
- name: Enable prometheus service
192+
ansible.builtin.systemd:
193+
name: prometheus.service
194+
enabled: true
195+
state: started
196+
175197
# Handlers restart/reload services at playbook completion
176198
# #######################################################
177199
handlers:
@@ -189,6 +211,11 @@
189211
name: caddy
190212
state: restarted
191213

214+
- name: Restart Prometheus
215+
ansible.builtin.systemd:
216+
name: prometheus
217+
state: restarted
218+
192219
- name: Restart webhook
193220
ansible.builtin.systemd:
194221
name: webhook

0 commit comments

Comments
 (0)