mirror of
https://github.com/ansible/awx.git
synced 2026-02-19 12:10:06 -03:30
Merge pull request #5438 from jainnikhil30/devel
adding instance consumed and remaining capacity to metrics Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -166,6 +166,8 @@ def instance_info(since, include_hostnames=False):
|
|||||||
instances = models.Instance.objects.values_list('hostname').values(
|
instances = models.Instance.objects.values_list('hostname').values(
|
||||||
'uuid', 'version', 'capacity', 'cpu', 'memory', 'managed_by_policy', 'hostname', 'last_isolated_check', 'enabled')
|
'uuid', 'version', 'capacity', 'cpu', 'memory', 'managed_by_policy', 'hostname', 'last_isolated_check', 'enabled')
|
||||||
for instance in instances:
|
for instance in instances:
|
||||||
|
consumed_capacity = sum(x.task_impact for x in models.UnifiedJob.objects.filter(execution_node=instance['hostname'],
|
||||||
|
status__in=('running', 'waiting')))
|
||||||
instance_info = {
|
instance_info = {
|
||||||
'uuid': instance['uuid'],
|
'uuid': instance['uuid'],
|
||||||
'version': instance['version'],
|
'version': instance['version'],
|
||||||
@@ -174,7 +176,9 @@ def instance_info(since, include_hostnames=False):
|
|||||||
'memory': instance['memory'],
|
'memory': instance['memory'],
|
||||||
'managed_by_policy': instance['managed_by_policy'],
|
'managed_by_policy': instance['managed_by_policy'],
|
||||||
'last_isolated_check': _get_isolated_datetime(instance['last_isolated_check']),
|
'last_isolated_check': _get_isolated_datetime(instance['last_isolated_check']),
|
||||||
'enabled': instance['enabled']
|
'enabled': instance['enabled'],
|
||||||
|
'consumed_capacity': consumed_capacity,
|
||||||
|
'remaining_capacity': instance['capacity'] - consumed_capacity
|
||||||
}
|
}
|
||||||
if include_hostnames is True:
|
if include_hostnames is True:
|
||||||
instance_info['hostname'] = instance['hostname']
|
instance_info['hostname'] = instance['hostname']
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ INSTANCE_MEMORY = Gauge('awx_instance_memory', 'RAM (Kb) on each node in a Tower
|
|||||||
INSTANCE_INFO = Info('awx_instance', 'Info about each node in a Tower system', ['hostname', 'instance_uuid',])
|
INSTANCE_INFO = Info('awx_instance', 'Info about each node in a Tower system', ['hostname', 'instance_uuid',])
|
||||||
INSTANCE_LAUNCH_TYPE = Gauge('awx_instance_launch_type_total', 'Type of Job launched', ['node', 'launch_type',])
|
INSTANCE_LAUNCH_TYPE = Gauge('awx_instance_launch_type_total', 'Type of Job launched', ['node', 'launch_type',])
|
||||||
INSTANCE_STATUS = Gauge('awx_instance_status_total', 'Status of Job launched', ['node', 'status',])
|
INSTANCE_STATUS = Gauge('awx_instance_status_total', 'Status of Job launched', ['node', 'status',])
|
||||||
|
INSTANCE_CONSUMED_CAPACITY = Gauge('awx_instance_consumed_capacity', 'Consumed capacity of each node in a Tower system', ['hostname', 'instance_uuid',])
|
||||||
|
INSTANCE_REMAINING_CAPACITY = Gauge('awx_instance_remaining_capacity', 'Remaining capacity of each node in a Tower system', ['hostname', 'instance_uuid',])
|
||||||
|
|
||||||
LICENSE_INSTANCE_TOTAL = Gauge('awx_license_instance_total', 'Total number of managed hosts provided by your license')
|
LICENSE_INSTANCE_TOTAL = Gauge('awx_license_instance_total', 'Total number of managed hosts provided by your license')
|
||||||
LICENSE_INSTANCE_FREE = Gauge('awx_license_instance_free', 'Number of remaining managed hosts provided by your license')
|
LICENSE_INSTANCE_FREE = Gauge('awx_license_instance_free', 'Number of remaining managed hosts provided by your license')
|
||||||
@@ -104,6 +106,8 @@ def metrics():
|
|||||||
INSTANCE_CAPACITY.labels(hostname=hostname, instance_uuid=uuid).set(instance_data[uuid]['capacity'])
|
INSTANCE_CAPACITY.labels(hostname=hostname, instance_uuid=uuid).set(instance_data[uuid]['capacity'])
|
||||||
INSTANCE_CPU.labels(hostname=hostname, instance_uuid=uuid).set(instance_data[uuid]['cpu'])
|
INSTANCE_CPU.labels(hostname=hostname, instance_uuid=uuid).set(instance_data[uuid]['cpu'])
|
||||||
INSTANCE_MEMORY.labels(hostname=hostname, instance_uuid=uuid).set(instance_data[uuid]['memory'])
|
INSTANCE_MEMORY.labels(hostname=hostname, instance_uuid=uuid).set(instance_data[uuid]['memory'])
|
||||||
|
INSTANCE_CONSUMED_CAPACITY.labels(hostname=hostname, instance_uuid=uuid).set(instance_data[uuid]['consumed_capacity'])
|
||||||
|
INSTANCE_REMAINING_CAPACITY.labels(hostname=hostname, instance_uuid=uuid).set(instance_data[uuid]['remaining_capacity'])
|
||||||
INSTANCE_INFO.labels(hostname=hostname, instance_uuid=uuid).info({
|
INSTANCE_INFO.labels(hostname=hostname, instance_uuid=uuid).info({
|
||||||
'enabled': str(instance_data[uuid]['enabled']),
|
'enabled': str(instance_data[uuid]['enabled']),
|
||||||
'last_isolated_check': getattr(instance_data[uuid], 'last_isolated_check', 'None'),
|
'last_isolated_check': getattr(instance_data[uuid], 'last_isolated_check', 'None'),
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ EXPECTED_VALUES = {
|
|||||||
'awx_custom_virtualenvs_total':0.0,
|
'awx_custom_virtualenvs_total':0.0,
|
||||||
'awx_running_jobs_total':0.0,
|
'awx_running_jobs_total':0.0,
|
||||||
'awx_instance_capacity':100.0,
|
'awx_instance_capacity':100.0,
|
||||||
|
'awx_instance_consumed_capacity':0.0,
|
||||||
|
'awx_instance_remaining_capacity':100.0,
|
||||||
'awx_instance_cpu':0.0,
|
'awx_instance_cpu':0.0,
|
||||||
'awx_instance_memory':0.0,
|
'awx_instance_memory':0.0,
|
||||||
'awx_instance_info':1.0,
|
'awx_instance_info':1.0,
|
||||||
|
|||||||
Reference in New Issue
Block a user