Merge "Integrate with StackLight" into stacklight
diff --git a/nova/files/collectd_hypervisor_stats.conf b/nova/files/collectd_hypervisor_stats.conf
new file mode 100644
index 0000000..89ae226
--- /dev/null
+++ b/nova/files/collectd_hypervisor_stats.conf
@@ -0,0 +1,11 @@
+Import "hypervisor_stats"
+
+<Module "hypervisor_stats">
+  KeystoneUrl "{{ plugin.url }}"
+  Tenant "{{ plugin.project }}"
+  Username "{{ plugin.user }}"
+  Password "{{ plugin.password }}"
+  Timeout "5"
+  CpuAllocationRatio "{{ plugin.cpu_allocation_ratio }}"
+</Module>
+
diff --git a/nova/files/collectd_libvirt.conf b/nova/files/collectd_libvirt.conf
index e88266b..e8ba456 100644
--- a/nova/files/collectd_libvirt.conf
+++ b/nova/files/collectd_libvirt.conf
@@ -1,10 +1,9 @@
-LoadPlugin libvirt
+<LoadPlugin libvirt>
+  Globals false
+</LoadPlugin>
+
 <Plugin "libvirt">
   Connection "qemu:///system"
   RefreshInterval 60
-  # Domain "nova"
-  # BlockDevice "name:device"
-  # InterfaceDevice "name:interface"
-  # IgnoreSelected false
   HostnameFormat "uuid"
 </Plugin>
diff --git a/nova/files/collectd_libvirt_check.conf b/nova/files/collectd_libvirt_check.conf
new file mode 100644
index 0000000..fe878de
--- /dev/null
+++ b/nova/files/collectd_libvirt_check.conf
@@ -0,0 +1,5 @@
+Import "collectd_libvirt_check"
+
+<Module "collectd_libvirt_check">
+  Uri "qemu:///system"
+</Module>
diff --git a/nova/files/collectd_nova.conf b/nova/files/collectd_nova.conf
deleted file mode 100644
index 3548712..0000000
--- a/nova/files/collectd_nova.conf
+++ /dev/null
@@ -1,17 +0,0 @@
-<LoadPlugin "python">
-  Globals true
-</LoadPlugin>
-
-<Plugin "python">
-  ModulePath "/usr/lib/collectd-plugins/openstack"
-
-  Import "openstack_nova"
-
-  <Module "openstack_nova">
-    Username "admin"
-    Password "123456"
-    TenantName "openstack"
-    AuthURL "https://api.example.com:5000/v2.0"
-    Verbose "False"
-  </Module>
-</Plugin>
\ No newline at end of file
diff --git a/nova/files/collectd_openstack_nova.conf b/nova/files/collectd_openstack_nova.conf
new file mode 100644
index 0000000..e6a1d1b
--- /dev/null
+++ b/nova/files/collectd_openstack_nova.conf
@@ -0,0 +1,10 @@
+Import "openstack_nova"
+
+<Module "openstack_nova">
+  KeystoneUrl "{{ plugin.url }}"
+  Tenant "{{ plugin.project }}"
+  Username "{{ plugin.user }}"
+  Password "{{ plugin.password }}"
+  Timeout "20"
+  MaxRetries "2"
+</Module>
diff --git a/nova/meta/collectd.yml b/nova/meta/collectd.yml
index b258fc3..a0f7727 100644
--- a/nova/meta/collectd.yml
+++ b/nova/meta/collectd.yml
@@ -1,14 +1,28 @@
 {%- if pillar.nova.compute is defined %}
-plugin:
+local_plugin:
   nova_compute_libvirt:
-    plugin: interface
-    interval: 60
+    plugin: libvirt
     template: nova/files/collectd_libvirt.conf
+  nova_libvirt_check:
+    plugin: python
+    template: nova/files/collectd_libvirt_check.conf
 {%- endif %}
 {%- if pillar.nova.controller is defined %}
