add redis
This commit is contained in:
parent
006ea95681
commit
e53304f8e8
@ -13,7 +13,7 @@ Role variables
|
||||
--------------
|
||||
|
||||
| Variable | Type | Choices | Default | Comment |
|
||||
|----------------------------------------------|---------|----------------------------------------------------------------------------|-------------|-----------------|
|
||||
|----------------------------------------------|---------|------------------------------------------------------------------------------------|-------------------------|-----------------|
|
||||
| prometheus_server_enable | string | true / false | | |
|
||||
| prometheus_server_version | string | | latest | |
|
||||
| prometheus_server_monitor | string | | | |
|
||||
@ -22,7 +22,7 @@ Role variables
|
||||
| prometheus_server_job_name | string | | prometheus | |
|
||||
| prometheus_server_scrape_interval | string | | 5 | |
|
||||
| prometheus_server_scrape_timeout | string | | 5 | |
|
||||
| prometheus_exporter_packages | list | node / mysqld / postgresql / mongodb / phpfpm / apache / haproxy / varnish | | |
|
||||
| prometheus_exporter_packages | list | node / mysqld / postgresql / mongodb / phpfpm / apache / haproxy / varnish / redis | | |
|
||||
| prometheus_node_exporter_targets | list | | | |
|
||||
| prometheus_mysqld_exporter_targets | list | | | |
|
||||
| prometheus_mongodb_exporter_targets | list | | | |
|
||||
@ -34,6 +34,9 @@ Role variables
|
||||
| prometheus_mongodb_exporter_user | string | | | |
|
||||
| prometheus_mongodb_exporter_pass | string | | | |
|
||||
| prometheus_server_version | string | | latest | |
|
||||
| prometheus_redis_exporter_addr | string | | redis://localhost:6379 | |
|
||||
| prometheus_redis_exporter_user | string | | | |
|
||||
| prometheus_redis_exporter_password | string | | | |
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
@ -33,3 +33,7 @@ prometheus_server_scrape_timeout: 5
|
||||
prometheus_server_version: "latest"
|
||||
|
||||
prometheus_blackbox_exporter_host: localhost
|
||||
|
||||
prometheus_redis_exporter_addr: "redis://localhost:6379"
|
||||
prometheus_redis_exporter_user: ""
|
||||
prometheus_redis_exporter_password: ""
|
||||
|
@ -60,3 +60,10 @@
|
||||
state: restarted
|
||||
enabled: yes
|
||||
tags: ['prometheus']
|
||||
|
||||
- name: 'prometheus | redis exporter | restart service'
|
||||
systemd:
|
||||
name: prometheus-redis-exporter.service
|
||||
state: restarted
|
||||
enabled: yes
|
||||
tags: ['prometheus']
|
||||
|
54
tasks/redis_exporter.yml
Normal file
54
tasks/redis_exporter.yml
Normal file
@ -0,0 +1,54 @@
|
||||
---
|
||||
- name: 'prometheus | redis exporter | get latest release from GitHub'
|
||||
shell: curl --silent "https://api.github.com/repos/oliver006/redis_exporter/releases/latest" | jq -r .tag_name | sed "s/v//"
|
||||
args:
|
||||
warn: false
|
||||
register: prometheus_redis_exporter_latest_version
|
||||
run_once: true
|
||||
|
||||
- name: 'prometheus | redis exporter | download'
|
||||
get_url:
|
||||
url: https://github.com/oliver006/redis_exporter/releases/download/v{{ prometheus_redis_exporter_version|default(prometheus_redis_exporter_latest_version.stdout) }}/redis_exporter-{{ prometheus_redis_exporter_version|default(prometheus_redis_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
|
||||
dest: /tmp
|
||||
|
||||
- name: 'prometheus | redis exporter | unarchive'
|
||||
unarchive:
|
||||
remote_src: yes
|
||||
src: /tmp/redis_exporter-{{ prometheus_redis_exporter_version|default(prometheus_redis_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
|
||||
dest: /tmp
|
||||
|
||||
- name: 'prometheus | redis exporter | move to /usr/local/bin'
|
||||
copy:
|
||||
src: /tmp/redis_exporter-{{ prometheus_redis_exporter_version|default(prometheus_redis_exporter_latest_version.stdout) }}.linux-amd64/redis_exporter
|
||||
dest: /usr/local/bin/prometheus-redis-exporter
|
||||
remote_src: yes
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
notify:
|
||||
- 'prometheus | redis exporter | restart service'
|
||||
|
||||
- name: 'prometheus | redis exporter | configuration'
|
||||
template:
|
||||
src: conf/prometheus-redis-exporter.j2
|
||||
dest: /etc/default/prometheus-redis-exporter
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0600
|
||||
register: prometheu_postgres_exporter_configuration
|
||||
notify:
|
||||
- 'prometheus | postgres exporter | restart service'
|
||||
|
||||
- name: 'prometheus | redis exporter | install unit file to systemd'
|
||||
template:
|
||||
src: systemd/prometheus-redis-exporter.service.j2
|
||||
dest: /etc/systemd/system/prometheus-redis-exporter.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0600
|
||||
|
||||
- name: 'prometheus | redis exporter | configure systemd to use service'
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
enabled: yes
|
||||
name: prometheus-redis-exporter.service
|
10
templates/conf/prometheus-redis-exporter.j2
Normal file
10
templates/conf/prometheus-redis-exporter.j2
Normal file
@ -0,0 +1,10 @@
|
||||
# {{ ansible_managed }}
|
||||
{% if (prometheus_redis_exporter_addr is defined) %}
|
||||
REDIS_ADDR={{ prometheus_redis_exporter_addr }}
|
||||
{% endif %}
|
||||
{% if (prometheus_redis_exporter_addr is defined) %}
|
||||
REDIS_USER={{ prometheus_redis_exporter_user }}
|
||||
{% endif %}
|
||||
{% if (prometheus_redis_exporter_addr is defined) %}
|
||||
REDIS_PASSWORD={{ prometheus_redis_exporter_password }}
|
||||
{% endif %}
|
@ -149,6 +149,7 @@ scrape_configs:
|
||||
{% endif %}
|
||||
|
||||
{% if prometheus_varnish_exporter_targets is defined %}
|
||||
# Varnish exporter #
|
||||
- job_name: varnish
|
||||
scrape_interval: 30s
|
||||
scrape_timeout: 10s
|
||||
@ -204,3 +205,14 @@ scrape_configs:
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if prometheus_redis_exporter_targets is defined %}
|
||||
# Redis exporter #
|
||||
- job_name: redis
|
||||
scrape_interval: 30s
|
||||
scrape_timeout: 10s
|
||||
static_configs:
|
||||
- targets:
|
||||
{% for target in prometheus_redis_exporter_targets %}
|
||||
- {{ target }}:9121
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
@ -5,6 +5,7 @@ After=network.target
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/local/bin/prometheus-redis-exporter
|
||||
EnvironmentFile=/etc/default/prometheus-redis-exporter
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
Loading…
x
Reference in New Issue
Block a user