Skip to Content
FeaturesModulesMonitorManagement Commands

Management Commands

monitor_status

python manage.py monitor_status

Reports:

  • Whether monitoring is enabled (it always is — zero-config).
  • Whether Telegram alerts are on, i.e. whether a TelegramConfig is present on your DjangoConfig.
  • Where events go: <log dir>/djangocfg/monitor.log (logging.dir, else /var/log/<app>, else the per-user state dir; see Django Logging) with a summary of today’s captured events; stdout when no directory is writable.

monitor.log is size-rotated (10 MB x 5 by default) and old files are pruned at boot; python manage.py log_prune does it by hand (dry run unless --apply). Events are also flat JSON lines on stdout (docker logs ... | jq). monitor_status also shows how many browser events the ingest ceiling dropped.


See Also

monitor_tail

Print the last events from monitor.log, no docker and no grep.

python manage.py monitor_tail # last 20 events python manage.py monitor_tail -n 50 --frontend # last 50 browser events python manage.py monitor_tail --user 42 # one signed-in user (the primary key; a uuid works too) python manage.py monitor_tail --fingerprint 9f3a1c0b22d4e7aa # one error python manage.py monitor_tail --session <session_id> # one browser tab

In a container there is no file: the events live in stdout, so read them from the pipe. --stdin (or -) reads the events from standard input instead of monitor.log:

docker logs reforms-django 2>&1 | python manage.py monitor_tail --stdin docker logs reforms-django 2>&1 | python manage.py monitor_tail --stdin -n 50 --frontend --user 42

On stdin only JSON lines whose logger starts with django_cfg.monitor count; startup banners, tracebacks and other loggers are skipped silently. Filters, -n (filters first) and the output (user=<id>) are the same as for the file. The command reads stdin only when --stdin is given, so it never hangs waiting for input. With no log file and no --stdin it prints where it looked and the docker logs <container> 2>&1 | ... line to use.

The three filters combine (all must match) and apply before the -n cut. A line shows user=<id> when the event had one.

One line per event: time, frontend or server, level, event type, message, page URL, user=<id>. --frontend keeps only what arrived through POST /cfg/monitor/ingest/ (all levels, including the devtools ping from window.devtools.ping()). Without a log file it says where it looked and shows the docker one-liner. Nothing is stored by the command.

TAGS: django_monitor, management-commands, monitor_status, monitor_tail

Last updated on