Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Metrics&Observability] Surface DB connections in /api/v2/metrics #12299

Closed
kdelee opened this issue May 31, 2022 · 3 comments · Fixed by #12427
Closed

[Metrics&Observability] Surface DB connections in /api/v2/metrics #12299

kdelee opened this issue May 31, 2022 · 3 comments · Fixed by #12427
Assignees

Comments

@kdelee
Copy link
Member

kdelee commented May 31, 2022

ISSUE TYPE
  • Feature Idea
SUMMARY

Surface the number of database connections awx is making to roll more of the data administrators need to track into /api/v2/metrics

Users can track this now by creating some kind of exporter that directly queries PG, but this is in general hacky and not portable. We know if we exceed the max connections that things start to go bad, so it is a best practice to track this number.

Maybe we can follow pattern of

def job_counts(since, **kwargs):
counts = {}
counts['total_jobs'] = models.UnifiedJob.objects.exclude(launch_type='sync').count()
counts['status'] = dict(models.UnifiedJob.objects.exclude(launch_type='sync').values_list('status').annotate(Count('status')).order_by())
counts['launch_type'] = dict(models.UnifiedJob.objects.exclude(launch_type='sync').values_list('launch_type').annotate(Count('launch_type')).order_by())
return counts

And create a database_stats function that returns a dictionary with a key for current connections by awx user. I say a dictionary so we can later expand that if desired, like adding number of idle vs active connections, or the max connections. These could then get surfaced like we do for guages like ORG_COUNT.

ORG_COUNT = Gauge('awx_organizations_total', 'Number of organizations', registry=REGISTRY)

@kdelee
Copy link
Member Author

kdelee commented May 31, 2022

@jainnikhil30 expressed interest in doing this

@kdelee
Copy link
Member Author

kdelee commented Jun 27, 2022

@Zokormazo in needs test now :D

@obaranov
Copy link
Contributor

Validated from QE side. Added automated tests.

@obaranov obaranov closed this as completed Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants