From 32bbf3a0c3f3a5b76bb03df52a1298b3ef2e209b Mon Sep 17 00:00:00 2001 From: Neev Geffen <133771232+neevnuv@users.noreply.github.com> Date: Thu, 15 May 2025 19:19:33 +0300 Subject: [PATCH] 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 --- awx/main/analytics/metrics.py | 2 ++ awx/main/tests/functional/analytics/test_metrics.py | 1 + 2 files changed, 3 insertions(+) diff --git a/awx/main/analytics/metrics.py b/awx/main/analytics/metrics.py index 100b1c968f..68cca87453 100644 --- a/awx/main/analytics/metrics.py +++ b/awx/main/analytics/metrics.py @@ -128,6 +128,7 @@ def metrics(): 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_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_FREE.set(str(license_info.get('free_instances', 0))) diff --git a/awx/main/tests/functional/analytics/test_metrics.py b/awx/main/tests/functional/analytics/test_metrics.py index 4295da0a6e..5fba90df71 100644 --- a/awx/main/tests/functional/analytics/test_metrics.py +++ b/awx/main/tests/functional/analytics/test_metrics.py @@ -30,6 +30,7 @@ EXPECTED_VALUES = { 'awx_license_instance_free': 0, 'awx_pending_jobs_total': 0, 'awx_database_connections_total': 1, + 'awx_license_expiry': 0, }