-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from sozialinfo/feature/push-gateway-scraper
Feature/push gateway scraper
- Loading branch information
Showing
8 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Prometheus role | ||
|
||
Deploy Pushgateway container. | ||
|
||
## Usage | ||
|
||
Configure the role. | ||
|
||
```yml | ||
# https://hub.docker.com/r/prom/pushgateway | ||
pushgateway_image: prom/pushgateway:v1.11.0 | ||
pushgateway_hostname: pushgw01 | ||
pushgateway_description: Pushgateway # default: Pushgateway | ||
pushgateway_volume_name: pushgw_data01 # default: "{{ pushgateway_hostname }}" | ||
pushgateway_data_dir: /usr/share/pushgw # default: "/usr/share/{{ pushgateway_hostname }}" | ||
pushgateway_port: 127.0.0.1:9091 # default: 127.0.0.1:9091 | ||
pushgateway_etc_hosts: # defaults: {} | ||
"server.example.com": 10.42.5.2 | ||
pushgateway_proxy_basic_auth_username: metric # default: pushgateway | ||
pushgateway_proxy_basic_auth_password: # default: "{{ vault_pushgateway_proxy_basic_auth_password }}" | ||
``` | ||
Ensure the nginx proxy includes the exporter config: | ||
```yml | ||
nginx_proxies: | ||
- src_hostname: server.example.com | ||
ssl: true | ||
monitor: / | ||
exporter: node,cadvsior,nextcloud,bigbluebutton,postgres,restic,mysqld,odoo | ||
options: | | ||
include /etc/nginx/conf.d/proxies/node-exporter.nginx; | ||
include /etc/nginx/conf.d/proxies/cadvisor.nginx; | ||
include /etc/nginx/conf.d/proxies/nextcloud-exporter.nginx; | ||
include /etc/nginx/conf.d/proxies/bigbluebutton-exporter.nginx; | ||
include /etc/nginx/conf.d/proxies/postgres-exporter.nginx; | ||
include /etc/nginx/conf.d/proxies/mysqld-exporter.nginx; | ||
include /etc/nginx/conf.d/proxies/odoo-exporter.nginx; | ||
include /etc/nginx/conf.d/proxies/n8n-exporter.nginx; | ||
``` | ||
And include it in your playbook. | ||
```yml | ||
- hosts: pushgateway | ||
roles: | ||
- role: pushgateway | ||
``` | ||
## Docs | ||
Pushgateway is used to monitor cronjobs | ||
### Deploy Pushgateway container | ||
Select multiple inventories when deploying. | ||
```bash | ||
ansible-playbook -i inventories/odoo -i inventories/nextcloud -i inventories/setup plays/setup.yml -l pushgateway -t pushgateway | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
pushgateway_port: 127.0.0.1:9091 | ||
pushgateway_description: Pushgateway | ||
pushgateway_volume_name: "{{ pushgateway_hostname }}" | ||
pushgateway_data_dir: /usr/share/{{ pushgateway_hostname }} | ||
pushgateway_etc_hosts: {} | ||
pushgateway_nginx_data_dir: "{{ nginx_data_dir }}/proxies" | ||
pushgateway_requires_package: python3-passlib | ||
pushgateway_proxy_basic_auth_username: pushgateway | ||
pushgateway_proxy_basic_auth_password: "{{ vault_pushgateway_proxy_basic_auth_password}}" | ||
pushgateway_hostname: pushgateway01 | ||
pushgateway_args: | ||
- --web.listen-address={{ pushgateway_port }} | ||
#- --web.external-url= | ||
- --web.route-prefix="/pushgateway" | ||
- --persistence.file=/pushgateway/state | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
dependencies: # noqa 701 | ||
- role: docker_network | ||
tags: | ||
- docker_network | ||
- depends |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
- name: Include {{ role_name }} tasks | ||
ansible.builtin.include_tasks: "{{ role_name }}.yml" | ||
when: pushgateway_image is defined | ||
tags: | ||
- pushgateway | ||
|
||
- name: Include {{ role_name }} nginx config tasks | ||
ansible.builtin.include_tasks: "{{ role_name }}_nginx_config.yml" | ||
when: pushgateway_image is defined | ||
tags: | ||
- pushgateway | ||
- pushgateway_nginx_config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
- name: Create {{ role_name }} volume | ||
community.docker.docker_volume: | ||
name: "{{ pushgateway_volume_name }}" | ||
|
||
- name: Ensure {{ role_name }} data dir exists | ||
ansible.builtin.file: | ||
path: "{{ pushgateway_data_dir }}" | ||
state: directory | ||
|
||
- name: Start {{ role_name }} container {{ pushgateway_hostname }} | ||
community.docker.docker_container: | ||
name: "{{ pushgateway_hostname }}" | ||
labels: | ||
description: "{{ pushgateway_description }}" | ||
image: "{{ pushgateway_image }}" | ||
restart_policy: unless-stopped | ||
command: "{{ pushgateway_args | join(' ') }}" | ||
volumes: | ||
- "{{ pushgateway_volume_name }}:/pushgateway" | ||
ports: | ||
- "{{ pushgateway_port }}:9091" | ||
networks: | ||
- name: "{{ docker_network_name }}" | ||
network_mode: bridge | ||
etc_hosts: "{{ pushgateway_etc_hosts }}" | ||
log_driver: "{{ docker_log_driver }}" | ||
log_options: | ||
max-size: "{{ docker_log_max_size }}" | ||
max-file: "{{ docker_log_max_file }}" | ||
tag: "{{ pushgateway_hostname }}|{{ role_name }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
- name: Ensure nginx data dir exists | ||
ansible.builtin.file: | ||
path: "{{ pushgateway_nginx_data_dir }}" | ||
state: directory | ||
|
||
- name: Gather package facts | ||
ansible.builtin.package_facts: | ||
manager: auto | ||
|
||
- name: Fail if package {{ pushgateway_requires_package }} is not installed | ||
ansible.builtin.assert: | ||
that: | ||
- pushgateway_requires_package in ansible_facts.packages | ||
fail_msg: Package {{ pushgateway_requires_package }} is not installed! | ||
|
||
- name: Configure user access for {{ role_name }} | ||
community.general.htpasswd: | ||
path: "{{ pushgateway_nginx_data_dir }}/pushgateway.htpasswd" | ||
name: "{{ pushgateway_proxy_basic_auth_username }}" | ||
password: "{{ pushgateway_proxy_basic_auth_password }}" | ||
|
||
- name: Copy nginx {{ role_name }} conf | ||
ansible.builtin.template: | ||
src: pushgateway.nginx | ||
dest: "{{ pushgateway_nginx_data_dir }}/pushgateway.nginx" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
location /pushgateway/ { | ||
auth_basic "{{ pushgateway_proxy_basic_auth_username }}"; | ||
auth_basic_user_file /etc/nginx/conf.d/proxies/pushgateway.htpasswd; | ||
proxy_pass http://{{ pushgateway_hostname }}:9091; | ||
include /etc/nginx/conf.d/proxy-params.conf; | ||
} |