-
Notifications
You must be signed in to change notification settings - Fork 499
feat: Add postgres logs error collector to database_observability.postgres component #5080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| Targets []discovery.Target `alloy:"targets,attr"` | ||
| ErrorLogsReceiver loki.LogsReceiver `alloy:"error_logs_receiver,attr,optional"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gaantunes I've done a first pass, my feeling is that we're doing more than needed at this stage, I'll explain:
- I'd focus on producing one single metric,
postgres_errors_total, but change the labels from"severity", "database", "instance"to"database", "instance", "queryid". This seems to be the core of what we'd need to show an error rate (global and per-query). - ignore anything else for now, e.g. no need to parse anything other than query error messages, no need for other metrics IMO. We also don't need to write back to EntryHandler a custom log line, we just need the metric really.
So my ask is to basically to trim it down dramatically and keep it very, very simple as first pass. We can still re-introduce later anything else that seems useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cristiangreco.
Customers have showed interest in knowing what is the exact error in previous feedbacks. If we are already going to parse the logs to have metrics, why not provide this information already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed in our 1:1 this will be split into different PRs to approach the problem iteratively.
|
💻 Deploy preview available (feat: Add postgres logs error collector to database_observability.postgres component): |
|
|
||
| ### `error_logs` | ||
|
|
||
| The `error_logs` collector is always active and processes PostgreSQL error logs in JSON format (requires `log_destination = 'jsonlog'` in PostgreSQL configuration). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| The `error_logs` collector is always active and processes PostgreSQL error logs in JSON format (requires `log_destination = 'jsonlog'` in PostgreSQL configuration). | |
| The `error_logs` collector is always active and processes PostgreSQL error logs in JSON format. | |
| This requires `log_destination = 'jsonlog'` in your PostgreSQL configuration. |
| The `error_logs` collector is always active and processes PostgreSQL error logs in JSON format (requires `log_destination = 'jsonlog'` in PostgreSQL configuration). | ||
| It receives log entries through the component's `forward_to` parameter, extracts error information, maps SQLSTATE codes to human-readable error names, and tracks metrics by error type and severity. | ||
|
|
||
| Unlike other collectors, `error_logs` does not need to be enabled via `enable_collectors` - it automatically processes any PostgreSQL JSON logs that are forwarded to the component. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Unlike other collectors, `error_logs` does not need to be enabled via `enable_collectors` - it automatically processes any PostgreSQL JSON logs that are forwarded to the component. | |
| Unlike other collectors, `error_logs` does not need to be enabled via `enable_collectors`. | |
| It automatically processes any PostgreSQL JSON logs that are forwarded to the component. |
| By default, SQL statements and Personally Identifiable Information (PII) in error log fields are redacted to protect sensitive data. | ||
| This includes: | ||
| - SQL literals in `statement` and `internal_query` fields | ||
| - Data values in `detail` and `context` fields (such as constraint violations, key values, and row data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - Data values in `detail` and `context` fields (such as constraint violations, key values, and row data) | |
| - Data values in `detail` and `context` fields such as constraint violations, key values, and row data |
| This includes: | ||
| - SQL literals in `statement` and `internal_query` fields | ||
| - Data values in `detail` and `context` fields (such as constraint violations, key values, and row data) | ||
| - Parenthesized values in error messages (e.g., `Key (id)=(123)` becomes `Key (id)=(?)`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - Parenthesized values in error messages (e.g., `Key (id)=(123)` becomes `Key (id)=(?)`) | |
| - Parenthesized values in error messages, for example, `Key (id)=(123)` becomes `Key (id)=(?)` |
| | `disable_query_redaction` | `bool` | Disable redaction of SQL queries and PII in error logs. Use with caution in production environments. | `false` | no | | ||
|
|
||
| {{< admonition type="warning" >}} | ||
| Setting `disable_query_redaction` to `true` will expose SQL query parameters, constraint values, and other potentially sensitive information in error logs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Setting `disable_query_redaction` to `true` will expose SQL query parameters, constraint values, and other potentially sensitive information in error logs. | |
| If you set `disable_query_redaction` to `true`, it will expose SQL query parameters, constraint values, and other potentially sensitive information in error logs. |
PR Description
Implementing a Postgres logs parser focused on error collection, with the following capabilities:
Which issue(s) this PR fixes
Notes to the Reviewer
PR Checklist