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:
parent
d256ab054a
commit
5717989110
@ -32,7 +32,7 @@ class Meter(object):
|
|||||||
def meter_name(self, vl):
|
def meter_name(self, vl):
|
||||||
"""Return meter name."""
|
"""Return meter name."""
|
||||||
# pylint: disable=no-self-use
|
# 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])
|
return '.'.join([i for i in resources if i])
|
||||||
|
|
||||||
def hostname(self, vl):
|
def hostname(self, vl):
|
||||||
@ -42,7 +42,7 @@ class Meter(object):
|
|||||||
|
|
||||||
def resource_id(self, vl):
|
def resource_id(self, vl):
|
||||||
"""Get resource ID."""
|
"""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])
|
return '-'.join([i for i in resources if i])
|
||||||
|
|
||||||
def unit(self, vl):
|
def unit(self, vl):
|
||||||
|
@ -57,7 +57,9 @@ class Writer(object):
|
|||||||
# take the plugin (specialized or default) for parsing the data
|
# take the plugin (specialized or default) for parsing the data
|
||||||
plugin = self._meters.get(vl.plugin)
|
plugin = self._meters.get(vl.plugin)
|
||||||
# prepare all data related to the sample
|
# 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)
|
unit = plugin.unit(vl)
|
||||||
timestamp = datetime.datetime.utcfromtimestamp(vl.time).isoformat()
|
timestamp = datetime.datetime.utcfromtimestamp(vl.time).isoformat()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user