Elastic fleet for postgresql fails to scrape pg_stat_statements

Hey,

I am currently setting up a elastic cloud installation with fleet agents. Our services are running in k8s as well as our agents. Also our databases are running in kubernetes.

Now I wanted to add the postgresql integration into my policy but I am experiencing issues when checking the dashboards. As far as I saw the agent is not able to scrape from pg_stat_statements. Here the exact error I get:

[elastic_agent.metricbeat][error] Error fetching data for metricset postgresql.statement: QueryStats: failed to query database: pq: relation "pg_stat_statements" does not exist

This is very weird as I am able to query the table through Datagrip in the postrgres database. Also I added the preloaded library on startup. I am not sure why this is happening as it can't shouldn't be a permissions issue as I used the same user to query manually as well as in the agent and some of the data metric data are in elastic.

Any help is much appreciated.

Thanks!

Hi D.R. welcome to the community!

I think the error doesn't seem like a permission issue on fleet/agent side, more like a problem with the postgresql setup.
I'm not very knowledgeable on postgresql, but found similar issues reported here:

Thanks @Julia_Bardi , there was indeed an issue. I didn't create the postgresql extension in the correct database.

Thank you for your help!

1 Like