mirror of
https://github.com/ansible/awx.git
synced 2026-02-19 20:20:06 -03:30
possible work around for 500 on /api/v2/metrics (#12376)
we've observed this in development and some users have reported experiencing 500's on /api/v2/metrics because of a key error here where a metric is missing from a certain instance
This commit is contained in:
@@ -40,7 +40,9 @@ class BaseM:
|
|||||||
def to_prometheus(self, instance_data):
|
def to_prometheus(self, instance_data):
|
||||||
output_text = f"# HELP {self.field} {self.help_text}\n# TYPE {self.field} gauge\n"
|
output_text = f"# HELP {self.field} {self.help_text}\n# TYPE {self.field} gauge\n"
|
||||||
for instance in instance_data:
|
for instance in instance_data:
|
||||||
output_text += f'{self.field}{{node="{instance}"}} {instance_data[instance][self.field]}\n'
|
if self.field in instance_data[instance]:
|
||||||
|
# on upgrade, if there are stale instances, we can end up with issues where new metrics are not present
|
||||||
|
output_text += f'{self.field}{{node="{instance}"}} {instance_data[instance][self.field]}\n'
|
||||||
return output_text
|
return output_text
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user