An api to parse logs and filter them based on params
- Perform a clone of this repo
git clone https://github.com/arbazsiddiqui/log-parser
- Install the required packages
nvm use && npm install
. - Change the value in config.json to your desired log file.
- Run the server
npm start
. - Open
http://localhost:8080/log
- To run tests use
npm t
Api to fetch logs using query params like timstamp, status code etc.
-
URL
/log?timestampFrom={timestampFrom}×tampTo={timestampTo}&status={statusCode}&route={route}&ip={ip}
-
Method:
GET
-
URL Params
Optional:
timestampFrom=string
Start time of logs to parse in ISO 8601 format. Example :2020-01-01T00:00:00.182Z
timestampTo=string
End time of logs to parse in ISO 8601 format. Example :2020-01-01T00:00:00.182Z
status=integer
Status code of the logs to fetch. Example :200
route=string
Route of the logs to fetch without backslashes. Example :home
ip=string
IP of the logs to fetch. Example :183.187.104.41
-
Success Response:
- Code: 200
Content:[ 2020-01-02T00:06:33.312Z Request received from 111.94.139.169 for /projects ]
- Code: 200
-
Error Response:
- Code: 500 Internal Server Error
Content:{ "message": "Something went wrong" }
- Code: 500 Internal Server Error
-
Sample Curl:
curl --location --request GET 'http://localhost:8080/log?timestampFrom=2020-01-01T00:00:00.182Z×tampTo=2020-01-02T00:00:00.000Z&status=200&route=projects&ip=183.187.104.41' \--data-raw ''