1
votes

Hi I have two projects project-A and project-B. I have created a monitoring workspace in project-A and added project-B in that workspace. I want to create alerts from log based metrics . I have created the log based metrics in project-A and created an alert from it but it wouldn't trigger for project-B it works for project-A only. For log based metrics my query is -

 "resource.type="build"
  severity=ERROR" 

so alert triggers when cloudbuild fails in project-A but not when it fails in project-B. Is it possible to do that?

1
Have you tried creating the alert directly in project B? I'm thinking that if the logs-based metric is showing up in project A, maybe you can write an alert out of this metric directly in monitoring. I will try to replicate this and see if I can figure it out. But can you add an example of the metrics you're using? Maybe a Minimal, Reproducible Example can help to begin with. - Judith Guzman
We could do that but i don't want to create monitoring workspace in project-B as i have already added project project-B in project-A workspace. So for log based metrics my query is - "resource.type="build" severity=ERROR" so alert triggers when cloudbuild fails in project-A but not when it fails in project-B. - Abhinav
Just as a kind reminder take a look here stackoverflow.com/help/someone-answers and if you find my answer useful, please consider upvoting/accepting it, thank you! - Jose Luis Delgadillo

1 Answers

1
votes

Per the information you shared in your question, you have added a Cloud Project-B to the metrics scope under your Project-A. And you want to create alerts from log based metrics for both projects.

It seems that you are expecting to see the information from your Project-B in the alerts from your Project-A.

The problem is that Logs-based metrics applies only to a single Google Cloud project. Additionally it is based on logs, and you only added Project-B to the metrics scope, from your Monitoring, you have to take into account that Monitoring and Logging are two different tools.

But if you want that alert to work for both projects and not only for project A, you need to create your metric also in the Project-B, in your case is should be

"resource.type="build" 
severity=ERROR"

Then taking into consideration that the metric is globally resource you can use this metric to be added into your Edit alerting policy in your Project-A In this way you will be able to see the information from your Project-B in your monitoring workspace in project-A.