In production, we have processes uploading metrics via an API I created, which causes duplication of datas. I did a workaround locally (using database migrations in the API), to alter a bit the structure: 1. Adding a unique constraint : ```sql ALTER TABLE metrics_values ADD CONSTRAINT unique_time_value_labels_id UNIQUE (time, value, labels_id); ``` 2. Adding an "ON CONFLICT" within the function `prometheus.insert_view_normal()`, at line 149 : https://github.com/timescale/pg_prometheus/blob/06b4c838a65ec096a236ba38f0046d03111dc1c7/sql/prometheus.sql#L149 Transforming this line as : ```sql EXECUTE format('INSERT INTO %I (time, value, labels_id) VALUES (%L, %L, %L) ON CONFLICT DO NOTHING', ``` so the unique constraint allow to push metrics, and no duplicates to be found afterwards. Does this qualify to be proposed as a PR ?
In production, we have processes uploading metrics via an API I created, which causes duplication of datas.
I did a workaround locally (using database migrations in the API), to alter a bit the structure:
prometheus.insert_view_normal(), at line 149 :pg_prometheus/sql/prometheus.sql
Line 149 in 06b4c83
Transforming this line as :
EXECUTE format('INSERT INTO %I (time, value, labels_id) VALUES (%L, %L, %L) ON CONFLICT DO NOTHING',so the unique constraint allow to push metrics, and no duplicates to be found afterwards.
Does this qualify to be proposed as a PR ?