-
Notifications
You must be signed in to change notification settings - Fork 490
SCL parser for PostgreSQL csvlog #4586
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
Conversation
af83c5c
to
072dd64
Compare
bde74f2
to
8173514
Compare
With #4680 this can be improved a lot by using csv-parser() to type up the extracted values. |
8173514
to
47e1886
Compare
As sometimes not every field is filled (e.g, |
47e1886
to
eda8da6
Compare
Build FAILURE |
05e9413
to
299fac3
Compare
modules/csvparser/csvparser.c
Outdated
static gboolean | ||
_should_drop_message(CSVParser *self) | ||
{ | ||
return self->drop_invalid || (self->template_options.on_error & ON_ERROR_DROP_MESSAGE); |
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.
We could just change the drop-invalid()
option to set self->template_options.on_error
and remove the self->drop_invalid
bool. This would clean up the code I think. Maybe we could even deprecate the usage of drop-invalid()
in favor of on-error()
.
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.
Absolutely, thanks, at the moment I just got rid of the drop_invalid
field, I think a separate deprecation PR might be more suitable, what do you think?
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.
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.
Hmm there's another case for drop_invalid, where the number of parsed columns is less than the count of expected fields. So it's not just the type casting that can cause the csv-parser() to drop an input.
I also find it suspicious at first sight that a template on-error flag is affecting csv-parser() type casting, which is not using templates?
I may have missed a beat on the patch though.
299fac3
to
50c749f
Compare
50c749f
to
f1322d6
Compare
modules/csvparser/csvparser.c
Outdated
GError *error = NULL; | ||
|
||
if (self->drop_invalid && !type_cast_validate(current_value, current_column->type, &error)) | ||
if (!_process_column(self, scanner, msg, column_l, key_scratch, _key_formatter)) |
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.
we should not pass the GList iterator here, passing current_column seems better.
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 _key_formatter could be also pushed into the _process_column() function, removing yet another argument.
I think adding LogTemplateOptions as a whole is a mistake. csv-parser doesn't use templates at all, and type hinting is a lower level concept. I understand that the on-error() is now coupled with template options but we should decouple that instead and only use this one option instead of the whole lot. Also I think the user visible option is named incorrectly. It should be on-type-error() or something like that. When used as a global option it's really not intuitive what it does. |
Thanks Bazsi! I am more than happy to do the decoupling (separate PR for sure), what I am unsure about is to where it should go once decoupled. Do you have something in mind? |
f1322d6
to
57427eb
Compare
Build FAILURE |
57427eb
to
cc5b0ee
Compare
Build FAILURE |
6f68be1
to
d315518
Compare
Signed-off-by: Szilard Parrag <szilard.parrag@axoflow.com>
Signed-off-by: Szilard Parrag <szilard.parrag@axoflow.com>
d315518
to
49fda7f
Compare
This Pull Request introduces config grammar changessyslog-ng/c4c127aeaa3258ca8a90b58a684bf764e33d8f57 -> bazsi/scl-pgsql-parser --- a/parser
+++ b/parser
csv-parser(
+ on-type-error(<string>)
)
|
Signed-off-by: Szilard Parrag <szilard.parrag@axoflow.com>
…ack options Signed-off-by: Szilard Parrag <szilard.parrag@axoflow.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
Signed-off-by: Szilard Parrag <szilard.parrag@axoflow.com>
Signed-off-by: Szilard Parrag <szilard.parrag@axoflow.com>
49fda7f
to
96b82cf
Compare
add a new parser to process CSV log formatted by PostgreSQL (https://www.postgresql.org/docs/current/runtime-config-logging.html). The CSV format is extracted into a set of name-value pairs.