Skip to content

Commit

Permalink
add weather data
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasberens committed Mar 17, 2024
1 parent 9ef213d commit e6777ec
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 3 deletions.
9 changes: 9 additions & 0 deletions roles/ff_monitor/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
ff_monitor_owm_key: !vault |
$ANSIBLE_VAULT;1.1;AES256
64663337633337313366353262393766346235613136663038643732373935333063366335666632
6663323030353234376639303534666230366334366333660a333136353639663463326365343463
38313662303035373666663161326337613233343433363538633466376439343966613535646562
3263623862333130630a643563343539303035383039343132336366333162353634313664306133
62623934646664643236313736643663333566333135306636356430303133366464353764363035
6261303662613335326263646137346562663839326661303365
30 changes: 29 additions & 1 deletion roles/ff_monitor/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
url: https://apt.grafana.com/gpg.key
state: present


- name: Add grafana APT Repo
ansible.builtin.apt_repository:
repo: deb https://apt.grafana.com stable main
Expand All @@ -29,6 +30,8 @@
owner: prometheus
group: prometheus
notify: Restart prometheus
tags:
- prometheus

- name: Copy prometheus defaults
ansible.builtin.template:
Expand All @@ -38,6 +41,8 @@
owner: root
group: root
notify: Restart prometheus
tags:
- prometheus

- name: Start prometheus collectd-exporter
community.docker.docker_container:
Expand All @@ -52,6 +57,29 @@
tags:
- collectd-exporter

- name: Copy owm-exporter config
ansible.builtin.template:
dest: /opt/owm-exporter.yml
src: owm-exporter.yml.j2
mode: "0640"
owner: root
group: 65532
tags:
- owm-exporter

- name: Start owm-exporter
community.docker.docker_container:
name: owm-exporter
state: started
restart_policy: unless-stopped
image: rkosegi/owm-exporter:v1.0.4
volumes:
- /opt/owm-exporter.yml:/config.yaml
ports:
- 127.0.0.1:9111:9111
tags:
- owm-exporter

- name: Copy grafana config
ansible.builtin.template:
dest: /etc/grafana/grafana.ini
Expand All @@ -75,7 +103,7 @@
name: remove old rrd files
special_time: daily
user: root
job: find /mnt/collectd/rrd/ -type f -mtime +14 -delete; find /mnt/collectd/rrd/ -type d -empty -delete
job: find /mnt/collectd/rrd/ -type f -mtime +30 -delete; find /mnt/collectd/rrd/ -type d -empty -delete

- name: Create a directory if it does not exist
ansible.builtin.file:
Expand Down
12 changes: 12 additions & 0 deletions roles/ff_monitor/templates/owm-exporter.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
apiKey: {{ ff_monitor_owm_key }}
targets:
- name: Alexanderplatz
lat: 52.5220
lon: 13.4133
interval: 900

- name: Teufelsberg
lat: 52.4972
lon: 13.2411
interval: 900
2 changes: 1 addition & 1 deletion roles/ff_monitor/templates/prometheus.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# {{ ansible_managed }}
# Set the command-line arguments to pass to the server.

ARGS="--storage.tsdb.retention.size=90GB --enable-feature=memory-snapshot-on-shutdown --web.listen-address=127.0.0.1:9090"
ARGS="--storage.tsdb.retention.size=100GB --enable-feature=memory-snapshot-on-shutdown --web.listen-address=127.0.0.1:9090"
9 changes: 8 additions & 1 deletion roles/ff_monitor/templates/prometheus.yml.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.

external_labels:
monitor: 'example'
alerting:
alertmanagers:
- static_configs:
Expand Down Expand Up @@ -41,3 +42,9 @@ scrape_configs:
{% for host in groups.all %}
- "{{ host }}:9100"
{% endfor %}

- job_name: 'weather'
scrape_interval: 900s
scrape_timeout: 30s
static_configs:
- targets: ['127.0.0.1:9111']

0 comments on commit e6777ec

Please sign in to comment.