elastic / elastic/integrations

[Journald] `host.hostname` is overwritten by the default `add_host_metadata` processor run in Filebeat

Open
#11,717 2 comments 0 reactions 0 assignees View on GitHub
Integration:journald Stalled Team:Elastic-Agent-Data-Plane
Dominant language
Handlebars
Stars
333
Forks
647
Avg merge
3d 4h
Merged PRs (30d)
209

Description

When using the journald input from Filebeat (currently used by the "Custom Journald logs" and the System integration once https://github.com/elastic/integrations/pull/11618), the field `host.hostname` can be overwritten by the `add_host_metadata` processor that runs by default on Beats running under Elastic-Agent.

The default processors added by the Elastic-Agent (and not shown in the policy/Fleet UI are):
```yaml
processors:
- add_host_metadata:
when.not.contains.tags: forwarded
- add_cloud_metadata: ~
- add_docker_metadata: ~
- add_kubernetes_metadata: ~
```

This is added by [this piece of code from Beats](https://github.com/elastic/beats/blob/ce4a17b3a960f779d61a6898f97080bbd2423033/x-pack/filebeat/cmd/root.go#L46-L64) when running under Elastic-Agent:
```go
func defaultProcessors() []mapstr.M {
// processors:
// - add_host_metadata:
// when.not.contains.tags: forwarded
// - add_cloud_metadata: ~
// - add_docker_metadata: ~
// - add_kubernetes_metadata: ~

return []mapstr.M{
{
"add_host_metadata": mapstr.M{
"when.not.contains.tags": "forwarded",
},
},
{"add_cloud_metadata": nil},
{"add_docker_metadata": nil},
{"add_kubernetes_metadata": nil},
}
}
```
That is later called during startup.

One way to avoid `host.hostname` being overwritten is to add the `forwarded` tag to the events produced by the journald input (or any input).

Currently the `forwarded` tag **is not added by default**.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.