Implementation of a Django REST API sending telemetry to Azure Application Insights from reference sample.
Implement Cloud_RoleName tags for microservices.
Create the infrastructure:
terraform -chdir="azure/terraform" init
terraform -chdir="azure/terraform" apply -auto-approveGet the Application Insights connection string:
az monitor app-insights component show --app '<appi>' -g '<group>' --query 'connectionString' -o tsvCreate the .env file from the template:
cp samples/sample.env .envSet the APPLICATIONINSIGHTS_CONNECTION_STRING environment variable with the Azure value.
Install the dependencies:
poetry install
poetry shellApply the migrations and start the server to start sending telemetry.
python manage.py makemigrations
python manage.py migrate
python manage.py runserver --noreloadAdditional examples here and here.
Call the API to test the tracing:
curl localhost:8000/users/Example KQL query on table request:
requests
| where timestamp >= ago(1h)Tip
Code snippets based from my other project epomatti/benchmarks.
Make sure the .env is configured, and start the application:
docker compose up --buildTest the tracing:
curl localhost:8000/users/Issues with gunicorn may happen, such as this one.
Follow the documentation for troubleshooting various scenarios.
