Need help with time conditions in BASH scripts

alex.lin

New Member
Credits
13
Hi folks, I'm going to need help, and I hope someone can share experience with me.

So, the task is to create a bash script which will parse the JSON data from a REST API (which totals a number of errors at a certain period of time). The output is to get the number of errors in the last 5 minutes. Does anybody know how to handle it? Any information will be much appreciated.
 


JasKinasis

Well-Known Member
Credits
783
How are you getting the details of the errors?
Which API are you using?
Which API functions are you using to get the error information?
And what does each of these functions return?
e.g.
What fields/information are in a single record for an error?

There’s no real way of knowing how to do it without knowing more about what you’re using.

Are you planning on getting all error records from the API and then filtering out those that were only from the last 5 minutes?
If so, that could be a particularly heavy way of getting the error messages from the last 5 minutes.

Does the API have a way of being able to access error records by specifying certain criteria? E.g. from the last 5 minutes? If so, you probably won’t need too much of a script.
If you can pull only the relevant error logs from the last 5 minutes from the API, it should just be a case of parsing the json data that is returned and counting the number of records.

Without knowing what functionality the API has, or what it will return, it’s difficult to know what you’re going to need script-wise.
 


Members online


Top