diff --git a/ceilometer/compute/libvirt.py b/ceilometer/compute/libvirt.py index c23a9f26..4d940b29 100644 --- a/ceilometer/compute/libvirt.py +++ b/ceilometer/compute/libvirt.py @@ -120,7 +120,7 @@ class CPUPollster(plugin.PollsterBase): ) yield make_counter_from_instance(instance, name='instance', - type='delta', + type='cumulative', volume=1, ) except Exception as err: diff --git a/ceilometer/compute/network.py b/ceilometer/compute/network.py index 1818bbf5..a59b8b8b 100644 --- a/ceilometer/compute/network.py +++ b/ceilometer/compute/network.py @@ -39,7 +39,7 @@ class FloatingIPPollster(plugin.PollsterBase): yield counter.Counter( source='?', name='floating_ip', - type='delta', + type='cumulative', volume=1, user_id=None, project_id=ip.project_id, diff --git a/ceilometer/compute/notifications.py b/ceilometer/compute/notifications.py index 7cebca1b..6afb8b0a 100644 --- a/ceilometer/compute/notifications.py +++ b/ceilometer/compute/notifications.py @@ -39,7 +39,7 @@ class InstanceNotifications(plugin.NotificationBase): return [counter.Counter( source='?', name='instance', - type='delta', + type='cumulative', volume=1, user_id=message['payload']['user_id'], project_id=message['payload']['tenant_id'], diff --git a/ceilometer/counter.py b/ceilometer/counter.py index c8e736f0..26fe6fba 100644 --- a/ceilometer/counter.py +++ b/ceilometer/counter.py @@ -24,7 +24,22 @@ in by the plugins that create them. import collections - +# Fields explanation: +# +# Source: +# Name: the name of the counter, must be unique +# Type: the type of the counter, must be either: +# - cumulative: the value is incremented and never reset to 0 +# - delta: the value is reset to 0 each time it is sent +# - absolute: the value is an absolute value and is not a counter +# Volume: the counter value +# User ID: the user ID +# Project ID: the project ID +# Resource ID: the resource ID +# Timestamp: when the counter has been read +# Duration: duration in seconds determining how long the value is valid. +# adding this to timestamp give the end time of the counter +# Resource metadata: various metadata Counter = collections.namedtuple('Counter', ' '.join(['source', 'name', diff --git a/doc/source/contributing/plugins.rst b/doc/source/contributing/plugins.rst index edf54b6f..238353a8 100644 --- a/doc/source/contributing/plugins.rst +++ b/doc/source/contributing/plugins.rst @@ -64,7 +64,7 @@ from libvirt and send back two ``Counter`` objects. The first one, named "cpu", is of type "cumulative", meaning that between two polls, its value is not reset, or in other word that the cpu value is always provided as a duration that continuously increases since the creation of the instance. The second one, -named "instance", is of type "delta", meaning that it's value is just the +named "instance", is of type "cumulative", meaning that it's value is just the volume since the last poll. Here, the instance counter is only used as a way to tell the system that the instance is still running, hence the hard coded value of 1. diff --git a/tests/compute/test_notifications.py b/tests/compute/test_notifications.py index e03425b3..c9c958f1 100644 --- a/tests/compute/test_notifications.py +++ b/tests/compute/test_notifications.py @@ -172,7 +172,7 @@ def test_process_notification(): for name, actual, expected in [ ('counter_name', info.name, 'instance'), - ('counter_type', info.type, 'delta'), + ('counter_type', info.type, 'cumulative'), ('counter_volume', info.volume, 1), ('timestamp', info.timestamp, INSTANCE_CREATE_END['timestamp']),