This repository provides an end-to-end system for log file anomaly detection using machine learning on knowledge graphs. To accomplish this, a dataset is constructed by transforming log lines into sets of knowledge graph triples using a custom method built with Drain3. The training dataset helps the model learn what normal behavior of the system looks like. The testing and validation sets contain both normal and malicious behavior and test this model on its ability to recognize deviations from this baseline behavior.
Clone the repository with
git clone https://github.com/LucasAPayne/anomaly_detection.git
Use Anaconda to create and activate a virtual environment, then install the additional dependencies of this repository:
cd path/to/repo
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
cd lib/pykeen
pip install .
Finally, install torch by following the instructions on pytorch.org, making sure to install an appropriate version depending on your GPU and CUDA version if available.
This repository includes a demo using the AIT log dataset. To run this demo, it is required to download the AIT and cyberML datasets and place them into the data directory. Next, run
python demo_ait.py
or
python demo_cyberml.py
For the AIT dataset, which consists of raw log data, the demo extracts a training, testing, and validation set and transforms them into knowledge graph triples using a custom method, then trains a knowledge graph completion model with the data. The cyberML dataset consists of log data that has already been preprocessed with a different method. In this case, the demo only creates a validation set and trains a knowledge graph completion model with the data.