Advanced filtering in the log explorer #22640
TheOtherBrian1
announced in
Troubleshooting
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Querying the Logs
For greater control over the Logs, consider using the Query Explorer.
Basic Queries
Filtering with regex
The Logs use BigQuery Style Regex with the regex_contains function. In its most basic form, it will just check if a string is present in a specified column.
However, there are multiple regex rules that you should consider using:
Find messages that start with a phrase
^
only looks for values at the start of a stringFind messages that end with a phrase:
$
only looks for values at the end of the stringIgnore case sensitivity:
(?i)
ignores capitalization for all proceeding charactersWildcards in regex:
.
can represent any string of charactersAlphanumeric ranges in regex:
[1-9a-zA-Z]
finds any strings with only numbers and lettersRepeated values in regex:
x*
zero or more xx+
one or more xx?
zero or one xx{4,}
four or more xx{3}
exactly 3 xEscaping reserved characters:
\.
interpreted as period.
instead of as a wildcardor
statements in regex:x|y
any string withx
ory
presentand/or/not statements in SQL:
and
,or
, andnot
are all native terms in SQL and can be used in conjunction with regex to filter resultsUnderstanding field references
Each product has its own log table. Unlike traditional tables, log tables contain nested fields. The first and most accessible fields are always the event_message and timestamp. At deeper layers are metadata and beyond:
field reference examples from postgres
The
event_message
can be accessed immediately.The
metadata.parsed.user_name
andmetadata.parsed.error_severity
must be unnested in a cross-join. This type of querying is used mostly with JSON and array columns, so it may look unfamiliarComplete Example
Filter Postgres errors encountered by the auth server
Limitations
Log tables cannot be joined together
All product tables are independent of each other. They lack connections (like foreign keys) to link them, making table joins impossible. This means merging PostgREST logs with Postgres logs directly wouldn't work.
with
andilike
statements cannot be usedThe query editor parses logs for optimization. The parser does not yet support
with
and subquery statements. Furthermoreilike
is not supported by BigQuery's variant of SQLBeta Was this translation helpful? Give feedback.
All reactions