Add fluentd configuration

Fixes: PROD-35778
Change-Id: Id5652d1b8fc875daddc82c93352e768e9846534d
diff --git a/metadata/service/support.yml b/metadata/service/support.yml
index 9d6df6a..8ce2711 100644
--- a/metadata/service/support.yml
+++ b/metadata/service/support.yml
@@ -9,6 +9,8 @@
         enabled: false
       sphinx:
         enabled: false
+      fluentd:
+        enabled: true
       grafana:
         enabled: true
       prometheus:
diff --git a/octavia/meta/fluentd.yml b/octavia/meta/fluentd.yml
new file mode 100644
index 0000000..3fd5486
--- /dev/null
+++ b/octavia/meta/fluentd.yml
@@ -0,0 +1,65 @@
+{%- if pillar.get('fluentd', {}).get('agent', {}).get('enabled', False) %}
+{%- set positiondb = pillar.fluentd.agent.dir.positiondb %}
+agent:
+  config:
+    label:
+      openstack_octavia:
+        input:
+          octavia_in_tail:
+            type: tail
+            path: /var/log/octavia/*.log
+            path_key: log_path
+            tag: openstack.octavia
+            pos_file: {{ positiondb }}/octavia.pos
+            parser:
+              type: regexp
+              time_key: Timestamp
+              time_format: '%Y-%m-%d %H:%M:%S.%N'
+              keep_time_key: false
+              # Apache format: https://regex101.com/r/W1MTtn/1/
+              format: '/^(?<Timestamp>.*)\s\d+\s(?<severity_label>\w+)\s(?<module>[\w|\.]+)\s(?<Payload>.*)$/'
+        filter:
+          add_octavia_record_fields:
+            tag: openstack.octavia
+            type: record_transformer
+            enable_ruby: true
+            record:
+              - name: Severity
+                value: '${ { 8=>"TRACE",7=>"DEBUG",6=>"INFO",5=>"NOTICE",4=>"WARNING",3=>"ERROR",2=>"CRITICAL",1=>"ALERT",0=>"EMERGENCY" }.key(record["severity_label"]) }'
+              - name: programname
+                value: 'octavia-${ record["log_path"].split("/")[-1].chomp(".log") }'
+        match:
+          send_to_default:
+            tag: openstack.octavia
+            type: copy
+            store:
+              - type: relabel
+                label: default_output
+              - type: rewrite_tag_filter
+                rule:
+                  - name: severity_label
+                    regexp: '.'
+                    result: metric.octavia_log_messages
+          push_to_metric:
+            tag: 'metric.**'
+            type: relabel
+            label: default_metric
+      default_metric:
+        filter:
+          octavia_logs_per_severity:
+            tag: metric.octavia_log_messages
+            require:
+              - add_general_fields
+            type: prometheus
+            metric:
+              - name: log_messages
+                type: counter
+                desc: Total number of log lines by severity
+            label:
+              - name: service
+                value: ${programname}
+              - name: level
+                value: ${severity_label}
+              - name: host
+                value: ${Hostname}
+{%- endif %}