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

Number of database connections per user #35196

Open
epochstamp opened this issue Sep 16, 2024 · 6 comments
Open

Number of database connections per user #35196

epochstamp opened this issue Sep 16, 2024 · 6 comments
Labels

Comments

@epochstamp
Copy link

Component(s)

receiver/postgresql

Is your feature request related to a problem? Please describe.

The number of maximum database active connections can be configured and is already tracked through the postgresql_connection_max metrics, yet there is no metrics to track the active number of connections. However this is an essential thing to monitor.

Describe the solution you'd like

Add a metrics named postgresql_connection_active with the following additional entries:

  • application_name - Name of the client application that started the session.
  • backend_start - Timestamp when the backend process was initiated.

Describe alternatives you've considered

Parse Loki logs to track connections vs disconnections, but this is a very rough approximation of the actual number of active connections...

Additional context

References:
Why active connections over max connections should be monitored
Query to get active connections per client

@epochstamp epochstamp added enhancement New feature or request needs triage New item requiring triage labels Sep 16, 2024
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@atoulme
Copy link
Contributor

atoulme commented Oct 2, 2024

backend_start would create a high cardinality situation. That won't work for this metric.

@atoulme atoulme removed the needs triage New item requiring triage label Oct 2, 2024
@epochstamp
Copy link
Author

epochstamp commented Oct 4, 2024

After further thinking I do not see any use-case (in the context of observability systems, at least from my place) of this anyway.

We could then just keep the application_name attribute.

Copy link
Contributor

github-actions bot commented Dec 4, 2024

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@github-actions github-actions bot added the Stale label Dec 4, 2024
@Grandys
Copy link
Contributor

Grandys commented Jan 27, 2025

There is already metric postgresql.backends

Source:

SELECT datname, count(*) as count from pg_stat_activity group by datname;

It doesn't have application_name attribute though. Is that what you need @epochstamp ?

@github-actions github-actions bot removed the Stale label Jan 28, 2025
@epochstamp
Copy link
Author

epochstamp commented Jan 31, 2025

There is already metric postgresql.backends

Source:

SELECT datname, count(*) as count from pg_stat_activity group by datname;
It doesn't have application_name attribute though. Is that what you need @epochstamp ?

Indeed, it would be nice to have it.

Thanks also for the pointer, I didn't realised that this metrics could actually allow to count active connections in a database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants