Skip to content
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

Merged
merged 2 commits into from
Jul 29, 2020

Conversation

marc-gr
Copy link
Contributor

@marc-gr marc-gr commented Jul 29, 2020

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

  • My code follows the style guidelines of this project
    - [ ] 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 tests that prove my fix is effective or that my feature works
    - [ ] I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Logs

Logs that did show the bug

"caused_by":{"type":"illegal_argument_exception","reason":"failed to parse date field [2020/07/28 04:59:59 UTC] with format [strict_date_optional_time||epoch_millis]","caused_by":{"type":"date_time_parse_exception","reason":"date_time_parse_exception: Failed to parse with all enclosed parsers"

@elasticmachine
Copy link
Collaborator

Pinging @elastic/siem (Team:SIEM)

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Jul 29, 2020
Comment on lines 450 to 471
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);
};
};
Copy link
Contributor

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.

@elasticmachine
Copy link
Collaborator

elasticmachine commented Jul 29, 2020

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #20308 updated]

  • Start Time: 2020-07-29T13:24:53.851+0000

  • Duration: 54 min 31 sec

Test stats 🧪

Test Results
Failed 0
Passed 2434
Skipped 385
Total 2819

Copy link
Contributor

@adriansr adriansr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New changes LGTM

@marc-gr marc-gr merged commit 953d067 into elastic:master Jul 29, 2020
@marc-gr marc-gr deleted the fix_gsuite_date_parsing branch July 29, 2020 14:27
marc-gr added a commit to marc-gr/beats that referenced this pull request Jul 29, 2020
…lastic#20308)

* Transform all dates to timestamp with processor

* Change parse date function to create a chain

(cherry picked from commit 953d067)
marc-gr added a commit to marc-gr/beats that referenced this pull request Jul 29, 2020
…lastic#20308)

* Transform all dates to timestamp with processor

* Change parse date function to create a chain

(cherry picked from commit 953d067)
@marc-gr marc-gr added the v7.9.0 label Jul 29, 2020
marc-gr added a commit that referenced this pull request Jul 29, 2020
…20308) (#20319)

* Transform all dates to timestamp with processor

* Change parse date function to create a chain

(cherry picked from commit 953d067)
marc-gr added a commit that referenced this pull request Jul 29, 2020
…20308) (#20318)

* Transform all dates to timestamp with processor

* Change parse date function to create a chain

(cherry picked from commit 953d067)
v1v added a commit to v1v/beats that referenced this pull request Jul 30, 2020
…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)
  ...
melchiormoulin pushed a commit to melchiormoulin/beats that referenced this pull request Oct 14, 2020
…lastic#20308)

* Transform all dates to timestamp with processor

* Change parse date function to create a chain
leweafan pushed a commit to leweafan/beats that referenced this pull request Apr 28, 2023
…lastic#20308) (elastic#20319)

* Transform all dates to timestamp with processor

* Change parse date function to create a chain

(cherry picked from commit 8eb5d14)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants