Abhinav
Abhinav

Reputation: 81

Create alerts of for two projects in gcp monitoring workspace

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?

Upvotes: 2

Views: 1421

Answers (1)

Jose Luis Delgadillo
Jose Luis Delgadillo

Reputation: 2468

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.

Upvotes: 2

Related Questions