pgoggijr
pgoggijr

Reputation: 434

GCP Logs-Based Monitoring: Trigger an alert when no logs are received

I have an application that I'm setting up logs-based monitoring for. The application will log whenever it completes a certain task. I want to ensure that the application completes this at least once every 6 hours.

I have tried to replicate this rule by configuring monitoring to fire an alert when the metric stays below 1 for the given amount of time.

Unfortunately, when the logs-based metric doesn't receive any logs, it appears to act that there is "no data" instead of a value of 0.

Is it possible to treat segments when no logs are received as a 0 so that the alert will fire?

Screenshot of my metric graph: enter image description here

Screenshot of alert definition: enter image description here You can see that we receive a log for one time frame, but right afterwards the line disappears and an alert isn't triggered.

Upvotes: 3

Views: 2074

Answers (1)

c69
c69

Reputation: 21487

Try using absent_for and MQL based Alert.

The absent_for table operation generates a table with two value columns, active and signal. The active column is true when there is data missing from the table input and false otherwise. This is useful for creating a condition query to be used to alert on the absence of inputs.

Example:

 fetch  gce_instance :: compute.googleapis.com/instance/cpu/usage_time
  | absent_for 8h

Upvotes: 1

Related Questions