Add License Expiry Metric (#15483)

* add license expiry metric

* Update metrics test with default value to the new license metrics

* Add the changes of the black-lint command

* Update awx/main/analytics/metrics.py

---------

Co-authored-by: Seth Foster <fosterseth@users.noreply.github.com>
This commit is contained in:
Neev Geffen
2025-05-15 19:19:33 +03:00
committed by GitHub
parent c76ae8a2ac
commit 32bbf3a0c3
2 changed files with 3 additions and 0 deletions

View File

@@ -128,6 +128,7 @@ def metrics():
registry=REGISTRY, registry=REGISTRY,
) )
LICENSE_EXPIRY = Gauge('awx_license_expiry', 'Time before license expires', registry=REGISTRY)
LICENSE_INSTANCE_TOTAL = Gauge('awx_license_instance_total', 'Total number of managed hosts provided by your license', registry=REGISTRY) LICENSE_INSTANCE_TOTAL = Gauge('awx_license_instance_total', 'Total number of managed hosts provided by your license', registry=REGISTRY)
LICENSE_INSTANCE_FREE = Gauge('awx_license_instance_free', 'Number of remaining managed hosts provided by your license', registry=REGISTRY) LICENSE_INSTANCE_FREE = Gauge('awx_license_instance_free', 'Number of remaining managed hosts provided by your license', registry=REGISTRY)
@@ -148,6 +149,7 @@ def metrics():
} }
) )
LICENSE_EXPIRY.set(str(license_info.get('time_remaining', 0)))
LICENSE_INSTANCE_TOTAL.set(str(license_info.get('instance_count', 0))) LICENSE_INSTANCE_TOTAL.set(str(license_info.get('instance_count', 0)))
LICENSE_INSTANCE_FREE.set(str(license_info.get('free_instances', 0))) LICENSE_INSTANCE_FREE.set(str(license_info.get('free_instances', 0)))

View File

@@ -30,6 +30,7 @@ EXPECTED_VALUES = {
'awx_license_instance_free': 0, 'awx_license_instance_free': 0,
'awx_pending_jobs_total': 0, 'awx_pending_jobs_total': 0,
'awx_database_connections_total': 1, 'awx_database_connections_total': 1,
'awx_license_expiry': 0,
} }