mirror of
https://github.com/ansible/awx.git
synced 2026-01-09 23:12:08 -03:30
Gracefully handle hostname change in metrics code
* Previously, we would error out because we assumed that when we got a metrics payload from redis, that there was data in it and it was for the current host. * Now, we do not assume that since we got a metrics payload, that is well formed and for the current hostname because the hostname could have changed and we could have not yet collected metrics for the new host.
This commit is contained in:
parent
612e8e7688
commit
51b2524b25
@ -456,7 +456,10 @@ class CustomToPrometheusMetricsCollector(prometheus_client.registry.Collector):
|
||||
logger.debug(f"No metric data not found in redis for metric namespace '{self._metrics._namespace}'")
|
||||
return None
|
||||
|
||||
host_metrics = instance_data.get(my_hostname)
|
||||
if not (host_metrics := instance_data.get(my_hostname)):
|
||||
logger.debug(f"Metric data for this node '{my_hostname}' not found in redis for metric namespace '{self._metrics._namespace}'")
|
||||
return None
|
||||
|
||||
for _, metric in self._metrics.METRICS.items():
|
||||
entry = host_metrics.get(metric.field)
|
||||
if not entry:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user