Commit d1a89358 authored by PizZaKatZe's avatar PizZaKatZe
Browse files

Configure NGINX monitoring using separate role

parent 850a3712
......@@ -6,6 +6,7 @@
roles:
- common
- jitsi
- prometheus-nginx-exporter
- cloudalchemy.grafana
- cloudalchemy.node-exporter
- cloudalchemy.prometheus
......@@ -29,6 +30,7 @@
node:
- targets:
- '127.0.0.1:9100'
- '127.0.0.1:9113'
- '127.0.0.1:9888'
prometheus_jitsi_meet_exporter_version: 1.1.1
prometheus_jitsi_meet_exporter_videobridge_url: http://localhost:8080/colibri/stats
# vim: ts=2 sw=2 et
---
nginx_prometheus_exporter_version: 0.7.0
nginx_prometheus_exporter_listen_port: :9113
nginx_stub_status_port: 8787
# vim: ts=2 sw=2 et
---
- name: Reload nginx
systemd:
name: nginx.service
state: reloaded
- name: Restart Nginx Prometheus Exporter
systemd:
name: prometheus-nginx-exporter.service
state: restarted
# vim: ts=2 sw=2 et
---
- name: Generate NGINX stub status site config
template:
src: stub_status.conf
dest: /etc/nginx/sites-available/stub_status.conf
notify: Reload nginx
- name: Enable NGINX stub status site config
file:
src: /etc/nginx/sites-available/stub_status.conf
dest: /etc/nginx/sites-enabled/stub_status.conf
state: link
- name: Get checksums from github.com
set_fact:
_checksums: "{{ query('url', nginx_prometheus_exporter_checksum_url) | list }}"
run_once: true
- name: Extract amd64 checksum
set_fact:
checksum: "{{ item.split(' ')[0] }}"
when: "'amd64' in item"
with_items: "{{ _checksums }}"
- name: Downlaod NGINX Prometheus Exporter
delegate_to: localhost
become: no
get_url:
url: "{{ nginx_prometheus_exporter_download_url }}"
dest: /tmp/nginx_prometheus_exporter.tar.gz
checksum: 'sha256:{{ checksum }}'
register: _download
retries: 3
delay: 4
until: _download is succeeded
- name: Ensure NGINX Prometheus Exporter is installed
unarchive:
src: /tmp/nginx_prometheus_exporter.tar.gz
dest: /usr/local/bin
mode: '755'
notify: Restart Nginx Prometheus Exporter
- name: Generate NGINX Prometheus Exporter systemd unit
template:
src: prometheus-nginx-exporter.service
dest: /etc/systemd/system/prometheus-nginx-exporter.service
register: systemd_unit
- name: Reload systemd daemon
systemd:
daemon_reload: yes
when: systemd_unit is changed
- name: Enable NGINX Prometheus Exporter service
systemd:
name: prometheus-nginx-exporter.service
state: started
enabled: yes
{{ ansible_managed | comment }}
[Unit]
Description=Prometheus Exporter for Nginx
After=network.target
[Service]
Type=simple
DynamicUser=yes
ExecStart=/usr/local/bin/nginx-prometheus-exporter -nginx.scrape-uri {{ nginx_prometheus_exporter_scrape_url }} -web.listen-address {{ nginx_prometheus_exporter_listen_port }}
Restart=always
[Install]
WantedBy=multi-user.target
server {
listen {{ nginx_stub_status_port }};
location = /stub_status {
stub_status;
}
}
# vim: ts=2 sw=2 et
---
nginx_prometheus_exporter_checksum_url: "https://github.com/nginxinc/nginx-prometheus-exporter/releases/download/v{{ nginx_prometheus_exporter_version }}/sha256sums.txt"
nginx_prometheus_exporter_download_url: "https://github.com/nginxinc/nginx-prometheus-exporter/releases/download/v{{ nginx_prometheus_exporter_version }}/nginx-prometheus-exporter-{{ nginx_prometheus_exporter_version }}-linux-amd64.tar.gz"
nginx_prometheus_exporter_scrape_url: "http://localhost:{{ nginx_stub_status_port }}/stub_status"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment