Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand Celery-Beat DB status check to include DB size #1300

Open
exalate-issue-sync bot opened this issue Jan 24, 2025 · 3 comments
Open

Expand Celery-Beat DB status check to include DB size #1300

exalate-issue-sync bot opened this issue Jan 24, 2025 · 3 comments
Assignees
Labels

Comments

@exalate-issue-sync
Copy link

exalate-issue-sync bot commented Jan 24, 2025

In order to expand visibility into the state of our postgresql databases, the developer will expand the regular Celery-Beat status check to also include the current size of the psql database and it’s relation to the max storage of the db which is 1TB.

QA Notes

The developer should include a screenshot of the status check, with it now having the size of the database.

DEV Notes

In order to directly query the postgresql database from a django management command, you will likely want to use the {{connection.cursor().execute()}} method. See the official Django documentation [here|https://docs.djangoproject.com/en/5.1/topics/db/sql/#executing-custom-sql-directly].

The PSQL command that you will likely want to use is:

{{select pg_size_pretty(pg_database_size('[DB_NAME]'));}}

Where [DB_NAME] is the name of the database in question. We store the database name in an environment variable, but if you needed to find it within the context of a psql shell, you could use:

{{select datname from pg_database where datistemplate=false order by pg_database_size(datname) desc limit 1;}}

The database name is sensitive information, and it should not be hard-coded. It must be retrieved at run-time, either from an environment variable or from psql directly, whichever is more convenient.

Design

null

See full ticket and images here: FECFILE-1973

Pull Request: #1313

Copy link
Author

Elaine Krauss commented: Screenshot of the check running on the scheduler on DEV

!image-20250130-220132.png|width=1754,height=230,alt="image-20250130-220132.png"!

Copy link
Author

Elaine Krauss commented: Screenshot of the results as seen on DEV’s web services

!image-20250130-220320.png|width=1998,height=40,alt="image-20250130-220320.png"!

Copy link
Author

Elaine Krauss commented: {{{'db_size_gb': 0.11308363359421492, 'db_size_pretty': '0.11 GB / 1024 GB (0.01%)', 'db_growth': '0.0 GB in the last 0.01 days', 'db_est_days_to_full': None}}}

Here’s a breakdown of what gets logged:

  • {{db_size_gb}} the size of the database as measured in gigabytes
  • {{db_size_pretty}} the size of the database in a human readable format with additional information regarding the capacity included
  • {{db_growth}} a human-readable measure of how much the database has grown since tracking started
  • {{db_est_days_to_full}} a human-readable estimation of how long it will be until the database reaches its maximum capacity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants