Skip to content

Conversation

@0xgouda
Copy link
Collaborator

@0xgouda 0xgouda commented Nov 6, 2025

  • Support specifying partition interval for PostgreSQL sink via new --partition-interval flag that accepts a PostgreSQL interval string and uses it as the time range in the 3rd-level partition in metric tables.
  • All formats for PostgreSQL intervals are supported.

closes: #958
closes: #931

@coveralls
Copy link

coveralls commented Nov 6, 2025

Pull Request Test Coverage Report for Build 19174203732

Details

  • 10 of 11 (90.91%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.5%) to 71.845%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/sinks/postgres.go 10 11 90.91%
Totals Coverage Status
Change from base Build 19173203694: 0.5%
Covered Lines: 3570
Relevant Lines: 4969

💛 - Coveralls

@0xgouda 0xgouda requested a review from pashagolub November 6, 2025 14:36
@pashagolub pashagolub changed the title [+] Support variable partition intervals in postgres sink [+] support variable partition intervals in postgres sink Nov 6, 2025
@pashagolub pashagolub self-assigned this Nov 6, 2025
@pashagolub pashagolub added enhancement New feature or request sinks Where and how to store monitored data labels Nov 6, 2025
@pashagolub
Copy link
Collaborator

Thanks. I don't see any new tests and I don't see validation on --partition-interval parameter.

I'd put additional check into NewWriterFromPostgresConn just as we did for retention.

@pashagolub pashagolub force-pushed the 958-variable-partition-intervals branch from a8a9685 to 9edacf6 Compare November 6, 2025 15:14
@pashagolub
Copy link
Collaborator

pashagolub commented Nov 6, 2025

fixes #931 as well

@0xgouda 0xgouda force-pushed the 958-variable-partition-intervals branch from 6c088ac to 4a93038 Compare November 7, 2025 10:53
Copy link
Collaborator

@pashagolub pashagolub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! Thanks!

pashagolub and others added 9 commits November 7, 2025 17:14
`admin.ensure_partition_metric_dbname_time()` acccepts now
partition_period interval. The naming format is 'YYYYMMDD' for intervals
bigger than 1 day and 'YYYYMMDD_HH24' for hour-based intervals.
The function finds the last available partition bound and creates
new partition based on it. So it's possible to use mixed length
partitions, possibly with scheduler based on monitored source and/or
metrics.
- Pass the param directly o need for additional parsing
pgx already expects a string
@pashagolub pashagolub force-pushed the 958-variable-partition-intervals branch from 6426231 to c1a32f8 Compare November 7, 2025 16:14
@pashagolub pashagolub merged commit 5bcbc1a into master Nov 7, 2025
9 checks passed
@pashagolub pashagolub deleted the 958-variable-partition-intervals branch November 7, 2025 16:30
0xgouda added a commit that referenced this pull request Nov 10, 2025
* [+] allow to specify interval for Postgres partitioning

`admin.ensure_partition_metric_dbname_time()` acccepts now
partition_period interval. The naming format is 'YYYYMMDD' for intervals
bigger than 1 day and 'YYYYMMDD_HH24' for hour-based intervals.
The function finds the last available partition bound and creates
new partition based on it. So it's possible to use mixed length
partitions, possibly with scheduler based on monitored source and/or
metrics.

* Add new `PartitionInterval` cli parameter.

* Use `PartitionInterval` parameter in `EnsureMetricDbnameTime()`

* Mention `--partition-interval` in docs.

* Add validation logic for `PartitionInterval`

* Add test for `PartitionInterval` validation

* Test actual partitions creation

* Add example usage of `--partition-interval` in docs.

---------

Co-authored-by: Pavlo Golub <pavlo.golub@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request sinks Where and how to store monitored data

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Configurable PostgreSQL Partition Intervals Partitions overlap when changing time zone of PostgreSQL

4 participants