Modifies metername and resource_id

* Changes metername value:
   <plugin>.<type> -> <type>.<type_instance>
   e.g. cpu.cpu -> cpu.nice
* Changes resource_id value
   <hostname>-<plugin_instance>-<type_instance> ->
   <hostname>-<plugin>-<plugin_instance>
   e.g. localhost-0-nice -> localhost-cpu-0
* Changes metername in gnocchi/writer
    metername -> <resource_id>@<metername>

* Supports multi-host deployment

Change-Id: If4cbff1c624ceb1e46b86bf999559b159ee78a04
This commit is contained in:
Emma Foley 2017-07-17 16:45:14 +00:00
parent d256ab054a
commit 5717989110
2 changed files with 5 additions and 3 deletions

View File

@ -32,7 +32,7 @@ class Meter(object):
def meter_name(self, vl):
"""Return meter name."""
# pylint: disable=no-self-use
resources = [vl.plugin, vl.type]
resources = [vl.type, vl.type_instance]
return '.'.join([i for i in resources if i])
def hostname(self, vl):
@ -42,7 +42,7 @@ class Meter(object):
def resource_id(self, vl):
"""Get resource ID."""
resources = [self.hostname(vl), vl.plugin_instance, vl.type_instance]
resources = [self.hostname(vl), vl.plugin, vl.plugin_instance]
return '-'.join([i for i in resources if i])
def unit(self, vl):

View File

@ -57,7 +57,9 @@ class Writer(object):
# take the plugin (specialized or default) for parsing the data
plugin = self._meters.get(vl.plugin)
# prepare all data related to the sample
metername = plugin.meter_name(vl)
metername = "{}@{}".format(
plugin.resource_id(vl), plugin.meter_name(vl))
unit = plugin.unit(vl)
timestamp = datetime.datetime.utcfromtimestamp(vl.time).isoformat()