Search code examples
filtertimestampstackdrivergoogle-cloud-stackdriver

Stackdriver Logging Advanced Filter Using Current Date/Time


I am trying to create an exclusion filter which would exclude any logs older than 7 days.

It seems with timestamp, you must specify the actual date and time for this to work -- rather than use something like timezone.now() - timedelta(days=7)

Can anyone tell me if this is possible?


Solution

  • Searching by time from the filter expression is usually achieved by absolute timestamps. At present, computing relative time is not supported in advanced filter. You can determine timestamps in RFC 3339 format by using 'date' command from Linux, as per "Choose the right time period" here.

    That being said, there is an internal Feature request filed for to include the relative timestamp ( e.g. "timestamp < now - 7 days" ) on the exclusion filter.