Skip to content

PG: Add sequence metrics#23444

Open
bonnefoa wants to merge 3 commits intomasterfrom
bonnefoa/sequence-metrics
Open

PG: Add sequence metrics#23444
bonnefoa wants to merge 3 commits intomasterfrom
bonnefoa/sequence-metrics

Conversation

@bonnefoa
Copy link
Copy Markdown
Collaborator

What does this PR do?

Generate metrics reporting the min, max and last_value of sequences. This will allow to monitor if a sequence is about to be exhausted.

Motivation

One issue is that users can't read a sequence's last value without SELECT permission on the sequence. This means a GRANT would be required for all sequences on all databases in order to allow the datadog agent user to read this last value.

Instead, we rely on a new pg_sequences function in the datadog schema that will be owned by the Postgres user, and GRANT it to the datadog-agent user. This will allow the agent to access all sequences, present and future, without having to provide additional GRANT.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add the qa/skip-qa label if the PR doesn't need to be tested during QA.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: feece89a5f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread postgres/datadog_checks/postgres/postgres.py Outdated
Comment thread postgres/datadog_checks/postgres/postgres.py
@datadog-prod-us1-4
Copy link
Copy Markdown
Contributor

datadog-prod-us1-4 Bot commented Apr 23, 2026

Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 96.67%
Overall Coverage: 92.80% (+5.66%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: cd3428f | Docs | Datadog PR Page | Give us feedback!

@cit-pr-commenter-54b7da
Copy link
Copy Markdown

cit-pr-commenter-54b7da Bot commented Apr 23, 2026

Monitor Template Quality Assessment

52 monitors analyzed across 9 integrations.

  • 31 monitors have missing sections
  • Most common missing sections: WHY, IMPACT, HOW_TO_TROUBLESHOOT
Monitors with missing sections
Integration Monitor Missing Sections Suggested Links
kubernetes [Kubernetes] Monitor Kubernetes Deployments Replica Pods IMPACT, WHY, HOW_TO_TROUBLESHOOT, RELATED_LINKS - Logs

@bonnefoa bonnefoa force-pushed the bonnefoa/sequence-metrics branch 4 times, most recently from c8f041a to 1872dd9 Compare April 23, 2026 15:27
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.35%. Comparing base (6597bfd) to head (cd3428f).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Generate metrics reporting the min, max and last_value of sequences.
This will allow to monitor if a sequence is about to be exhausted.

One issue is that users can't read a sequence's last value without
SELECT permission on the sequence. This means a GRANT would be required
for all sequences on all databases in order to allow the datadog agent
user to read this last value.

Instead, we rely on a new `pg_sequences` function in the datadog schema
that will be owned by the Postgres user, and GRANT it to the
datadog-agent user. This will allow the agent to access all sequences,
present and future, without having to provide additional
GRANT.
@bonnefoa bonnefoa force-pushed the bonnefoa/sequence-metrics branch from 1872dd9 to 69d3b56 Compare April 27, 2026 08:34
@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented Apr 27, 2026

Validation Report

All 20 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and Codecov settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
dep Verify dependency pins are consistent and Agent-compatible
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants