Skip to content

Use Gauge metric to find DB connectivity status #176

@prem-baranwal

Description

@prem-baranwal

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions