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

533 Views Asked by At

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.

2

There are 2 best solutions below

0
user2962698 On BEST ANSWER

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

Resource type must be declared.

0
Hemanth Kumar On

I have tested in my environment and checked it is mandatory to give the resource type in MQL. This will work.