Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Provide regex for "resource" in protopayload

I am trying to filter logs based on resource mapping using "protoPayload.resource" property. It works fine if I specify the exact resource name.

metadata.serviceName="appengine.googleapis.com"
metadata.labels."appengine.googleapis.com/module_id"={module}
metadata.labels."appengine.googleapis.com/version_id"={version}
log="appengine.googleapis.com/request_log"
protoPayload.resource = ***********

How to supply a regex for this property to filter out logs?

Maven dependency for logging api:

 <dependency>
        <groupId>com.google.apis</groupId>
        <artifactId>google-api-services-logging</artifactId>
        <version>v2beta1-rev9-1.21.0</version>
    </dependency>
like image 659
akgaur Avatar asked Oct 24 '25 15:10

akgaur


2 Answers

The Stackdriver Logging API does not currently support regular expressions.

It does, however, support a "has" operator through using a : instead of an = in your filter expression, e.g. path.to.field: "value". This matches substrings of the actual value in a case-insensitive fashion, which is most of what people typically used it for anyway.

See also: Write effective advanced filters

If the "has" operator doesn't accomplish your goal, consider filing feedback through the speech bubble button in the top right of the Cloud Console providing details of your use case and what you're ultimately trying to accomplish, and we'll incorporate that feedback as we plan the future direction of the product.

like image 63
Ben Rister Avatar answered Oct 26 '25 15:10

Ben Rister


The advanced queries documentation page lists the regex operator =~ Further, there is a dedicated documentation page specifically for the regular expression use in the new log viewer. As of 2020-09-13, this page is marked as "new"

like image 30
Michael Avatar answered Oct 26 '25 17:10

Michael