prometheus-community / postgres_exporter

A PostgreSQL metric exporter for Prometheus
Apache License 2.0
2.72k stars 724 forks source link

metric was collected before with the same name and label values v0.8.0 #439

Open MohamedMSaeed opened 3 years ago

MohamedMSaeed commented 3 years ago

I'm facing this error more often these days. Whenever I update the deployment, one or more metrics get this error.

* collected metric "pg_stat_statements_calls" { label:<name:"datname" value:"hamada" >  label:<name:"rolname" value:"xxx" > label:<name:"server" value:"xxx.svc:5432" > untyped:<value:2 > } was collected before with the same name and label values
* collected metric "pg_stat_statements_total_time_seconds" { label:<name:"datname" value:"hamada" > label:<name:"rolname" value:"xxx" > label:<name:"server" value:"xxx.svc:5432" > untyped:<value:7.026152139000001 > } was collected before with the same name and label values

I'm using exporter v0.8.0 I'm sure that I'm using a superuser.

To solve this issue temporarily, I delete the metrics and stop collecting them!

CoolCold commented 3 years ago

@MohamedMSaeed do you use master: true or not? I'm facing issue with database size if master: true is not specified

ArloL commented 3 years ago

In Azure PaaS we had the issue that the postgres user could not read queryid because it wasn't a member of the pg_read_all_stats role. After fixing that the error disappeared.

rhysjtevans commented 3 years ago

I had the same problem as @ArloL , I simply ran the following and it worked.

GRANT pg_read_all_stats to <MY_USER>;
set role pg_read_all_stats;
ArloL commented 3 years ago

Just sth. to be aware: If you followed the instructions of running as a non-superuser be aware that the new user does not need the role. The user creating the functions does e.g. postgres.