-
Notifications
You must be signed in to change notification settings - Fork 1
FEATURE:: Adding -oaddFieldsPosition flag to capture fields position #15
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: master
Are you sure you want to change the base?
Conversation
src/parser.c
Outdated
| ln_recordfieldposition(npb, "DeviceVendor", iHdrStart, i-1); | ||
| iHdrStart = i; | ||
| CHKR(cefGetHdrField(npb, &i, (value == NULL) ? NULL : &product)); | ||
| ln_recordfieldposition(npb, "DeviceProduct", iHdrStart, i-1); | ||
| iHdrStart = i; | ||
| CHKR(cefGetHdrField(npb, &i, (value == NULL) ? NULL : &version)); | ||
| ln_recordfieldposition(npb, "DeviceVersion", iHdrStart, i-1); | ||
| iHdrStart = i; | ||
| CHKR(cefGetHdrField(npb, &i, (value == NULL) ? NULL : &sigID)); | ||
| ln_recordfieldposition(npb, "SignatureID", iHdrStart, i-1); | ||
| iHdrStart = i; | ||
| CHKR(cefGetHdrField(npb, &i, (value == NULL) ? NULL : &name)); | ||
| ln_recordfieldposition(npb, "Name", iHdrStart, i-1); | ||
| iHdrStart = i; | ||
| CHKR(cefGetHdrField(npb, &i, (value == NULL) ? NULL : &severity)); | ||
| ln_recordfieldposition(npb, "Severity", iHdrStart, i-1); |
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.
i-1 ?
isn't it i+1 ?
And I don't think all fields are 1 char long
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.
I tried with i-1. It works great.
| if (npb == NULL || npb->fieldposition == NULL || npb->field_path == NULL || fieldName == NULL) { | ||
| return; | ||
| } | ||
| if (fieldName[0] == '.' && fieldName[1] == '\0') { |
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.
why not?
| if (fieldName[0] == '.' && fieldName[1] == '\0') { | |
| if (fieldName[0] == '.' && fieldName[1] == NULL) { |
src/pdag.h
Outdated
| struct json_object *fieldposition; /**< field logspan data */ | ||
| struct json_object *field_path; /**< field logspan path stack */ |
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.
wrong indentation
Adding -oaddFieldsPosition flag to liblognorm
The -oaddFieldsPosition flag is made to enable the tracking of the position of each field's value in the input log.
The output is a new field under "metadata" which has the same structure as the base fields but the values are replaced with an array of two indices.
Example
A
__fieldpositionfield is also added under each new nested level of json so as to track the whole position of the group.For example here, the field __fieldposition was added under
metadata.fields_position.parent_dataand says that theparent_datafield started at index 5 and ended at index 944.Limitations
This feature does not work for the fields created by the following types: