Add Promehteus Exporter
This commit is contained in:
parent
146716ad9c
commit
872179cbcd
6 changed files with 53 additions and 9 deletions
12
README.md
12
README.md
|
@ -10,15 +10,6 @@ lassen sich daraus Services für verschiedene Anwendungen erstellen.
|
||||||
Für die PHP-Konfiguration sind verschiedene defaults gesetzt. Über die jeweilige `host_vars` lassen sich im Dictionary `php`
|
Für die PHP-Konfiguration sind verschiedene defaults gesetzt. Über die jeweilige `host_vars` lassen sich im Dictionary `php`
|
||||||
die defaults überschreiben.
|
die defaults überschreiben.
|
||||||
|
|
||||||
| Varible | Wert |
|
|
||||||
|--|--|
|
|
||||||
| date_timezone | string |
|
|
||||||
| default_charset | string |
|
|
||||||
| max_execution_time | int |
|
|
||||||
| memory_limit | string |
|
|
||||||
| post_max_size | string |
|
|
||||||
| upload_max_filesize | string |
|
|
||||||
|
|
||||||
Beispiel:
|
Beispiel:
|
||||||
```YAML
|
```YAML
|
||||||
php:
|
php:
|
||||||
|
@ -26,6 +17,9 @@ php:
|
||||||
post_max_size: 30M
|
post_max_size: 30M
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Durch setzen der Variable `phpfpm_exporter: true` wird ein [Prometheus Exporter](https://github.com/Lusitaniae/phpfpm_exporter)
|
||||||
|
installiert. Das zugehörife [Grafana Dashboard](https://grafana.com/grafana/dashboards/5714-php-fpm-multi-pool/) trägt die ID `5714`.
|
||||||
|
|
||||||
## Nutzerkonto und PHP-FPM-Service anlegen
|
## Nutzerkonto und PHP-FPM-Service anlegen
|
||||||
|
|
||||||
Per Ansible Tag kann ein Systemkonto und ein PHP-FPM-Socket und Service angelegt werden. Am Beispiel des playbooks `php.yml`:
|
Per Ansible Tag kann ein Systemkonto und ein PHP-FPM-Socket und Service angelegt werden. Am Beispiel des playbooks `php.yml`:
|
||||||
|
|
|
@ -18,3 +18,7 @@ php_fpm_config:
|
||||||
assert.active: "Off"
|
assert.active: "Off"
|
||||||
mail.add_x_header: "Off"
|
mail.add_x_header: "Off"
|
||||||
session.use_strict_mode: 1
|
session.use_strict_mode: 1
|
||||||
|
|
||||||
|
phpfpm_exporter_github_api_url: https://api.github.com/repos/Lusitaniae/phpfpm_exporter/releases/latest
|
||||||
|
phpfpm_exporter_socket_directories: /run/php/
|
||||||
|
phpfpm_exporter_listen_address: ":9253"
|
||||||
|
|
|
@ -21,3 +21,10 @@
|
||||||
- name: Reload systemd
|
- name: Reload systemd
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
|
||||||
|
- name: Start phpfpm_exporter
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: phpfpm_exporter
|
||||||
|
daemon_reload: true
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
|
|
@ -18,3 +18,8 @@
|
||||||
- name: User tasks
|
- name: User tasks
|
||||||
ansible.builtin.import_tasks: user.yml
|
ansible.builtin.import_tasks: user.yml
|
||||||
tags: never, user
|
tags: never, user
|
||||||
|
|
||||||
|
- name: Prometheus exporter
|
||||||
|
ansible.builtin.import_tasks: prometheus.yml
|
||||||
|
tags: exporter
|
||||||
|
when: phpfpm_exporter is defined and phpfpm_exporter
|
||||||
|
|
21
tasks/prometheus.yml
Normal file
21
tasks/prometheus.yml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
---
|
||||||
|
- name: "Prometheus | Get Download URL"
|
||||||
|
ansible.builtin.shell:
|
||||||
|
cmd: curl -sL "{{ phpfpm_exporter_github_api_url }}" | jq -r '.assets[].browser_download_url' | grep -E linux-amd64.tar.gz
|
||||||
|
register: exporter_download_url
|
||||||
|
|
||||||
|
- name: "Prometheus | Download binary"
|
||||||
|
ansible.builtin.unarchive:
|
||||||
|
src: "{{ exporter_download_url.stdout }}"
|
||||||
|
dest: /usr/local/bin
|
||||||
|
remote_src: true
|
||||||
|
exclude:
|
||||||
|
- LICENSE
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
- name: "Prometheus | Copy systemd service file"
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: systemd/phpfpm_exporter.service.j2
|
||||||
|
dest: /etc/systemd/system/phpfpm_exporter.service
|
||||||
|
mode: "0644"
|
||||||
|
notify: Start phpfpm_exporter
|
13
templates/systemd/phpfpm_exporter.service.j2
Normal file
13
templates/systemd/phpfpm_exporter.service.j2
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# Ansible managed
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description = PHP-FPM Prometheus Exporter
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
SyslogIdentifier = phpfpm_exporter
|
||||||
|
|
||||||
|
ExecStart =/usr/local/bin/phpfpm_exporter --phpfpm.socket-directories={{ phpfpm_exporter_socket_directories }} --web.listen-address="{{ phpfpm_exporter_listen_address }}"
|
||||||
|
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy = multi-user.target
|
Loading…
Reference in a new issue