add varnish exporter
This commit is contained in:
parent
e01e571906
commit
4c9be50c29
44
README.md
44
README.md
@ -12,28 +12,28 @@ It has been tested on :
|
|||||||
Role variables
|
Role variables
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
| Variable | Type | Choices | Default | Comment |
|
| Variable | Type | Choices | Default | Comment |
|
||||||
|----------------------------------------------|---------|------------------------------------------------------------------|-------------|-----------------|
|
|----------------------------------------------|---------|----------------------------------------------------------------------------|-------------|-----------------|
|
||||||
| prometheus_server_enable | string | true / false | | |
|
| prometheus_server_enable | string | true / false | | |
|
||||||
| prometheus_server_version | string | | latest | |
|
| prometheus_server_version | string | | latest | |
|
||||||
| prometheus_server_monitor | string | | | |
|
| prometheus_server_monitor | string | | | |
|
||||||
| prometheus_server_global_scrape_interval | string | | 15 | |
|
| prometheus_server_global_scrape_interval | string | | 15 | |
|
||||||
| prometheus_server_global_evaluation_interval | string | | 15 | |
|
| prometheus_server_global_evaluation_interval | string | | 15 | |
|
||||||
| prometheus_server_job_name | string | | prometheus | |
|
| prometheus_server_job_name | string | | prometheus | |
|
||||||
| prometheus_server_scrape_interval | string | | 5 | |
|
| prometheus_server_scrape_interval | string | | 5 | |
|
||||||
| prometheus_server_scrape_timeout | string | | 5 | |
|
| prometheus_server_scrape_timeout | string | | 5 | |
|
||||||
| prometheus_exporter_packages | list | node / mysqld / postgresql / mongodb / phpfpm / apache / haproxy | | |
|
| prometheus_exporter_packages | list | node / mysqld / postgresql / mongodb / phpfpm / apache / haproxy / varnish | | |
|
||||||
| prometheus_node_exporter_targets | list | | | |
|
| prometheus_node_exporter_targets | list | | | |
|
||||||
| prometheus_mysqld_exporter_targets | list | | | |
|
| prometheus_mysqld_exporter_targets | list | | | |
|
||||||
| prometheus_mongodb_exporter_targets | list | | | |
|
| prometheus_mongodb_exporter_targets | list | | | |
|
||||||
| prometheus_postgres_exporter_targets | list | | | |
|
| prometheus_postgres_exporter_targets | list | | | |
|
||||||
| prometheus_mysqld_exporter_user | string | | | |
|
| prometheus_mysqld_exporter_user | string | | | |
|
||||||
| prometheus_mysqld_exporter_password | string | | | |
|
| prometheus_mysqld_exporter_password | string | | | |
|
||||||
| prometheus_mongodb_exporter_host | string | | localhost | |
|
| prometheus_mongodb_exporter_host | string | | localhost | |
|
||||||
| prometheus_mongodb_exporter_port | string | | 27017 | |
|
| prometheus_mongodb_exporter_port | string | | 27017 | |
|
||||||
| prometheus_mongodb_exporter_user | string | | | |
|
| prometheus_mongodb_exporter_user | string | | | |
|
||||||
| prometheus_mongodb_exporter_pass | string | | | |
|
| prometheus_mongodb_exporter_pass | string | | | |
|
||||||
| prometheus_server_version | string | | latest | |
|
| prometheus_server_version | string | | latest | |
|
||||||
|
|
||||||
Dependencies
|
Dependencies
|
||||||
------------
|
------------
|
||||||
|
@ -46,3 +46,10 @@
|
|||||||
state: restarted
|
state: restarted
|
||||||
enabled: yes
|
enabled: yes
|
||||||
tags: ['prometheus']
|
tags: ['prometheus']
|
||||||
|
|
||||||
|
- name: 'prometheus | varnish exporter | restart service'
|
||||||
|
systemd:
|
||||||
|
name: prometheus-varnish-exporter.service
|
||||||
|
state: restarted
|
||||||
|
enabled: yes
|
||||||
|
tags: ['prometheus']
|
||||||
|
@ -39,3 +39,8 @@
|
|||||||
include_tasks: 'apache_exporter.yml'
|
include_tasks: 'apache_exporter.yml'
|
||||||
when:
|
when:
|
||||||
- "'apache' in prometheus_exporter_packages"
|
- "'apache' in prometheus_exporter_packages"
|
||||||
|
|
||||||
|
- name: 'prometheus | Varnish exporter'
|
||||||
|
include_tasks: 'varnish_exporter.yml'
|
||||||
|
when:
|
||||||
|
- "'varnish' in prometheus_exporter_packages"
|
||||||
|
43
tasks/varnish_exporter.yml
Normal file
43
tasks/varnish_exporter.yml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
---
|
||||||
|
- name: 'prometheus | varnish exporter | get latest release from GitHub'
|
||||||
|
shell: curl --silent "https://api.github.com/repos/jonnenauha/prometheus_varnish_exporter/releases/latest" | jq -r .tag_name | sed "s/v//"
|
||||||
|
args:
|
||||||
|
warn: false
|
||||||
|
register: prometheus_varnish_exporter_latest_version
|
||||||
|
run_once: true
|
||||||
|
|
||||||
|
- name: 'prometheus | varnish exporter | download'
|
||||||
|
get_url:
|
||||||
|
url: https://github.com/jonnenauha/prometheus_varnish_exporter/releases/download/v{{ prometheus_varnish_exporter_version|default(prometheus_varnish_exporter_latest_version.stdout) }}/varnish_exporter-{{ prometheus_varnish_exporter_version|default(prometheus_varnish_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
|
||||||
|
dest: /tmp
|
||||||
|
|
||||||
|
- name: 'prometheus | varnish exporter | unarchive'
|
||||||
|
unarchive:
|
||||||
|
remote_src: yes
|
||||||
|
src: /tmp/varnish_exporter-{{ prometheus_varnish_exporter_version|default(prometheus_varnish_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
|
||||||
|
dest: /tmp
|
||||||
|
|
||||||
|
- name: 'prometheus | varnish exporter | move to /usr/local/bin'
|
||||||
|
copy:
|
||||||
|
src: /tmp/varnish_exporter-{{ prometheus_varnish_exporter_version|default(prometheus_varnish_exporter_latest_version.stdout) }}.linux-amd64/varnish_exporter
|
||||||
|
dest: /usr/local/bin/prometheus-varnish-exporter
|
||||||
|
remote_src: yes
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0755
|
||||||
|
notify:
|
||||||
|
- 'prometheus | varnish exporter | restart service'
|
||||||
|
|
||||||
|
- name: 'prometheus | varnish exporter | install unit file to systemd'
|
||||||
|
template:
|
||||||
|
src: systemd/prometheus-varnish-exporter.service.j2
|
||||||
|
dest: /etc/systemd/system/prometheus-varnish-exporter.service
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0600
|
||||||
|
|
||||||
|
- name: 'prometheus | varnish exporter | configure systemd to use service'
|
||||||
|
systemd:
|
||||||
|
daemon_reload: yes
|
||||||
|
enabled: yes
|
||||||
|
name: prometheus-varnish-exporter.service
|
@ -107,3 +107,14 @@ scrape_configs:
|
|||||||
- {{ target }}:8404
|
- {{ target }}:8404
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if prometheus_varnish_exporter_targets is defined %}
|
||||||
|
- job_name: varnish
|
||||||
|
scrape_interval: 30s
|
||||||
|
scrape_timeout: 10s
|
||||||
|
static_configs:
|
||||||
|
- targets:
|
||||||
|
{% for target in prometheus_varnish_exporter_targets %}
|
||||||
|
- {{ target }}:9131
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Prometheus Varnish Exporter
|
Description=Prometheus Varnish Exporter
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
ExecStart=/usr/local/bin/prometheus-varnish-exporter
|
ExecStart=/usr/local/bin/prometheus-varnish-exporter
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
Loading…
x
Reference in New Issue
Block a user