always display awx_status_total

this way we don't have null data in monitoring data
this makes writing alerts and dashboards easier
This commit is contained in:
Elijah DeLee
2022-09-28 12:39:10 -04:00
parent 5b5aac675b
commit 710b02a443
2 changed files with 5 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ from prometheus_client import CollectorRegistry, Gauge, Info, generate_latest
from awx.conf.license import get_license from awx.conf.license import get_license
from awx.main.utils import get_awx_version from awx.main.utils import get_awx_version
from awx.main.models import UnifiedJob
from awx.main.analytics.collectors import ( from awx.main.analytics.collectors import (
counts, counts,
instance_info, instance_info,
@@ -169,8 +170,9 @@ def metrics():
all_job_data = job_counts(None) all_job_data = job_counts(None)
statuses = all_job_data.get('status', {}) statuses = all_job_data.get('status', {})
for status, value in statuses.items(): states = set(dict(UnifiedJob.STATUS_CHOICES).keys()) - set(['new'])
STATUS.labels(status=status).set(value) for state in states:
STATUS.labels(status=state).set(statuses.get(state, 0))
RUNNING_JOBS.set(current_counts['running_jobs']) RUNNING_JOBS.set(current_counts['running_jobs'])
PENDING_JOBS.set(current_counts['pending_jobs']) PENDING_JOBS.set(current_counts['pending_jobs'])

View File

@@ -19,8 +19,7 @@ EXPECTED_VALUES = {
'awx_hosts_total': 1.0, 'awx_hosts_total': 1.0,
'awx_schedules_total': 1.0, 'awx_schedules_total': 1.0,
'awx_sessions_total': 0.0, 'awx_sessions_total': 0.0,
'awx_sessions_total': 0.0, 'awx_status_total': 0.0,
'awx_sessions_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_consumed_capacity': 0.0,