-
Notifications
You must be signed in to change notification settings - Fork 153
Description
I want to parse (primarily) two type of lines in a log. One with DB error and one with successful query result as below.
[07:17:44.496832 2022-05-01] XYZ table loaded 105 records
[07:56:21.123456 2022-05-01] SQL error: Query select * from XYZ_table failed
Based on these two metric, i want to raise DB alert notifications. For this i first need to get the last log line having either 'SQL error ...', or 'XYZ table loaded...' and then decide whether we an alert needs to be raised.
However, i am facing issue achieving the same.
How to get the last line either having 'SQL error ...', or 'XYZ table loaded...'? Note that its possible to have some other log line in which we are not interested.
I used a classic condition (Last(A) >= 1) || (Last(B) == 0) in Grafana where A is 'SQL error..' pattern and B is 'XYZ table loaded...'. But this does not work as first condition once true, will always remain so.
I have been stuck on this for quite sometime now and any help will really be appreciated.