albertodonato / query-exporter

Export Prometheus metrics from SQL queries
GNU General Public License v3.0
436 stars 101 forks source link

Increased in time RAM utilization #187

Open vvitad opened 7 months ago

vvitad commented 7 months ago

In time RAM utilization has been increasing

Exporter has shown huge RAM utilization up to 2GB that is progressing in time. Starting with 50MB it has grown to 1GB in 10 days. Other Postgres instance showed 50MB to 2GB in 7 days. Others has shown smaller growth: 30MB to 100MB in 10 days. After restarting the service, which is used to start exporter, memory 'returns', but than utilization starts to increase once again.

Installation details

To Reproduce

Such a huge increase is reproducing only on some instances, but the only difference between them - is the number of metrics retrieved(depends on the amount of queries and tables in database). I can't see how it can be the reason to not letting the memory go.

  1. Config file content (redacted of secrets if needed)
    
    databases:
    dbname:
    dsn: env:PG_DATABASE_DSN_dbname

metrics: pg_table_seq_scan: type: counter description: Number of sequential scans initiated on the table labels: [datname, schemaname, relname, parent_relname] ....

queries: table_stats: interval: 1h databases: [dbname] metrics:

PG_DATABASE_DSN_dbname=postgresql://exporter_user>:<password>@<host.ru:/dbname?target_session_attrs=read-write&application_name=query_exporter



Right now I'm trying to use keep-connected: false, but the results will take a couple of days at least. I have no understanding in why it keeps doing it and not just return memory back after doing a query. 
Also there is a thought that it could be Postgres specified behaviour. I would be grateful if you can share your knowledge. 

You can clearly see when restart of the exporter has been made.
<img width="1425" alt="Снимок экрана 2024-01-31 в 08 56 31" src="https://github.com/albertodonato/query-exporter/assets/22113207/ff57af4f-8d58-4016-9c14-62180cd3e99d">
vvitad commented 6 months ago

expiration: 1m also isn't helping

GSX1400 commented 4 months ago

I am also experiencing this bug.

OS: Amazon Linux 2 Docker image: 2.10.0

I have attempted it with the following:

OS: Ubuntu 24.04 Snap: 2.10.0

I have also tested version 2.9.0 with the same issue.

Same configuration for both to a Postgres RDS server.

If query exporter is left running, it will eventually consume all system memory, leading to a freeze.

vvitad commented 4 months ago

@GSX1400 we couldn't resolve this problem and chose another exporter burningalchemist/sql_exporter