Skip to content

Commit

Permalink
Refactor kubernetes autodiscover to avoid skipping short-living pods (e…
Browse files Browse the repository at this point in the history
…lastic#24742)

Refactor logic in kubernetes autodiscover that decides when
to generate events to try to address issues with short-living
containers.

Kubernetes autodiscover can generate events without network
information now (without host or port/ports). This allows to generate
events for pods that haven't started yet, or have succeeded/failed
before generating a running event. These events still include the
container id, so they can be used to collect logs. Still, no start event
is generated if no pod ip and no container ids are available.

Some helpers have been added to obtain relevant information from
pods and their containers.

Some additional small refactors are done to improve readability.
  • Loading branch information
jsoriano authored Apr 20, 2021
1 parent 8cf8f51 commit b4b6e6e
Show file tree
Hide file tree
Showing 6 changed files with 722 additions and 284 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Allow cgroup self-monitoring to see alternate `hostfs` paths {pull}24334[24334]
- Add `expand_keys` to the list of permitted config fields for `decode_json_fields` {24862}[24862]
- Fix 'make setup' instructions for a new beat {pull}24944[24944]
- Fix discovery of short-living and failing pods in Kubernetes autodiscover {issue}22718[22718] {pull}24742[24742]
- Fix inode removal tracking code when files are replaced by files with the same name {pull}25002[25002]
- Fix `mage GenerateCustomBeat` instructions for a new beat {pull}17679[17679]
- Fix bug with annotations dedot config on k8s not used {pull}25111[25111]
Expand Down
5 changes: 0 additions & 5 deletions filebeat/autodiscover/builder/hints/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ func (l *logHints) CreateConfig(event bus.Event, options ...ucfg.Option) []*comm
return []*common.Config{}
}

host, _ := event["host"].(string)
if host == "" {
return []*common.Config{}
}

if inputConfig != nil {
configs := []*common.Config{}
for _, cfg := range inputConfig {
Expand Down
Loading

0 comments on commit b4b6e6e

Please sign in to comment.