From 4e191e4e02d23dca1d5d0af125daa0784ee80243 Mon Sep 17 00:00:00 2001 From: "Ketelsen, Sven" Date: Wed, 16 Nov 2022 13:26:06 +0000 Subject: [PATCH] DEV-630 added support for elk to PaaS --- host_vars/dev-devops-iaas-01.yml | 3 +++ host_vars/prodnso-platform-iaas-01.yml | 2 ++ templates/filebeat/config/filebeat.yml.j2 | 3 +++ .../config/logstash/pipeline/filebeat.conf.j2 | 12 ++++++++++++ 4 files changed, 20 insertions(+) create mode 100644 host_vars/dev-devops-iaas-01.yml diff --git a/host_vars/dev-devops-iaas-01.yml b/host_vars/dev-devops-iaas-01.yml new file mode 100644 index 0000000..c58a2f9 --- /dev/null +++ b/host_vars/dev-devops-iaas-01.yml @@ -0,0 +1,3 @@ +--- + +pass_tenant_id: "devops" diff --git a/host_vars/prodnso-platform-iaas-01.yml b/host_vars/prodnso-platform-iaas-01.yml index 6278a49..710496a 100644 --- a/host_vars/prodnso-platform-iaas-01.yml +++ b/host_vars/prodnso-platform-iaas-01.yml @@ -1,5 +1,7 @@ --- +pass_tenant_id: "plattform" + hetzner_server_type: cpx41 default_plattform_users: diff --git a/templates/filebeat/config/filebeat.yml.j2 b/templates/filebeat/config/filebeat.yml.j2 index b3451a4..e9a0305 100644 --- a/templates/filebeat/config/filebeat.yml.j2 +++ b/templates/filebeat/config/filebeat.yml.j2 @@ -60,6 +60,9 @@ filebeat.autodiscover: fields: stage: {{ stage }} hostname: {{ inventory_hostname }} +{% if pass_tenant_id is defined | default(false) %} + pass_tenant_id: {{ pass_tenant_id }} +{% endif %} # reducing network traffic by removing unused fields # avoiding docker.container.labels with [] crashing logstash diff --git a/templates/logstash/config/logstash/pipeline/filebeat.conf.j2 b/templates/logstash/config/logstash/pipeline/filebeat.conf.j2 index 5f0c691..99a0ce7 100644 --- a/templates/logstash/config/logstash/pipeline/filebeat.conf.j2 +++ b/templates/logstash/config/logstash/pipeline/filebeat.conf.j2 @@ -201,6 +201,18 @@ output { } } } + else if [fields][pass_tenant_id] and [container][name] and [@metadata][beat] { + elasticsearch { + hosts => ["https://{{ shared_service_elastic_stack_01_hostname }}:{{ service_port_elasticsearch }}"] + cacert => "/usr/share/logstash/config/certificates/ca/ca.crt" + user => "{{ elastic_admin_username }}" + password => "{{ elastic_admin_password }}" + + index => "%{[fields][stage]}-%{[fields][pass_tenant_id]}-%{[container][name]}-%{+YYYY.MM}" + + manage_template => false + } + } else if [container][name] and [@metadata][beat] { elasticsearch { hosts => ["https://{{ shared_service_elastic_stack_01_hostname }}:{{ service_port_elasticsearch }}"]