Python Realtime Processing Tweets COVID-19 using Kafka + Elasticsearch + Kibana + Docker + Docker-Compose
If you want use this repository you need to make a git clone:
git clone --depth 1 https://github.com/lpmatos/twitter-realtime-processing-covid.git -b masterThis will give access on your local machine.
To this project you yeed:
- Python 3.8.
- Docker and Docker Compose.
- Kafka ecosystem.
- Elasticsearch.
- Kiabana
- Set the application environment variables.
- Install python packages in requirements.txt.
- Run docker-compose.yml to deploy all kafka and elastic ecosystem.
- Profit.
- Set all environment variables in dot-env files.
- Creathe a docker network.
- Run docker-compose.yml to deploy all kafka and elastic ecosystem.
- Run docker-compose-tools.to run the application.
- Profit.
This system is fully containerised. You will need Docker and Docker Compose to run it.
You simply need to create a Docker network called kafka-network to enable communication between the Kafka cluster and the apps:
$ docker network create kafka-networkAll set!
curl -X POST kafka-connect:8083/connectors -H "Content-Type: application/json" -d '{
"name": "elasticsearch-sink-kafka",
"config": {
"connector.class": "io.confluent.connect.elasticsearch.ElasticsearchSinkConnector",
"type.name": "kafka-connect",
"key.converter.schemas.enable": "false",
"tasks.max": "1",
"topics": "dados-tweets",
"value.converter.schemas.enable": "false",
"key.ignore": "true",
"connection.url": " http://elasticsearch:9200",
"value.converter": "org.apache.kafka.connect.json.JsonConverter",
"key.converter": "org.apache.kafka.connect.storage.StringConverter",
"schema.ignore": "true"
}
}'| Name | Description |
|---|---|
| TWITTER_CONSUMER_KEY | Twitter Consumer Key |
| TWITTER_CONSUMER_SECRET | Twitter Consumer Secret |
| TWITTER_ACCESS_TOKEN | Twitter Access Token |
| TWITTER_ACCESS_TOKEN_SECRET | Twitter Access Token Secret |
| LOG_PATH | Just the Log Path |
| LOG_FILE | Just the Log File |
| LOG_LEVEL | Just the Log Level |
| LOGGER_NAME | Just the Logger name |
| KAFKA_BROKER_URL | Kafka Broker URL |
| KAFKA_TOPIC | Kafka Topic Name |
We use decouple for strict separation of settings from code. It helps us with to store parameters in .env file and properly convert values to correct data type.
Copy the file .env-example to a .env file and replace the values inside of it.
Ways to run and use this project.
Docker
Steps to build the Docker Image.
docker image build -t <IMAGE_NAME> -f <PATH_DOCKERFILE> <PATH_CONTEXT_DOCKERFILE>
docker image build -t <IMAGE_NAME> . (This context)Steps to run the Docker Container.
- Linux running:
docker container run -d -p <LOCAL_PORT:CONTAINER_PORT> <IMAGE_NAME> <COMMAND>
docker container run -it --rm --name <CONTAINER_NAME> -p <LOCAL_PORT:CONTAINER_PORT> <IMAGE_NAME> <COMMAND>- Windows running:
winpty docker.exe container run -it --rm <IMAGE_NAME> <COMMAND>
For more information, access the Docker documentation or this.
Docker-Compose
Build and run a docker-compose.
docker-compose up --buildDown all services deployed by docker-compose.
docker-compose downDown all services and delete all images.
docker-compose down --rmi allDepending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
👤 Lucca Pessoa
Hey!! If you like this project or if you find some bugs feel free to contact me in my channels:
- Email: lpsm-dev@protonmail.com
- Website: https://github.com/lpmatos
- GitHub: @lpmatos
- GitLab: @lpmatos
To check the change history, please access the CHANGELOG.md file.
If you have any problems, please contact me.
This project is currently undergoing a reorganization 👾.

