I want to analyse GCP logs in real time and make alerts from it. Because analysis depends on some aggregations and correlations (example: event A happend less then 10 min from the event B so there should be an alert), the Cloud Logging – Logs Analytics seems as the perfect solution for that. I would like to run scheduled Cloud Function (let say every 5 min) that runs SQL queries on Log bucket and if there is a match it will send an alert.
The problem is I didn’t find it possible when reading the Logging API docs. I found this section: https://cloud.google.com/logging/docs/reference/v2/rpc/google.logging.v2#opsanalyticsquery but it says that this query can be run only run via UI.
Is there any other way around to make Logs Analytics query from cloud function? Or maybe there are some other GCP products better suited for this case?
I also tried making Log Sink to Big Query, but logs in BigQuery arrived with much greater deley then in Log Bucket.