From b649ae922f8d215ce218d070e3c0d3ad9d4a463f Mon Sep 17 00:00:00 2001
From: Bertrand Lallau <bertrand.lallau@gmail.com>
Date: Mon, 28 Aug 2017 08:44:18 +0200
Subject: [PATCH] Fluentd: fix duplicate log level naming

Fluentd config actually used two keywords to named log level:
"log_level" and "severity_label".
This doesn't allow to search and sort ALL logs in Kibana using a unique
field (ex: log_level).
This fix standardize log level keyword naming.

Closes-Bug: #1713410
Change-Id: Ibb2eaf3b6aa21ce6f7945e768e6362c0d40f0507
---
 .../roles/common/templates/conf/format/apache_access.conf.j2    | 2 +-
 ansible/roles/common/templates/conf/format/wsgi_python.conf.j2  | 2 +-
 ansible/roles/common/templates/conf/input/02-mariadb.conf.j2    | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/ansible/roles/common/templates/conf/format/apache_access.conf.j2 b/ansible/roles/common/templates/conf/format/apache_access.conf.j2
index 9a7276955e..f47b6cdf62 100644
--- a/ansible/roles/common/templates/conf/format/apache_access.conf.j2
+++ b/ansible/roles/common/templates/conf/format/apache_access.conf.j2
@@ -12,7 +12,7 @@
 <filter apache_access>
    @type record_transformer
    <record>
-     severity_label INFO
+     log_level INFO
      Severity 6
    </record>
 </filter>
diff --git a/ansible/roles/common/templates/conf/format/wsgi_python.conf.j2 b/ansible/roles/common/templates/conf/format/wsgi_python.conf.j2
index 46995bf3d3..d266f64cea 100644
--- a/ansible/roles/common/templates/conf/format/wsgi_python.conf.j2
+++ b/ansible/roles/common/templates/conf/format/wsgi_python.conf.j2
@@ -3,7 +3,7 @@
   reserve_data true
   format grok
   key_name message
-  grok_pattern %{TIMESTAMP_ISO8601:Timestamp} %{NUMBER:Pid} %{LOGLEVEL:severity_label} %{NOTSPACE:python_module} \[(?:req-(?:%{NOTSPACE:request_id}) (?:%{NOTSPACE:user_id}) (?:%{NOTSPACE:tenant_id}) (?:%{NOTSPACE:domain_id}) (?:%{NOTSPACE:user_domain}) (?:%{NOTSPACE:project_domain})|-)\] %{GREEDYDATA:Payload}
+  grok_pattern %{TIMESTAMP_ISO8601:Timestamp} %{NUMBER:Pid} %{LOGLEVEL:log_level} %{NOTSPACE:python_module} \[(?:req-(?:%{NOTSPACE:request_id}) (?:%{NOTSPACE:user_id}) (?:%{NOTSPACE:tenant_id}) (?:%{NOTSPACE:domain_id}) (?:%{NOTSPACE:user_domain}) (?:%{NOTSPACE:project_domain})|-)\] %{GREEDYDATA:Payload}
   time_format "%Y-%m-%d %H:%M:%S.%L"
   time_key Timestamp
   keep_time_key true
diff --git a/ansible/roles/common/templates/conf/input/02-mariadb.conf.j2 b/ansible/roles/common/templates/conf/input/02-mariadb.conf.j2
index b435cb1a48..c1ddd196ef 100644
--- a/ansible/roles/common/templates/conf/input/02-mariadb.conf.j2
+++ b/ansible/roles/common/templates/conf/input/02-mariadb.conf.j2
@@ -6,6 +6,6 @@
   tag infra.mariadb
   format multiline
   format_firstline /^\d{6}/
-  format1 /^(?<time>\d{6} \d{1,2}:\d{1,2}:\d{1,2}) \[(?<severity_label>\S+)\] (?<Payload>.*)/
+  format1 /^(?<time>\d{6} \d{1,2}:\d{1,2}:\d{1,2}) \[(?<log_level>\S+)\] (?<Payload>.*)/
   time_format %y%m%d %k:%M:%S
 </source>