What is the resource.type for a log-based metric?

2,340 views
Skip to first unread message

Benjamin Neff

unread,
Aug 9, 2019, 5:33:02 PM8/9/19
to Google Stackdriver Discussion Forum
Hello,

I created a log-based metric and want now to create an alert policy for it, but I can't find what should be set for "resource.type" in the "filter" for it. When I create a alert policy manually in the web, it doesn't require a resource, it only sets this:
filter: "metric.type=\"logging.googleapis.com/user/foobar\""

But when I try to create the same alert policy with the same parameters with the deployment-manager, it fails with:

Field alert_policy.conditions[0].condition_threshold.filter had an invalid value of "metric.type=\"logging.googleapis.com/user/foobar\"": must specify a restriction on "resource.type" in the filter; see "https://cloud.google.com/monitoring/api/resources" for a list of available resource types.

So it requires something for "resource.type", but the linked website https://cloud.google.com/monitoring/api/resources doesn't have a resource type for log-based metrics.

Is this a bug and the deployment-manager should allow to create alert policies without "resource.type"? Or what should I use as "resource.type" and why does it work without it when created manually in the web?

... must specify the metric type and optionally may contain restrictions on resource type, resource labels, and metric labels

Regards,
Benjamin

Igor Peshansky

unread,
Aug 9, 2019, 5:46:21 PM8/9/19
to Benjamin Neff, Google Stackdriver Discussion Forum
The documentation probably needs to be updated on the required filter contents, but the monitored resource for the logs-based metrics should be the same as that of the corresponding logs (e.g., if the log is written against gce_instance, the metrics will be against gce_instance as well).
        Igor
-- sent from a mobile device, please excuse tyops and omissns

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Stackdriver Discussion Google Group (google-stackdr...@googlegroups.com) to participate in discussions with other members of the GoogleStackdriver community.
---
You received this message because you are subscribed to the Google Groups "Google Stackdriver Discussion Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-stackdriver-d...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-stackdriver-discussion/fa297eb0-a1a0-42df-9024-b249789a7f32%40googlegroups.com.

Benjamin Neff

unread,
Aug 9, 2019, 7:52:54 PM8/9/19
to Google Stackdriver Discussion Forum
Hi Igor,

Thanks for your response.

I tried that, so the log-based metric has a filter for resource.type="http_load_balancer", but when I try to add this to the alert policy as well, it fails with "The filter contains unknown resource type: http_load_balancer" (and it's true, the list from the first error message with all monitoring resource types doesn't include that resource). 

And it's still weird that the web-ui doesn't need a resource to work, and also doesn't autocomplete a resource.

Regards,
Benjamin

Igor Peshansky

