Skip to content

Conversation

kdelee
Copy link
Member

@kdelee kdelee commented Jul 24, 2025

Description

  • What is being changed?
    Adding management command
  • Why is this change needed?
    Standardize database debugging procedure
  • How does this change address the issue?
    A management command that all django_ansible_base consumers will have available to get report on contents of database and current/historical query performance

Type of Change

  • New feature (non-breaking change which adds functionality)

Self-Review Checklist

  • I have performed a self-review of my code
  • I have added relevant comments to complex code sections
  • I have updated documentation where needed
  • I have considered the security impact of these changes
  • I have considered performance implications
  • I have thought about error handling and edge cases
  • I have tested the changes in my local environment

Testing Instructions

Prerequisites

Steps to Test

  1. pip install this into environment with ansible_base.resource_registry in INSTALLED_APPS
  2. for full report, enable pg_stat_statements as indicated in docs in this branch
  3. run management command for that consumer (for example, awx-manage database_resource_report)

Expected Results

REport prints to stdout (probably want to change that, but is a start)

Additional Context

Would like to include calling this and saving output into the SOS report plugins, but is not required for merge
https://issues.redhat.com/browse/AAP-50873

Required Actions

  • Requires documentation updates
  • Requires downstream repository changes
  • Requires infrastructure/deployment changes
  • Requires coordination with other teams
  • Blocked by PR/MR: #XXX

Screenshots/Logs

Adds a new management command, `database_resource_report`, to the
`resource_registry` application to generate reports on database usage
and query activity for PostgreSQL.

The command provides the following information:
- Table sizes and row counts.
- Object counts for all Django models.
- A real-time report from `pg_stat_activity`, with sorted lists for:
    - Longest running active queries
    - Oldest "idle in transaction" connections
    - Connections with active wait events
    - Oldest open connections
- Historical query performance statistics from `pg_stat_statements`,
  including most frequent, slowest, and resource-intensive queries.
  It also advises on enabling the extension if it is not active.
Copy link

DVCS PR Check Results:

Could not find JIRA key(s) in PR title, branch name, or commit messages

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
4 New issues
1 Security Hotspot
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@kdelee kdelee changed the title [wip] feat(reporting): Add database resource report command [wip] [AAP-50873] feat(reporting): Add database resource report command Aug 4, 2025
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