This POC connects to an Elasticsearch instance to collect network logs, applies anomaly detection using the Isolation Forest algo, and exports detected anomalies back to Elasticsearch. for further analysis.
- Connect to an Elasticsearch server
- Retrieves up to 1000 logs from the
filebeat-*index. - Detects anomalies using the isolation forest model
- exports anomalies into a dedicated index :
anomalies-ml
sudo apt update
sudo apt install python3 python3-pip python3-venv -y
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# create .env file
python collect_logs.pyMake sur to have Elasticsearch running on localhost:9200
- Open Kibana in your web browser (usually at
http://IP_ELASTIC_SERVER:5601). - Go to the "Management" section.
- Click on "Index Patterns".
- Click on "Create index pattern".
- Enter
anomalies-mlas the index pattern. - Go to Dashboard and create a new dashboard.
- Create a new visualization.
- Select the "Bar vertical" visualization type.
- Select the
anomalies-mlindex pattern. - Drag and drop the
@timestampfield into the "X-axis" section. - Drag and drop the
anomalyfield into the "Y-axis" section and select "Count" as the aggregation. - Click on "Save" to save the visualization.