Skip to content

Postgres database agent support - #2103

Closed
JayPolanco wants to merge 3 commits into
dbifrom
postgres-test
Closed

Postgres database agent support#2103
JayPolanco wants to merge 3 commits into
dbifrom
postgres-test

Conversation

@JayPolanco

@JayPolanco JayPolanco commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Description of the issue

Self-managed PostgreSQL monitoring on EC2 requires the CloudWatch Agent to collect counter metrics, DB Load (active session sampling at 1s), and Top SQL statistics. The upstream OTel PostgreSQL receiver (v0.150.0) provides the foundation but has gaps for these requirements.

Description of changes

Embedded upstream v0.150.0 postgresqlreceiver into receiver/postgresqlreceiver/ with adapted module paths and inlined internal/sqlquery dependency.

Registered new components in service/defaultcomponents/components.go:

  • postgresqlreceiver
  • signaltometricsconnector (converts log events → metrics)

Gap fixes on top of upstream (reviewer focus):

  1. Independent query_sample collection_interval — Added CollectionInterval to QuerySampleCollection and separate ControllerConfig in createLogsReceiver. Allows 1s DB Load sampling without affecting 60s counter collection.

  2. postgresql.sessions metric — New gauge metric querying pg_stat_activity GROUP BY state for session state breakdown (active/idle/idle_in_transaction). Disabled by default via metrics config.

  3. Top SQL local_blks columns — Added local_blks_hit, local_blks_read, local_blks_dirtied, local_blks_written to the top query SQL template.

  4. Exclude receiver self-connection from DB Load — Added pid <> pg_backend_pid() filter to the query sample template to prevent the receiver's own database connection from inflating active session counts.

Updated components_test.go for new receiver and connector counts.

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

  • components_test.go updated and passing
  • End-to-end validated on EC2 with PostgreSQL 16: counter metrics, Top SQL metrics, DB Load metrics, session states, and raw log events all flowing to CloudWatch

Requirements

  1. Run make fmt and make fmt-sh
  2. Run make lint

@JayPolanco
JayPolanco requested a review from a team as a code owner April 27, 2026 22:04
@JayPolanco JayPolanco closed this May 4, 2026
@JayPolanco

Copy link
Copy Markdown
Contributor Author

Not needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant