From 3c9a650933e446418dc2238cee8ab67f7ed13e72 Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Tue, 26 Nov 2019 16:30:23 +0100
Subject: [PATCH] ansible-playbooks/general#92 Add support for beats

---
 tasks/fluentd-client.yml |  1 +
 templates/td-agent.conf  | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/tasks/fluentd-client.yml b/tasks/fluentd-client.yml
index 6d5f41b..0b3f514 100644
--- a/tasks/fluentd-client.yml
+++ b/tasks/fluentd-client.yml
@@ -42,6 +42,7 @@
     - fluent-plugin-multi-format-parser
     - fluent-plugin-record-modifier
     - fluent-plugin-mail
+    - fluent-plugin-beats
 
 - name: Ensure SSL Directory
   file:
diff --git a/templates/td-agent.conf b/templates/td-agent.conf
index de77bb6..252a33a 100644
--- a/templates/td-agent.conf
+++ b/templates/td-agent.conf
@@ -2,6 +2,11 @@
   @type forward
   port 24224
 </source>
+
+<source>
+  @type beats
+  metadata_as_tag
+</source>
 {% if 'proxyserver' in groups and inventory_hostname in groups.proxyserver %}
 
 <source>
@@ -332,6 +337,27 @@
   request_timeout 15s
 </match>
 
+<match *beat>
+  @type elasticsearch_dynamic
+  logstash_format true
+  logstash_prefix ${tag_parts[0]}
+  type_name ${record['type']}
+  host 127.0.0.1
+  port 9200
+  user elastic
+  password {{ elasticsearch.users.elastic|default("") }}
+  include_tag_key true
+  tag_key @log_name
+  reconnect_on_error true
+  <buffer>
+    @type file
+    path /var/log/td-agent/buffer/beats.*.buffer
+    flush_at_shutdown true
+    flush_thread_count 8
+  </buffer>
+  request_timeout 15s
+</match>
+
 <match **>
   @type elasticsearch
   logstash_format true
-- 
GitLab