-
Clone this repository:
git clone https://github.com/GabrielZuany/ElasticSearchLoggs.git
-
Install and run Docker in your machine (for local development).
-
Go to elastic-config and run the compose file to pull the necessary images:
cd elastic-config docker compose up
-
Then await a few seconds and check the 2 urls below:
-
You must see these two windows:
-
So now your environment is setted up and ready to receive loggings from your Python application!
-
Create and activate the Virtual Environment:
python -m venv .venv .venv/Scripts/Activate.ps1
-
Install the requirements:
pip install -r requirements.txt
-
Import the ElasticSearchLogging class to your source code and create an object to manipulate logs:
import ElasticsearchLogs.ElasticsearchLogging as esl logging_sender = esl.ElasticsearchLogging( host="localhost", port=9200 index=DEFAULT_INDEX )
-
Once your setted up the host and port (and also index if you already have one), you can just send logs to Kibana:
import uuid logger.info(message="Hello World!", user_id=uuid.uuid4()) try: res = 1 / 0 except Exception as e: logger.error(message="Error", user_id=uuid.uuid4(), exception=e)
-
Your logs also going to be writen in console.
- Licensed under the MIT License
- Made by me (Gabriel Zuany Duarte Vargas)
- Feel free to sugest new features and fix non mapped bugs
- Last update: 07/08/2023