google-cloud-platformgoogle-cloud-stackdriver

How do I build a query using MQL to fetch data from Log based metric?


I have a log based metric where the resource type is not defined. How do I build a MQL query for a log based metric for the following:

logging.googleapis.com/user/MY_METRIC

If I use the "configuration view" in Metric Explorer the data shows. However when I switch to MQL I can't seem to create the correct filter.

fetch logging.googleapis.com/user/MY_METRIC gives me syntax errors for resource type not defined.


Solution

  • If the logs come from a VM then the resource type must be selected as compute.

    Resource type must be declared.