zino
zino

Reputation: 1612

How can I trigger an alert based on log output?

I am using GCP and want to create an alert after not seeing a certain pattern in the output logs of a process.

As an example, my CLI process will output "YYYY-MM-DD HH:MM:SS Successfully checked X" every second.

I want to know when this fails (indicated by no log output). I am collecting logs using the normal GCP log collector.

Can this be done?

I am creating the alerts via the UI at: https://console.cloud.google.com/monitoring/alerting/policies/create

Upvotes: 1

Views: 1308

Answers (1)

guillaume blaquiere
guillaume blaquiere

Reputation: 75715

You can create an alert based on log metric. For that, create a log based metric in Cloud Logging with the log filter that you want.

Then create an alert, aggregate per minute the metrics and set an alert when the value is below 60.

You won't have an alert for each missing message but based on a minute, you will have an alert when the expected value isn't reached.

Upvotes: 4

Related Questions