For developers and system administrators who often work with Command Line Interface (CLI) tools, the good news is that AI can be incorporated into your existing workflow. I found doing the following as helped me anaylsis large logs. Download Your Log Files and create a Bash Script.
#!/bin/bash FILE_NAME=$1 QUESTION=$2 # Run the Ollama AI with the question and the contents of the log file ollama run llama3:latest "${QUESTION} $(cat ${FILE_NAME})"
Save this script to a file, for example, ai_log_analyzer.sh, and give it execute permissions using chmod +x ai_log_analyzer.sh.
Start Asking AI Questions
With your script ready, you're now set to start asking questions about your log files. Simply run the script followed by the log file name and the question you want to ask. For example:
./ai_log_analyzer.sh system.log "Why did the last system crash occur?"
The script will feed your question and the log file content to Ollama, which will then use its AI capabilities to analyze the data and provide you with an answer. By following the steps outlined in this post, you can set up your system that allows you to interact with your log files.