From 301970a5d2f07440ec54efb9b0cae21572aff140 Mon Sep 17 00:00:00 2001
From: Arne Oslebo <arne.oslebo@uninett.no>
Date: Fri, 13 Nov 2020 09:53:23 +0100
Subject: [PATCH] added logging from haproxy

---
 roles/filebeat/templates/filebeat.yml.j2 | 6 ++++++
 roles/haproxy/templates/haproxy.cfg.j2   | 2 +-
 soctools-inventory                       | 2 +-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/roles/filebeat/templates/filebeat.yml.j2 b/roles/filebeat/templates/filebeat.yml.j2
index 3abc622..3335c48 100644
--- a/roles/filebeat/templates/filebeat.yml.j2
+++ b/roles/filebeat/templates/filebeat.yml.j2
@@ -1,9 +1,15 @@
 filebeat.inputs:
+{% if FILEBEAT_FILES is defined %}
 - type: log
   paths:
 {% for file in FILEBEAT_FILES %}
       - {{ file }}
 {% endfor %}
+{% else %}
+- type: syslog
+  protocol.udp:
+    host: "localhost:{{ FILEBEAT_SYSLOG_PORT }}"
+{% endif %}
   fields:
     log_type: {{ FILEBEAT_LOG_TYPE }}
 
diff --git a/roles/haproxy/templates/haproxy.cfg.j2 b/roles/haproxy/templates/haproxy.cfg.j2
index ad77710..7290147 100644
--- a/roles/haproxy/templates/haproxy.cfg.j2
+++ b/roles/haproxy/templates/haproxy.cfg.j2
@@ -1,6 +1,6 @@
 global
   #quiet
-  log stdout format raw local0
+  log 127.0.0.1:9000  local0
   nbproc {{ HAPROXY_PROCESSES }}
   ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
   ssl-default-bind-options prefer-client-ciphers no-sslv3 no-tlsv10 no-tlsv11 no-tls-tickets
diff --git a/soctools-inventory b/soctools-inventory
index 1ad3a1c..7a4e4f9 100644
--- a/soctools-inventory
+++ b/soctools-inventory
@@ -35,5 +35,5 @@ dsoclab-nifi-3 ansible_connection=docker FILEBEAT_FILES='["/opt/nifi/nifi-curren
 #dsoclab-keycloak ansible_connection=docker FILEBEAT_FILES='[""]'
 #dsoclab-mysql ansible_connection=docker FILEBEAT_FILES='[""]'
 #dsoclab-misp ansible_connection=docker FILEBEAT_FILES='[""]'
-#dsoclab-haproxy ansible_connection=docker FILEBEAT_FILES='[""]'
+dsoclab-haproxy ansible_connection=docker FILEBEAT_SYSLOG_PORT=9000 FILEBEAT_LOG_TYPE="haproxy"
 #dsoclab-zookeeper ansible_connection=docker FILEBEAT_FILES='[""]'
-- 
GitLab