-
Notifications
You must be signed in to change notification settings - Fork 44
Unique metrics #39
Comments
@Knudian Thank you for your proposal. |
For consistency, it might be good to implement duplicate elimination for raw schema too. |
I did the modifications on my fork (https://github.com/Knudian/pg_prometheus/tree/feature/unique-metrics). For the tests ... I have to admit that I'm totally lost (I can make sql request, and counting results so it follows as expected by the unique constraints, but after that ?). |
The test can be continuation of the existing tests. For example, it inserts new data with duplicates after the existing test and then selects data from the table and compares with the expected result, which should not contain duplicates. |
@spolcyn see above! Not sure if you'll have time to get to it in addition to the other things you're doing, but worth looking at. |
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 ?
The text was updated successfully, but these errors were encountered: