Table of Contents
The project is built on Flask
. It helps you ingest logs and then later query it. It consists of app.py. On running app.py the server will run on localhost on port 3000. On launching the localhost with port 3000 a query_form will be visible in your browser.
On enterring query in the input boxes if a query is matched then the logs are shown in query_result webpage.
Flask
MySQL
HTML
This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.
This is an example of how to list things you need to use the software and how to install them.
- pip
pip install flask
pip install mysql-connector-python
Save app.py
and templates
in a folder.
- run in terminal where you have saved the file.
python app.py
A new database is created(if not present) with the name logs. To see if the database is created open mysql command line client and run
show databases;
A table with name logs is created in the same database. To check if the table is created successfully run
show tables;
To add logs to the table use -
- windows
*Linux
$headers = @{ "Content-Type" = "application/json"} $data = @{ "level" = "error" "message" = "Failed to connect to DB" "resourceId" = "server-1234" "timestamp" = "2023-09-15T08:00:00Z" "traceId" = "abc-xyz-123" "spanId" = "span-456" "commit" = "5e5342f" "metadata" = @{ "parentResourceId" = "server-0987" } } Invoke-RestMethod -Uri "http://localhost:3000/logs" -Method Post -Headers $headers -Body ($data | ConvertTo-Json)
curl -X POST -H "Content-Type: application/json" -d '{ "level": "error", "message": "Failed to connect to DB", "resourceId": "server-1234", "timestamp": "2023-09-15T08:00:00Z", "traceId": "abc-xyz-123", "spanId": "span-456", "commit": "5e5342f", "metadata": { "parentResourceId": "server-0987" } }' http://localhost:3000/logs
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
Distributed under the MIT License. See LICENSE.txt
for more information.