# What this PR does ## Main stuff - add Python script to populate local Grafana/OnCall setup w/ large amounts of fake data. Right now the data types that can be generated are: - teams and Admin users via the Grafana API (must be synced manually by going into the UI before going onto the next step) - Calendar Schedules which have three 8h oncall-shifts, via the OnCall public API - fixes `django-debug-toolbar` when being run in `docker-compose` locally ## Other stuff - documents how to easily modify the Grafana `docker-compose` container provisioning configuration - document solutions for two backend setup related issues encountered when running the engine/celery workers locally, outside of `docker-compose`, on an Apple silicon Mac - fixes small bug in `grafana_plugin.helpers.client.APIClient.call_api` where it would call `response.json()` for all requests, regardless of whether or not the response actually contained data or not - in `engine/settings/dev.py`, properly setup `django-silk` and document the steps to use it locally - make it possible to log out debug SQL queries by specifying `DEV_DEBUG_VIEW_SQL_QUERIES` env var, rather than having to uncomment out a section of `settings/dev.py` ## Which issue(s) this PR fixes - Some local setup issues when trying to use `django-silk` and `django-debug-toolbar` - Makes it much easier to populate your local setup with a lot of fake data - Makes it possible to easily modify your local grafana's provisioning configuration ## Checklist - [ ] Tests updated (N/A) - [ ] Documentation added (N/A) - [ ] `CHANGELOG.md` updated (N/A) |
||
|---|---|---|
| .. | ||
| main.py | ||
| README.md | ||
| requirements.txt | ||
Fake Data Generator Script
This script can be used to easily populate fake data into your local Grafana/OnCall setup. Currently the script is capable of generating the following objects:
- teams
- users
- schedules
- schedule on call shifts
Prerequisites
- Create/active a Python 3.9 virtual environment
pip install -r requirements.txt- Must have a local version of Grafana and OnCall up and running
- Generate an API key inside of Grafana OnCall
How to run
Note: The below flag values assume you are running a grafana container locally via the docker-compose setup.
The reason why there is a few separate steps involved is that we need to first create teams and users in the Grafana
instance. Later on, in order to create OnCall schedules/oncall-shifts, we need the OnCall user ID to do so. There is
currently no way to trigger a Grafana -> OnCall data sync via the public API, hence the manual step in the middle
to have data synced between Grafana and OnCall.
-
Create teams and users in Grafana. The
teamsandusersflags represent the number of teams and users you would like to create respectively:# by default this will generate 10 teams and 1000 users python main.py generate_teams_and_usersSee
python main.py generate_teams_and_users -hfor more information on how to run the command. -
Head to your OnCall setup, and trigger a Grafana -> OnCall data sync by visiting the plugin page.
-
Create schedules and on call shifts in OnCall. The
schedulesflag represents the number of OnCall schedules you would like to generate. Note that one on call shift is created for each schedule:# by default this will generate 100 schedules python main.py generate_schedules_and_oncall_shifts --oncall-api-token=<oncall-api-key>See
python main.py generate_schedules_and_oncall_shifts -hfor more information on how to run the command.