-plugin: {}
-#  nova_controller_nova:
-#    plugin: nova
-#    interval: 60
-#    template: nova/files/collectd_nova.conf
-{%- endif %}
\ No newline at end of file
+{% from "nova/map.jinja" import controller with context %}
+remote_plugin:
+  nova_resources:
+    plugin: python
+    template: nova/files/collectd_openstack_nova.conf
+    url: "http://{{ controller.identity.host }}:{{ controller.identity.port }}/v{% if controller.identity.get('api_version', 2)|int == 2 %}2.0{% else %}3{% endif %}"
+    project: {{ controller.identity.tenant }}
+    user: {{ controller.identity.user }}
+    password: {{ controller.identity.password }}
+  nova_hypervisor_stats:
+    plugin: python
+    template: nova/files/collectd_hypervisor_stats.conf
+    url: "http://{{ controller.identity.host }}:{{ controller.identity.port }}/v{% if controller.identity.get('api_version', 2)|int == 2 %}2.0{% else %}3{% endif %}"
+    project: {{ controller.identity.tenant }}
+    user: {{ controller.identity.user }}
+    password: {{ controller.identity.password }}
+    cpu_allocation_ratio: {{ controller.cpu_allocation_ratio }}
+{%- endif %}
diff --git a/nova/meta/heka.yml b/nova/meta/heka.yml
index 9e847fd..ee9e28b 100644
--- a/nova/meta/heka.yml
+++ b/nova/meta/heka.yml
@@ -1,54 +1,34 @@
-input:
-  {%- if pillar.nova.compute is defined %}
-  nova_compute:
-    engine: logstreamer
-    log_directory: /var/log/nova
-    file_match: nova-compute\.log\.?(?P<Index>\d+)?(.gz)?
-    priority: ["^Index"]
-    decoder: multidecoder_openstack
-  libvirtd:
-    engine: logstreamer
-    log_directory: /var/log/libvirt
-    file_match: libvirtd\.log\.?(?P<Index>\d+)?(.gz)?
-    priority: ['^Index']
-    decoder: multidecoder_libvirtd
-  {%- endif %}
-  {%- if pillar.nova.controller is defined %}
-  nova_compute:
-    engine: logstreamer
-    log_directory: /var/log/nova
-    file_match: nova-api\.log\.?(?P<Index>\d+)?(.gz)?
-    priority: ["^Index"]
-    decoder: multidecoder_openstack
-  {%- endif %}
-decoder:
-  openstack:
-    engine: multidecoder
-    subs: [ 'Payloadregex_OpenStackLog','Payloadregex_OpenStackLogTrace' ]
-    cascade_strategy: first-wins
-    log_sub_errors: "false"
-  OpenStackLog:
-    engine: payloadregex
-    match_regex: ^(?P<timestamp>\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}.\d{3})\s(?P<pid>\d+)\s(?P<severity>\w+)\s(?P<programname>\D+)\s\[(?P<id>.+)\]\s(?P<payload>.*)
-    timestamp_layout: "2015-10-06 11:34:37.243"
-  OpenStackLogTrace:
-    engine: payloadregex
-    match_regex: ^(?P<timestamp>\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}.\d{3})\s(?P<pid>\d+)\s(?P<severity>TRACE)\s(?P<programname>.\S+)\s(?P<payload>.*)
-    timestamp_layout: "2015-10-06 11:34:37.243"
-  openstacksandbox:
-    engine: sandbox
-    file_name: "/etc/heka/plugins.d/decoders/openstack.lua"
-    module_directory: "/etc/heka/plugins.d/common;/usr/share/heka/lua_modules"
-  libvirtd:
-    engine: multidecoder
-    subs: [ 'Payloadregex_libvirtcommon', 'Payloadregex_libvirtaudit' ]
-    cascade_strategy: first-wins
-    log_sub_errors: "false"
-  libvirtcommon:
-    engine: payloadregex
-    match_regex: ^(?P<timestamp>\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}.\d{3}\+\d{4}):\s+(?P<pid>\d+):\s+(?P<severity>\w+)\s+:\s+(?P<qemutrace>\w+:\d+)\s+:\s+(?P<payload>.*)
-    timestamp_layout: "2015-09-01 15:56:14.675+0000"
-  libvirtaudit:
-    engine: payloadregex
-    match_regex: ^(?P<timestamp>\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}.\d{3}\+\d{4}):\s+(?P<pid>\d+):\s+(?P<severity>\w+)\s+:\s+(?P<message>.+):\s(?P<payload>.+)
-    timestamp_layout: "2015-09-01 15:56:14.675+0000"
+log_collector:
+  decoder:
+    nova:
+      engine: sandbox
+      module_file: /usr/share/lma_collector/decoders/openstack_log.lua
+      module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
+    {%- if pillar.nova.compute is defined %}
+    libvirt:
+      engine: sandbox
+      module_file: /usr/share/lma_collector/decoders/libvirt_log.lua
+      module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
+    {%- endif %}
+  splitter:
+    nova:
+      engine: token
+      delimiter: '\n'
+  input:
+    nova_log:
+      engine: logstreamer
+      log_directory: "/var/log/nova"
+      file_match: '(?P<Service>.+)\.log\.?(?P<Seq>\d*)$'
+      differentiator: ['nova', '_', 'Service']
+      priority: ["^Seq"]
+      decoder: "nova_decoder"
+      splitter: "nova_splitter"
+    {%- if pillar.nova.compute is defined %}
+    libvirt_log:
+      engine: logstreamer
+      log_directory: "/var/log/libvirt"
+      file_match: 'libvirtd.log'
+      differentiator: ['libvirt']
+      decoder: "libvirt_decoder"
+      splitter: "TokenSplitter"
+    {%- endif %}