Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Gauge metric to find DB connectivity status #176

Open
prem-baranwal opened this issue May 2, 2022 · 1 comment
Open

Use Gauge metric to find DB connectivity status #176

prem-baranwal opened this issue May 2, 2022 · 1 comment

Comments

@prem-baranwal
Copy link

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.

@prem-baranwal
Copy link
Author

Note that i tried to have two conditions in the regex itself using look ahead for 'SQL error' and negative look-around for 'XYZ table loaded...' but that does not work either because the second pattern matches the not-interesting logs as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant