Article original Publié le : 05 juillet 2022 Mise à jour le : – |
Le bout de conf procstat pour le template telegraf.conf.j2 mis en place en fonction du système ou du service custom historique
Redis
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
{% if 'redis' in group_names %} [[inputs.redis]] servers = ["{{ redis_local_config | default ('tcp://localhost:6379') }}"] [[inputs.procstat]] {% if ansible_distribution == "Debian" %} systemd_unit = "redis-server.service" {% elif ansible_distribution == "RedHat" %} systemd_unit = "redis.service" {% elif ansible_distribution == "Gentoo" %} pattern = "redis-server" {% endif %} [inputs.procstat.tags] process_title="redis" {% endif %} |
Apache
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
{% if 'apache2' in group_names or 'apache2-sysv' in group_names or 'httpd' in group_names %} [[inputs.apache]] urls = ["{{ apache_local_config | default ('http://localhost/server-status?auto') }}"] [[inputs.procstat]] {% if 'apache2' in group_names %} systemd_unit = "apache2.service" {% elif 'apache2-sysv' in group_names %} pid_file = "/var/run/apache2/apache2.pid" {% elif 'httpd' in group_names %} systemd_unit = "httpd.service" {% endif %} [inputs.procstat.tags] process_title="apache" {% endif %} |
Rajouter le bout de code pour l’alert.rules.j2 de Prometheus, pour déclencher les alertes
Redis
1 2 3 4 5 6 7 8 9 10 |
- alert: Redis expr: procstat_lookup_running { process_title="redis" } == 0 for: 5m labels: resourceName: "Redis" severity: critical service: "system" instanceName: "{{ $labels.host }}" annotations: summary: "Alerte redis sur {{ $labels.host }}" |
Apache
1 2 3 4 5 6 7 8 9 10 |
- alert: Apache expr: procstat_lookup_running { process_title="apache" } == 0 for: 5m labels: resourceName: "Apache" severity: critical service: "system" instanceName: "{{ $labels.host }}" annotations: summary: "Alerte apache sur {{ $labels.host }}." |