Added seed code for caas-logging.
[ta/caas-logging.git] / ansible / roles / fluentd / templates / fluentd-cm.yaml
diff --git a/ansible/roles/fluentd/templates/fluentd-cm.yaml b/ansible/roles/fluentd/templates/fluentd-cm.yaml
new file mode 100644 (file)
index 0000000..fb58c0d
--- /dev/null
@@ -0,0 +1,64 @@
+{#
+Copyright 2019 Nokia
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+#}
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: fluentd-cm
+  namespace: kube-system
+data:
+  #Take care that the files will be processed by fluentd in alphabetical order
+  01-fluentd_kubernetes.conf: |-
+
+    # Look for files of type *kube-system* and add tag kubernetes
+    <source>
+      @type tail
+      path /var/log/containers/*kube-system*.log
+      pos_file /fluentd/log/fluentd-kubernetes.log.pos
+      time_format %Y-%m-%dT%H:%M:%S.%NZ
+      tag kubernetes.*
+      format json
+      read_from_head true
+    </source>
+    # Add kubernetes metadata to "kubernetes" tagged messages
+    <filter kubernetes.**>
+      @type kubernetes_metadata
+    </filter>
+
+  02-fluentd_elasticsearch.conf: |-
+
+    # Forward all messages with either kubenetes tag to elasticsearch
+    <match kubernetes**>
+       @type elasticsearch
+       @log_level info
+       include_tag_key true
+       host "{{ caas.elasticsearch_url }}"
+       port "{{ caas.elasticsearch_port }}"
+       scheme "{{ elasticsearch_sheme | default('http') }}"
+       user "{{ elasticsearch_user | default('elastic') }}"
+       password "{{ elasticsearch_passwd | default('changeme') }}"
+       ssl_verify  "{{ elasticsearch_ssl | default('true') }}"
+       reload_connections "{{ elasticsearch_reload_connections | default('true') }}"
+       logstash_prefix "{{ elasticsearch_logstash_prefix | default('logstash') }}"
+       logstash_format true
+       reconnect_on_error true
+       resurrect_after 5s
+       <buffer tag>
+          chunk_limit_size 256m
+          flush_at_shutdown "true"
+          flush_interval 5s
+      </buffer>
+    </match>