Merge "Add service class for gnocchi client"
diff --git a/README.rst b/README.rst
index 0edefad..4d06135 100644
--- a/README.rst
+++ b/README.rst
@@ -262,6 +262,33 @@
                   test_policy_rule2:
                     metric_pattern: 'foo2.*'
 
+=======
+Gnocchi logging configuration
+----------------------------------
+
+For enable fluend logging use
+
+.. code-block:: yaml
+
+  gnocchi:
+    _support:
+      fluentd:
+        enabled: true
+
+.. note:: Gnocchi doesnt support oslo.log options. So we cant use
+   log_appender and log_handlers options
+
+For change log_level or other log options
+
+.. code-block:: yaml
+
+  gnocchi:
+    common:
+      debug: true
+      use_syslog: true
+      use_journal: true
+      log_dir: /var/log/gnocchi
+      log_file: gnocchi.log
 
 
 More Information
diff --git a/gnocchi/meta/fluentd.yml b/gnocchi/meta/fluentd.yml
new file mode 100644
index 0000000..39aea37
--- /dev/null
+++ b/gnocchi/meta/fluentd.yml
@@ -0,0 +1,47 @@
+{%- if pillar.get('fluentd', {}).get('agent', {}).get('enabled', False) %}
+agent:
+  config:
+    label:
+      gnocchi:
+        input:
+          tail_gnocchi_metricd:
+            type: tail
+            tag: gnocchi.metricd
+            path: /var/log/gnocchi/gnocchi-metricd.log
+            pos_file: {{ pillar.fluentd.agent.dir.positiondb }}/gnocchi.pos
+            parser:
+              type: regexp
+              time_key: time
+              time_format: '%FT%H:%M:%S.%L%z'
+              keep_time_key: false
+              format: '/^(?<time>.*)\s\[(?<pid>[0-9]+)\]\s(?<severity_label>[A-Z]+)\s+(?<Payload>.*)$/'
+          tail_gnocchi_statsd:
+            type: tail
+            tag: gnocchi.statsd
+            path: /var/log/gnocchi/gnocchi-statsd.log
+            pos_file: {{ pillar.fluentd.agent.dir.positiondb }}/gnocchi.pos
+            parser:
+              type: regexp
+              time_key: time
+              time_format: '%FT%H:%M:%S.%L%z'
+              keep_time_key: false
+              format: '/^(?<time>.*)\s\[(?<pid>[0-9]+)\]\s(?<severity_label>[A-Z]+)\s+(?<Payload>.*)$/'
+        filter:
+          match_severity:
+            type: record_transformer
+            tag: gnocchi.**
+            enable_ruby: true
+            remove_keys: priority
+            record:
+              - name: programname
+                value: gnocchi
+              - name: Severity
+                value: "${ record['priority'].to_i % 8 }"
+              - name: severity_label
+                value: "${ {'DEBUG'=>7,'INFO'=>6,'NOTICE'=>5,'WARNING'=>4,'ERROR'=>3,'CRITICAL'=>2,'ALERT'=>1}.key(record['priority'].to_i % 8) }"
+        match:
+          push_to_default:
+            tag: gnocchi.**
+            type: relabel
+            label: default_output
+{%- endif %}
\ No newline at end of file
diff --git a/metadata/service/server/cluster.yml b/metadata/service/server/cluster.yml
index 43ec445..a1a058d 100644
--- a/metadata/service/server/cluster.yml
+++ b/metadata/service/server/cluster.yml
@@ -20,4 +20,4 @@
         user: gnocchi
         password: ${_param:keystone_gnocchi_password}
         tenant: service
-        auth_type: password
\ No newline at end of file
+        auth_type: password
diff --git a/metadata/service/server/single.yml b/metadata/service/server/single.yml
index cc48bbb..fb7da38 100644
--- a/metadata/service/server/single.yml
+++ b/metadata/service/server/single.yml
@@ -21,4 +21,4 @@
         user: gnocchi
         password: ${_param:keystone_gnocchi_password}
         tenant: service
-        auth_type: password
\ No newline at end of file
+        auth_type: password
diff --git a/metadata/service/support.yml b/metadata/service/support.yml
index 002c442..9fb25fa 100644
--- a/metadata/service/support.yml
+++ b/metadata/service/support.yml
@@ -9,3 +9,5 @@
         enabled: false
       sphinx:
         enabled: true
+      fluentd:
+        enabled: true