Search code examples
logginggoogle-cloud-platformgoogle-compute-enginemonitoringgoogle-cloud-logging

How to show filtered logs on GCP Monitoring Dashboard


On the Google Cloud monitoring mosaic, we have a card that shows logs. It's able to pre-filter on several fiels, for example the severity field screens logs below warning level as shown below. Is there a similar way filter on text? For example, I want the dashbaord to show only logs that match the text string "foobar". I've tried adding textPayload="foobar" to the Query Editor to no avail. Is this possible?

enter image description here


Solution

  • Based on Sample queries using the Logs Explorer Docs.

    Container error logs for a specific pod containing a POST in the textPayload

    resource.type="k8s_container" AND
    resource.labels.pod_name="POD_NAME" AND
    textPayload:"POST" AND
    severity=ERROR
    

    You can also check the dropdown of error logs to see the code and copy the line to Query Editor for more filter options

    You can check also Logging Query Language for reference