Projeto para estudo da integração Django com Elastic APM para monitoramento de performance de uma API REST.
- Postgres
- Rabbitmq
- ElasticSearch
- Kibana
- Elastic APM
docker-compose up -d
IMAGE | COMMAND | STATUS | PORTS | NAMES |
---|---|---|---|---|
postgres:12 | "docker-entrypoint.s…" | Up About an hour | 0.0.0.0:5432->5432/tcp | djapm_postgres_1 |
rabbitmq:3-management | "docker-entrypoint.s…" | Up About an hour | 4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, 15671/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp | djapm_rabbitmq_1 |
docker-compose -f apm-docker-compose.yml up -d
IMAGE | COMMAND | STATUS | PORTS | NAMES |
---|---|---|---|---|
docker.elastic.co/elasticsearch/elasticsearch:7.8.1 | "/tini -- /usr/local…" | Up About an hour (healthy) | 0.0.0.0:9200->9200/tcp, 9300/tcp | djapm_elasticsearch_1 |
docker.elastic.co/kibana/kibana:7.8.1 | "/usr/local/bin/dumb…" | Up About an hour (healthy) | 0.0.0.0:5601->5601/tcp | djapm_kibana_1 |
docker.elastic.co/apm/apm-server:7.8.1 | "/usr/local/bin/dock…" | Up About an hour (healthy) | 0.0.0.0:8200->8200/tcp | djapm_apm_server_1 |
- Criar virtualenv
- Instalar requisitos
pip install -r requirements/dev.txt
- Iniciar Django
./manage.py runserver
- Iniciar Worker com fila padrão
celery worker -A djapm -l INFO
- Iniciar Beat com task configurada para uma chamada por minuto
celery beat -A djapm -S django -l INFO
Após exectuar os serviços, acesse o kibana (http://localhost:5601) na aba APM, há um menu para configurar e inciar o monitoramento.
- Popular base de dados de usuários
./manage.py runscript populate_db_users
- Simular várias requisições de vários usuários
./manage.py runscript random_request
- Simular várias chamadas de tasks de vários usuários
./manage.py runscript random_tasks
https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker
https://www.elastic.co/guide/en/kibana/current/docker.html#docker
https://www.elastic.co/guide/en/apm/server/7.8/running-on-docker.html#running-on-docker