Inspired by Phoenix's LiveView Dashboard. Uses redis
pub-sub, chart.js, alpine.js, and websockets for streaming realtime updates of all current requests to a Django application.
- Python 3.6+
- Django 3.0+
- Django to be run via
ASGI
for websockets support
pip install django-live-dashboard
orpoetry add django-live-dashboard
- Update current
asgi.py
or use theasgi.py
file in the repo as an example - Add
"django_live_dashboard",
toINSTALLED_APPS
in settings file - Add
"django_live_dashboard.middleware.DjangoLiveDashboardMiddleware",
to beginning of theMIDDLEWARE
list in settings file - Add
DJANGO_LIVE_DASHBOARD
configuration to settings file (see details below) - Add to default
urls.py
:path("admin/", include(django_live_dashboard_urls))
- Run your server with something like
uvicorn project.asgi:application --port=8000
Configuration is in a DJANGO_LIVE_DASHBOARD
setting.
DJANGO_LIVE_DASHBOARD = {
"ENABLED": True,
"WEBSOCKET_HOST": 'localhost:8000',
"TOTAL_TIME_CUTOFF": 0.5,
"REDIS": {
"HOST": "localhost",
"PORT": 6379,
"DB": 0,
"PUBSUB_CHANNEL": "django_live_dashboard:stats"
},
"CHART": {
"REFRESH": 1000,
"DELAY": 1000,
"DURATION": 100000,
}
}
Whether any statistics should be logged. Defaults to DEBUG
.
The host that the websocket should listen to. Defaults to localhost
.
How long a request should take in seconds before getting logged. For example, if the value is 0.75, any request that takes longer than three quarters of a second will get graphed. Defaults to 0.5
.
Redis configuration with standard HOST
, PORT
, and DB
settings in a dictionary.
The host of the redis server. Defaults to localhost
.
THe port of the redis server. Defaults to 6379
.
The database of the redis server. Defaults to 0
.
Configuration for the streaming chart.js
plugin.
Delay in milliseconds of the chart.js
which helps to make the drawing more fluid and smooth. Defaults to 1000.
Time duration in milliseconds of how much data should be charted. Defaults to 100000.
How often the chart should try to refresh its data. Defaults to 1000.
Found in the example_project
directory in this repo.
redis-server
poetry install
poetry run example_project/manage.py migrate
poetry run example_project/manage.py createsuperuser
poetry run uvicorn example_project.project.asgi:application
- Go to http://localhost:8000/monitoring/
- Open up http://localhost:8000/admin/ in a new tab; go back to the first tab and you should see some updated information