unread,
Aug 9, 2019, 8:01:59 PM8/9/19
to Benjamin Neff, Google Stackdriver Discussion Forum, Mary Koes, Rory Petty
Ah. There are, in fact, two lists of monitored resources: one used by monitoring (https://cloud.google.com/monitoring/api/resources) and one used by logging (https://cloud.google.com/logging/docs/api/v2/resource-list). They share many resources, but the one you need, http_load_balancer, is one of the discrepancies. +Mary Koes to clarify the behavior in those cases. +Rory Petty FYI for the alerting feedback.

        Igor
-- sent from a mobile device, please excuse tyops and omissns
--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Stackdriver Discussion Google Group (google-stackdr...@googlegroups.com) to participate in discussions with other members of the GoogleStackdriver community.
---
You received this message because you are subscribed to the Google Groups "Google Stackdriver Discussion Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-stackdriver-d...@googlegroups.com.

Igor Peshansky

unread,
Aug 9, 2019, 8:47:13 PM8/9/19
to Benjamin Neff, Google Stackdriver Discussion Forum, Mary Koes, Rory Petty
Update: for various historical reasons, logs-based metrics from the http_load_balancer logs are written against the l7_lb_rule monitored resource. You should be able to find your metrics if you constrain to that resource type.
        Igor

Benjamin Neff

unread,
Aug 10, 2019, 1:00:53 AM8/10/19
to Google Stackdriver Discussion Forum
Sidenote: I can't select that in the web-ui, if I select the l7_lb_rule resource, I can't find my log-based metric and if I already selected, my metric, I can't set any resource anymore. So in the web-ui I can only create the policy without resource, but it shows the policy created with the deployment-manager correctly. The same goes with the metric explorer, if I only set my metric, it warns "Selecting a metric without a resource may have performance implications.", but I can't set l7_lb_rule as resource, and if I set the resource, I can't find the metric anymore. It would have helped if the web-ui behaves the same as the API, because I tried to use it to see what I need to send to the API to create what I want.

Regards,
Benjamin


Am Samstag, 10. August 2019 02:47:13 UTC+2 schrieb Igor Peshansky:
Update: for various historical reasons, logs-based metrics from the http_load_balancer logs are written against the l7_lb_rule monitored resource. You should be able to find your metrics if you constrain to that resource type.
        Igor

On Fri, Aug 9, 2019, 8:01 PM Igor Peshansky <ig...@google.com> wrote:
Ah. There are, in fact, two lists of monitored resources: one used by monitoring (https://cloud.google.com/monitoring/api/resources) and one used by logging (https://cloud.google.com/logging/docs/api/v2/resource-list). They share many resources, but the one you need, http_load_balancer, is one of the discrepancies. +Mary Koes to clarify the behavior in those cases. +Rory Petty FYI for the alerting feedback.
        Igor
-- sent from a mobile device, please excuse tyops and omissns

On Fri, Aug 9, 2019, 7:52 PM Benjamin Neff <benj...@coding4coffee.ch> wrote:
Hi Igor,

Thanks for your response.

I tried that, so the log-based metric has a filter for resource.type="http_load_balancer", but when I try to add this to the alert policy as well, it fails with "The filter contains unknown resource type: http_load_balancer" (and it's true, the list from the first error message with all monitoring resource types doesn't include that resource). 

And it's still weird that the web-ui doesn't need a resource to work, and also doesn't autocomplete a resource.

Regards,
Benjamin

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Stackdriver Discussion Google Group (google-stackdriver-discu...@googlegroups.com) to participate in discussions with other members of the GoogleStackdriver community.

---
You received this message because you are subscribed to the Google Groups "Google Stackdriver Discussion Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-stackdriver-discussion+unsub...@googlegroups.com.

Benjamin Neff

unread,
Aug 10, 2019, 1:00:53 AM8/10/19
to Google Stackdriver Discussion Forum
That worked, thanks for your help.


Am Samstag, 10. August 2019 02:47:13 UTC+2 schrieb Igor Peshansky:
Update: for various historical reasons, logs-based metrics from the http_load_balancer logs are written against the l7_lb_rule monitored resource. You should be able to find your metrics if you constrain to that resource type.
        Igor

On Fri, Aug 9, 2019, 8:01 PM Igor Peshansky <ig...@google.com> wrote:
Ah. There are, in fact, two lists of monitored resources: one used by monitoring (https://cloud.google.com/monitoring/api/resources) and one used by logging (https://cloud.google.com/logging/docs/api/v2/resource-list). They share many resources, but the one you need, http_load_balancer, is one of the discrepancies. +Mary Koes to clarify the behavior in those cases. +Rory Petty FYI for the alerting feedback.
        Igor
-- sent from a mobile device, please excuse tyops and omissns

On Fri, Aug 9, 2019, 7:52 PM Benjamin Neff <benj...@coding4coffee.ch> wrote:
Hi Igor,

Thanks for your response.

I tried that, so the log-based metric has a filter for resource.type="http_load_balancer", but when I try to add this to the alert policy as well, it fails with "The filter contains unknown resource type: http_load_balancer" (and it's true, the list from the first error message with all monitoring resource types doesn't include that resource). 

And it's still weird that the web-ui doesn't need a resource to work, and also doesn't autocomplete a resource.

Regards,
Benjamin

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Stackdriver Discussion Google Group (google-stackdriver-discu...@googlegroups.com) to participate in discussions with other members of the GoogleStackdriver community.

---
You received this message because you are subscribed to the Google Groups "Google Stackdriver Discussion Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-stackdriver-discussion+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages