This program processes a flow log file and assigns tags to each log entry based on a lookup table. It then generates an output file with the count of matches for each tag and the count of matches for each port/protocol combination.
lookup_table.csv
: Contains the port, protocol, and tag mappings.flow_log.txt
: Contains the flow log data to be processed.output/
: Directory where the output file will be saved.output/tag_counts.txt
: Output file with the count of matches for each tag.output/protocol_counts.txt
: Output file with the count of matches for each port/protocol combination.
- The log entries in the flow log file are formatted similarly to AWS VPC flow logs.
- The program is case-insensitive when matching protocols and tags.
- Entries that do not match any port/protocol combination in the lookup table are considered "Untagged".
- Ensure the input files (
lookup_table.csv
andflow_log.txt
) are present in theinput/
directory. You can generate them using thegenerate_input_files/generator.py
script and check theinput/
directory for the results.
Command: python generate_input_files/generator.py
- Run the program to process the flow log and generate the output.
Command: python flow_log_parser.py
- Check the
output/
directory for the results.
- Run the test script in the
tests/
directory.
Command: python -m unittest tests/test_flow_log_parser.py
- The output and input directory are cleared after tests are run. You can comment out the
tearDownClass
method in thetests/test_flow_log_parser.py
file to keep the files in directory.