Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pending jobs and system level job status to metrics #4375

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions awx/main/analytics/collectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def counts(since):
counts['active_user_sessions'] = active_user_sessions
counts['active_anonymous_sessions'] = active_anonymous_sessions
counts['running_jobs'] = models.UnifiedJob.objects.exclude(launch_type='sync').filter(status__in=('running', 'waiting',)).count()
counts['pending_jobs'] = models.UnifiedJob.objects.exclude(launch_type='sync').filter(status__in=('pending',)).count()
return counts


Expand Down
9 changes: 9 additions & 0 deletions awx/main/analytics/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
counts,
instance_info,
job_instance_counts,
job_counts,
)


Expand All @@ -36,6 +37,8 @@
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')
PENDING_JOBS = Gauge('awx_pending_jobs_total', 'Number of pending jobs on the Tower system')
STATUS = Gauge('awx_status_total', 'Status of Job launched', ['status',])

INSTANCE_CAPACITY = Gauge('awx_instance_capacity', 'Capacity of each node in a Tower system', ['hostname', 'instance_uuid',])
INSTANCE_CPU = Gauge('awx_instance_cpu', 'CPU cores on each node in a Tower system', ['hostname', 'instance_uuid',])
Expand Down Expand Up @@ -87,7 +90,13 @@ def metrics():
USER_SESSIONS.labels(type='user').set(current_counts['active_user_sessions'])
USER_SESSIONS.labels(type='anonymous').set(current_counts['active_anonymous_sessions'])

all_job_data = job_counts(None)
statuses = all_job_data.get('status', {})
for status, value in statuses.items():
STATUS.labels(status=status).set(value)

RUNNING_JOBS.set(current_counts['running_jobs'])
PENDING_JOBS.set(current_counts['pending_jobs'])

instance_data = instance_info(None, include_hostnames=True)
for uuid, info in instance_data.items():
Expand Down
3 changes: 2 additions & 1 deletion awx/main/tests/functional/analytics/test_counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def test_empty():
"team": 0,
"user": 0,
"workflow_job_template": 0,
"unified_job": 0
"unified_job": 0,
"pending_jobs": 0
}


Expand Down
1 change: 1 addition & 0 deletions awx/main/tests/functional/analytics/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
'awx_instance_info':1.0,
'awx_license_instance_total':0,
'awx_license_instance_free':0,
'awx_pending_jobs_total':0,
}


Expand Down