mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
add uuids to ping and metrics
This commit is contained in:
parent
23d0f6022c
commit
40393e201f
@ -159,11 +159,12 @@ class ApiV1PingView(APIView):
|
||||
'ha': is_ha_environment(),
|
||||
'version': get_awx_version(),
|
||||
'active_node': settings.CLUSTER_HOST_ID,
|
||||
'install_uuid': settings.INSTALL_UUID,
|
||||
}
|
||||
|
||||
response['instances'] = []
|
||||
for instance in Instance.objects.all():
|
||||
response['instances'].append(dict(node=instance.hostname, heartbeat=instance.modified,
|
||||
response['instances'].append(dict(node=instance.hostname, uuid=instance.uuid, heartbeat=instance.modified,
|
||||
capacity=instance.capacity, version=instance.version))
|
||||
sorted(response['instances'], key=operator.itemgetter('node'))
|
||||
response['instance_groups'] = []
|
||||
|
||||
@ -37,10 +37,10 @@ USER_SESSIONS = Gauge('awx_sessions_total', 'Number of sessions', ['type',])
|
||||
CUSTOM_VENVS = Gauge('awx_custom_virtualenvs_total', 'Number of virtualenvs')
|
||||
RUNNING_JOBS = Gauge('awx_running_jobs_total', 'Number of running jobs on the Tower system')
|
||||
|
||||
INSTANCE_CAPACITY = Gauge('awx_instance_capacity', 'Capacity of each node in a Tower system', ['type',])
|
||||
INSTANCE_CPU = Gauge('awx_instance_cpu', 'CPU cores on each node in a Tower system', ['type',])
|
||||
INSTANCE_MEMORY = Gauge('awx_instance_memory', 'RAM (Kb) on each node in a Tower system', ['type',])
|
||||
INSTANCE_INFO = Info('awx_instance', 'Info about each node in a Tower system', ['type',])
|
||||
INSTANCE_CAPACITY = Gauge('awx_instance_capacity', 'Capacity of each node in a Tower system', ['instance_uuid',])
|
||||
INSTANCE_CPU = Gauge('awx_instance_cpu', 'CPU cores on each node in a Tower system', ['instance_uuid',])
|
||||
INSTANCE_MEMORY = Gauge('awx_instance_memory', 'RAM (Kb) on each node in a Tower system', ['instance_uuid',])
|
||||
INSTANCE_INFO = Info('awx_instance', 'Info about each node in a Tower system', ['instance_uuid',])
|
||||
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',])
|
||||
|
||||
@ -48,7 +48,7 @@ INSTANCE_STATUS = Gauge('awx_instance_status_total', 'Status of Job launched', [
|
||||
def metrics():
|
||||
license_info = get_license(show_key=False)
|
||||
SYSTEM_INFO.info({
|
||||
'system_uuid': settings.SYSTEM_UUID,
|
||||
'install_uuid': settings.INSTALL_UUID,
|
||||
'insights_analytics': str(settings.INSIGHTS_DATA_ENABLED),
|
||||
'tower_url_base': settings.TOWER_URL_BASE,
|
||||
'tower_version': get_awx_version(),
|
||||
@ -87,10 +87,10 @@ def metrics():
|
||||
|
||||
instance_data = instance_info(None)
|
||||
for uuid in instance_data:
|
||||
INSTANCE_CAPACITY.labels(type=uuid).set(instance_data[uuid]['capacity'])
|
||||
INSTANCE_CPU.labels(type=uuid).set(instance_data[uuid]['cpu'])
|
||||
INSTANCE_MEMORY.labels(type=uuid).set(instance_data[uuid]['memory'])
|
||||
INSTANCE_INFO.labels(type=uuid).info({
|
||||
INSTANCE_CAPACITY.labels(instance_uuid=uuid).set(instance_data[uuid]['capacity'])
|
||||
INSTANCE_CPU.labels(instance_uuid=uuid).set(instance_data[uuid]['cpu'])
|
||||
INSTANCE_MEMORY.labels(instance_uuid=uuid).set(instance_data[uuid]['memory'])
|
||||
INSTANCE_INFO.labels(instance_uuid=uuid).info({
|
||||
'enabled': str(instance_data[uuid]['enabled']),
|
||||
'last_isolated_check': getattr(instance_data[uuid], 'last_isolated_check', 'None'),
|
||||
'managed_by_policy': str(instance_data[uuid]['managed_by_policy']),
|
||||
@ -100,7 +100,6 @@ def metrics():
|
||||
instance_data = job_instance_counts(None)
|
||||
for node in instance_data:
|
||||
# skipping internal execution node (for system jobs)
|
||||
# TODO: determine if we should exclude execution_node from instance count
|
||||
if node == '':
|
||||
continue
|
||||
types = instance_data[node].get('launch_type', {})
|
||||
|
||||
@ -60,7 +60,6 @@ def test_metrics_counts(organization_factory, job_template_factory, workflow_job
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_metrics_permissions(get, admin, org_admin, alice, bob, organization):
|
||||
|
||||
assert get(reverse('api:metrics_view'), user=admin).status_code == 200
|
||||
assert get(reverse('api:metrics_view'), user=org_admin).status_code == 403
|
||||
assert get(reverse('api:metrics_view'), user=alice).status_code == 403
|
||||
@ -75,7 +74,6 @@ def test_metrics_permissions(get, admin, org_admin, alice, bob, organization):
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_metrics_http_methods(get, post, patch, put, options, admin):
|
||||
|
||||
assert get(reverse('api:metrics_view'), user=admin).status_code == 200
|
||||
assert put(reverse('api:metrics_view'), user=admin).status_code == 405
|
||||
assert patch(reverse('api:metrics_view'), user=admin).status_code == 405
|
||||
|
||||
@ -116,6 +116,7 @@ INSTALLED_APPS += ('rest_framework_swagger',)
|
||||
|
||||
# Configure a default UUID for development only.
|
||||
SYSTEM_UUID = '00000000-0000-0000-0000-000000000000'
|
||||
INSTALL_UUID = '00000000-0000-0000-0000-000000000000'
|
||||
|
||||
# Store a snapshot of default settings at this point before loading any
|
||||
# customizable config files.
|
||||
|
||||
0
tools/prometheus/data/lock
Normal file
0
tools/prometheus/data/lock
Normal file
BIN
tools/prometheus/data/wal/00000000
Normal file
BIN
tools/prometheus/data/wal/00000000
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user