From 3dde7049ce848be6cbc9deb3542dd7a88491122e Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Tue, 5 Jun 2018 12:46:03 +0000 Subject: [PATCH] Optionally collect uwsgi stats from unix domain sockets Change-Id: I78561fe3cf3c90c7aa25f39c74c30702c1da5d52 --- elk_metrics_6x/installMetricbeat.yml | 8 ++++++++ elk_metrics_6x/templates/metricbeat.yml.j2 | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/elk_metrics_6x/installMetricbeat.yml b/elk_metrics_6x/installMetricbeat.yml index defc8454..38579752 100644 --- a/elk_metrics_6x/installMetricbeat.yml +++ b/elk_metrics_6x/installMetricbeat.yml @@ -77,6 +77,13 @@ path: /etc/uwsgi register: uwsgi + - name: Check for uwsgi stats sockets + find: + paths: /tmp + file_type: any + patterns: '*uwsgi-stats.sock' + register: uwsgi_find_sockets + - name: Set discovery facts set_fact: apache_enabled: "{{ (apache2.stat.exists | bool) or (httpd.stat.exists | bool) }}" @@ -88,6 +95,7 @@ nginx_enabled: "{{ nginx.stat.exists | bool }}" rabbitmq_enabled: "{{ rabbitmq.stat.exists | bool }}" uwsgi_enabled: "{{ uwsgi.stat.exists | bool }}" + uwsgi_sockets: "{{ uwsgi_find_sockets }}" # Apache 2 stats enablement - name: Drop apache2 stats site config diff --git a/elk_metrics_6x/templates/metricbeat.yml.j2 b/elk_metrics_6x/templates/metricbeat.yml.j2 index 6257d4b0..2055fe16 100644 --- a/elk_metrics_6x/templates/metricbeat.yml.j2 +++ b/elk_metrics_6x/templates/metricbeat.yml.j2 @@ -465,7 +465,11 @@ metricbeat.modules: - module: uwsgi metricsets: ["status"] period: 30s +{% if uwsgi_sockets.matched | int > 0 %} + hosts: [{% for file in uwsgi_sockets.files %}"unix://{{ file.path }}"{% if not loop.last %},{% endif %}{% endfor %}] +{% else %} hosts: ["tcp://127.0.0.1:9191"] +{% endif %} # {% endif %} ##------------------------------- vSphere Module ------------------------------