Discovering and Interpreting API Errors in the Logs #22849
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
-
Navigating the API logs:
The Database API is powered by a PostgREST web-server, recording every request to the API Edge Network logs. To precisely navigate them, use the Log Explorer. These logs are managed through Logflare and can be queried with a subset of BigQuery SQL syntax.
The log table that contains API requests is
edge_logs
.Notably, it contains:
The request and response columns are arrays in the metadata field and must be unnested. This is done with a
cross join
.Unnesting example
The most useful fields for debugging are:
Request object
Cloudflare geographic data:
Suggested use cases:
Unnesting example:
IP and browser/environment data:
Suggested use cases:
Unnesting example:
query type and formatting data:
Suggested use cases:
Unnesting example:
Response object
Status code:
Suggested use cases:
Unnesting example:
Finding errors
API Level errors
The
metadata.request.url
contains PostgREST formatted queries.For example, the following call to the JS client:
translates to calling the following endpoint:
You can use regex (Advanced Regex Guide) to find the objects related to your query. Try isolating by:
Example:
PostgREST has an error reference table that you can use to interpret status codes.
Database-level errors
However, some errors that are reported through the Database API occur at the PostgreSQL level. If it is not clear which error occurred you should reference the timestamp of the error and try to see if you can find it in the Postgres logs.
Like PostgREST, PostgreSQL has a reference table for interpreting error codes.
PostgREST server and Cloudflare errors
In some cases, errors may emerge because of Cloudflare or PostgREST server errors. For 500 and above errors, you may want to check your PostgREST logs and the Cloudflare docs.)
Practical examples:
Find All Errors:
Group errors by path and code:
Find requests by region:
Find total requests by IP:
Search frequented query paths by authenticated user:
Beta Was this translation helpful? Give feedback.
All reactions