-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Filebeat][Gsuite] Transform all dates to timestamp with processor #20308
Conversation
Pinging @elastic/siem (Team:SIEM) |
var parseDate = function(field, targetField) { | ||
return function(evt) { | ||
new processor.Timestamp({ | ||
field: field, | ||
target_field: targetField, | ||
timezone: "UTC", | ||
layouts: [ | ||
"2006-01-02T15:04:05Z", | ||
"2006-01-02T15:04:05.999Z", | ||
"2006/01/02 15:04:05 UTC", | ||
], | ||
tests: [ | ||
"2020-02-05T18:19:23Z", | ||
"2020-02-05T18:19:23.599Z", | ||
"2020/07/28 04:59:59 UTC", | ||
], | ||
ignore_missing: true, | ||
}).Run(evt); | ||
|
||
evt.Delete(field); | ||
}; | ||
}; |
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.
Nit:
This pattern is allocating a new Timestamp processor for each event it processes. I think it would make more sense to create a Chain in the outer function.
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.
New changes LGTM
…lastic#20308) * Transform all dates to timestamp with processor * Change parse date function to create a chain (cherry picked from commit 953d067)
…lastic#20308) * Transform all dates to timestamp with processor * Change parse date function to create a chain (cherry picked from commit 953d067)
…ne-2.0 * upstream/master: (29 commits) Add an explicit system test for processes on unix systems (elastic#20320) [Autodiscovery] Ignore ErrInputNotFinished errors in autodiscover config checks (elastic#20305) [CI] Update README.md with CI references (elastic#20316) Add ECK doc links to Heartbeat docs (elastic#20284) [Filebeat] Add export tests to x-pack/filebeat (elastic#20156) feat(ci): support building docker images for PRs (elastic#20323) Update system tests dependency (elastic#20287) [Libbeat] Log debug message if the Kibana dashboard can not be imported from the archive (elastic#12211) (elastic#20150) [Filebeat][Gsuite] Transform all dates to timestamp with processor (elastic#20308) Infer types in Prometheus remote_write (elastic#19944) Remove unnecessary restarts of metricsets while using Node autodiscover (elastic#19974) docs: update changelog on master branch (elastic#20259) feat(ci): support storing artifacts for PRs in separate dirs (elastic#20282) [CI] Change upstream reference (elastic#20296) [Filebeat] Updates to Suricata module (elastic#20220) [docs] Fix Windows download link for agent (elastic#20258) [docs] Rename release highlights to what's new (elastic#20255) fix: update the display name of the multibranch job (elastic#20265) [Elastic Agent] Add basic protocol to control Elastic Agent. (elastic#20146) Cisco ASA: Fix message 106100 (elastic#20245) ...
…lastic#20308) * Transform all dates to timestamp with processor * Change parse date function to create a chain
…lastic#20308) (elastic#20319) * Transform all dates to timestamp with processor * Change parse date function to create a chain (cherry picked from commit 8eb5d14)
What does this PR do?
Parse properly date time fields in different formats in gsuite module.
Why is it important?
Not all fields come in the same format, and some of them were not accepted as valid dates. This change proactively parses all date fields with the known incoming formats.
Checklist
- [ ] I have commented my code, particularly in hard-to-understand areas- [ ] I have made corresponding changes to the documentation- [ ] I have made corresponding change to the default configuration files- [ ] I have added an entry inCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Logs
Logs that did show the bug