Skip to content

Commit

Permalink
Cherry-pick elastic#18948 to 7.7: Filebeat: Fix o365 module issues (e…
Browse files Browse the repository at this point in the history
…lastic#19063)

* Filebeat: Fix o365 module issues (elastic#18948)

- Fix scary data-loss warning on startup
- Avoid API errors being processed by the JS pipeline
- Fix dissect error about overiding client.port
- Fix module passing API settings to the input
- Document max_period using the right units

(cherry picked from commit b99a73c)
  • Loading branch information
adriansr committed Jun 9, 2020
1 parent c7aed35 commit e8629e8
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fixed `cloudfoundry.access` to have the correct `cloudfoundry.app.id` contents. {pull}17847[17847]
- Fixing `ingress_controller.` fields to be of type keyword instead of text. {issue}17834[17834]
- Fixed typo in log message. {pull}17897[17897]
- Fix `o365` module ignoring `var.api` settings. {pull}18948[18948]

*Heartbeat*

Expand Down
2 changes: 1 addition & 1 deletion x-pack/filebeat/filebeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ filebeat.modules:
# authentication_endpoint: "https://login.microsoftonline.us/"
# resource: "https://manage.office365.us"
#
# max_retention: 7d
# max_retention: 168h
# max_requests_per_minute: 2000
# poll_interval: 3m

Expand Down
5 changes: 1 addition & 4 deletions x-pack/filebeat/input/o365audit/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,7 @@ func (s *stateStorage) Load(key stream) (cursor, error) {
}
cur, err := s.persister.Load(key)
if err != nil {
if err != errStateNotFound {
return cur, err
}
cur = newCursor(key, time.Time{})
return newCursor(key, time.Time{}), err
}
return cur, s.saveUnsafe(cur)
}
Expand Down
8 changes: 2 additions & 6 deletions x-pack/filebeat/input/o365audit/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,14 @@ func TestNoopState(t *testing.T) {
t.Run("new state", func(t *testing.T) {
st := newStateStorage(noopPersister{})
cur, err := st.Load(myStream)
if !assert.NoError(t, err) {
t.Fatal(err)
}
assert.Equal(t, errStateNotFound, err)
empty := newCursor(myStream, time.Time{})
assert.Equal(t, empty, cur)
})
t.Run("update state", func(t *testing.T) {
st := newStateStorage(noopPersister{})
cur, err := st.Load(myStream)
if !assert.NoError(t, err) {
t.Fatal(err)
}
assert.Equal(t, errStateNotFound, err)
advanced := cur.TryAdvance(content{
Type: tn,
ID: "1234",
Expand Down
2 changes: 1 addition & 1 deletion x-pack/filebeat/module/o365/_meta/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@
# authentication_endpoint: "https://login.microsoftonline.us/"
# resource: "https://manage.office365.us"
#
# max_retention: 7d
# max_retention: 168h
# max_requests_per_minute: 2000
# poll_interval: 3m
3 changes: 2 additions & 1 deletion x-pack/filebeat/module/o365/audit/config/input.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ content_type:
{{ if .api }}
api:
{{ range $k, $v := .api }}
- {{ $k }}: {{ $v -}}
{{ $k }}: {{ $v -}}
{{ end }}
{{ end }}

Expand Down Expand Up @@ -49,6 +49,7 @@ processors:
- 2006-01-02T15:04:05
{{ end }}
- script:
when.has_fields: ['o365audit']
lang: javascript
id: o365audit_script
file: ${path.home}/module/o365/audit/config/pipeline.js
Expand Down
5 changes: 4 additions & 1 deletion x-pack/filebeat/module/o365/audit/config/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,10 @@ function AuditProcessor(tenant_names, debug) {
tokenizer: '[%{_ip}]:%{port}',
field: 'client.address',
target_prefix: 'client',
'when.contains.client.address': ']:',
'when.and': [
{'not.has_fields': ['client._ip', 'client.port']},
{'contains.client.address': ']:'},
],
}));
builder.Add("extractClientIPv4Port", new processor.Dissect({
tokenizer: '%{_ip}:%{port}',
Expand Down
2 changes: 1 addition & 1 deletion x-pack/filebeat/modules.d/o365.yml.disabled
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@
# authentication_endpoint: "https://login.microsoftonline.us/"
# resource: "https://manage.office365.us"
#
# max_retention: 7d
# max_retention: 168h
# max_requests_per_minute: 2000
# poll_interval: 3m

0 comments on commit e8629e8

Please sign in to comment.