Query Insights not working in SQL instance

I have enabled query insights on sql db instance, but still unable to get any data in the query insights dashboard.

DB version: PostgreSQL 14.4

Below errors are the only errors being logged in the db:

db=cloudsqladmin,user=cloudsqladmin STATEMENT: select count(*) from google_insights_aggregated_stats(); ERROR: function google_insights_aggregated_stats() does not exist at character 22"

Hi @Shravan_14 ,

Welcome to Google Cloud Community!

It appears that the error message “function google_insights_aggregated_stats() does not exist” suggests that the necessary extension for query insights is not installed or not enabled on your PostgreSQL 14.4 instance.

To resolve this issue, you should ensure that the “pg_stat_statements” extension is installed and enabled on your database. You can check if it’s already installed by running the command ‘dx’ in psql shell.

If it’s not installed, you can install it by running the following command in psql shell:

CREATE EXTENSION IF NOT EXISTS pg_stat_statements;

After that, you need to configure the pg_stat_statements by running the following query :

SELECT pg_stat_statements.track('all');

Once you’ve done this, you should be able to see data in the query insights dashboard

Thank you!

Hi @christianpaula

Thanks for the reply.

pg_stat_statements extension is installed and pg_stat_statements.track flag is also set to all, but still there is no data in query insights dashboard.

Were you able to make it work somehow?

Hi,

the solution didn’t work for me. I have a fresh postgres 14 migrated from aws. I’m still getting:

db=cloudsqladmin,user=cloudsqladmin STATEMENT: select count(*) from google_insights_aggregated_stats(); ERROR: function google_insights_aggregated_stats() does not exist at character 22"

Hi,

this solution didt’n work for me too. I got this error when I migrate the data from cloudsql instance X to cloudsql instance Y using DMS. I have also reenable the query insight, but it doest’n work, still getting error “db=cloudsqladmin,user=cloudsqladmin ERROR: function google_insights_aggregated_stats() does not exist at character 22”

I’m seeing the same issue after migrating using DMS.

I also have this issue. All my DB’s have been migrated using DMS which seems consistent with what other people in this thread are seeing. Not all my databases have this issue. Some which have been migrated with DMS are fine, but others are not.

The error seems to be coming from the cloudsqladmin user running on the cloudsqladmin database, which users do not have access to. I imagine this is where the CREATE EXTENSION command would need to be run? If so, we can’t do that.

Any other possible solution?

@christianpaula Is there a way we can extract these query insights result outside to bigquery or graffana ?