Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
kind: enhancement
summary: "Filestream: include_file_fingerprint controls log.file.fingerprint in events."
description: |
Add an `include_file_fingerprint` option (default: `true`) to the filestream
input. By default `log.file.fingerprint` is included in published events when
`file_identity.fingerprint` is configured, preserving the previous behaviour.
Set `include_file_fingerprint: false` to omit the field and reduce network,
indexing, and storage costs at scale. A still-growing fingerprint is never
added to events; only the completed SHA-256 is published.
component: filebeat
pr: https://github.com/elastic/beats/pull/50129
issue: https://github.com/elastic/beats/issues/50724
2 changes: 1 addition & 1 deletion docs/reference/filebeat/filebeat-input-filestream.md
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ This option is not supported on Windows.
```yaml {applies_to}
stack: ga 9.5.0
```
Controls whether `log.file.fingerprint` is added to published events. Only takes effect when `file_identity.fingerprint` is configured. Defaults to `false`. The file path (`log.file.path`) is always present in events regardless of this setting.
Controls whether `log.file.fingerprint` is added to published events. Only takes effect when `file_identity.fingerprint` is configured. Defaults to `true`. The file path (`log.file.path`) is always present in events regardless of this setting.

### `exclude_lines` [filebeat-input-filestream-exclude-lines]

Expand Down
4 changes: 2 additions & 2 deletions filebeat/_meta/config/filebeat.inputs.reference.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,10 @@ filebeat.inputs:
#include_file_owner_group_name: false

# Whether to add log.file.fingerprint to published events. Only takes
# effect when file_identity.fingerprint is configured. Defaults to false.
# effect when file_identity.fingerprint is configured. Defaults to true.
# The file path (log.file.path) is always present in events regardless
# of this setting.
#include_file_fingerprint: false
#include_file_fingerprint: true

# Optional additional fields. These fields can be freely picked
# to add additional information to the crawled log files for filtering
Expand Down
4 changes: 2 additions & 2 deletions filebeat/filebeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -882,10 +882,10 @@ filebeat.inputs:
#include_file_owner_group_name: false

# Whether to add log.file.fingerprint to published events. Only takes
# effect when file_identity.fingerprint is configured. Defaults to false.
# effect when file_identity.fingerprint is configured. Defaults to true.
# The file path (log.file.path) is always present in events regardless
# of this setting.
#include_file_fingerprint: false
#include_file_fingerprint: true

# Optional additional fields. These fields can be freely picked
# to add additional information to the crawled log files for filtering
Expand Down
4 changes: 2 additions & 2 deletions filebeat/input/filestream/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type config struct {
IncludeFileOwnerName bool `config:"include_file_owner_name"`
IncludeFileOwnerGroupName bool `config:"include_file_owner_group_name"`
// IncludeFileFingerprint controls whether log.file.fingerprint is added
// to published events. Disabled by default.
// to published events. Enabled by default.
IncludeFileFingerprint bool `config:"include_file_fingerprint"`

// -1 means that registry will never be cleaned, disabling clean_inactive.
Expand Down Expand Up @@ -162,7 +162,7 @@ func defaultConfig() config {
ReadUntilEOF: loginp.DefaultReadUntilEOFConfig(),
IncludeFileOwnerName: false,
IncludeFileOwnerGroupName: false,
IncludeFileFingerprint: false,
IncludeFileFingerprint: true,
CleanInactive: -1,
CleanRemoved: true,
HarvesterLimit: 0,
Expand Down
9 changes: 3 additions & 6 deletions filebeat/input/filestream/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,12 +558,9 @@ func (inp *filestream) open(

r = readfile.NewStripNewline(r, inp.readerConfig.LineTerminator)

// log.file.fingerprint is opt-in (include_file_fingerprint, default false).
// A growing file's raw fingerprint material is the RAW hex of the file
// header, not a SHA-256, so publishing it would expose file content. Only
// publish the SHA-256 once the fingerprint is complete; below the threshold
// we publish no fingerprint at all. A renamed file may still carry the old
// path until the next open — that pre-existing limitation is unchanged here.
// Only publish the completed SHA-256. A still-growing fingerprint's material
// is the raw hex of the file header, not a hash, so publishing it would
// expose file content.
var fingerprint string
if inp.includeFileFingerprint && fs.desc.Fingerprint.Complete() {
fingerprint = fs.desc.Fingerprint.Sum
Expand Down
15 changes: 5 additions & 10 deletions filebeat/tests/integration/filestream_other_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,29 +117,27 @@ func TestFilestreamIncludeFileFingerprint(t *testing.T) {
} `json:"log"`
}

const fingerprintIdentity = "file_identity.fingerprint: ~\n prospector.scanner:\n fingerprint.enabled: true"

tests := []struct {
name string
identityConfig string
includeFileFingerprint string
expectFingerprint bool
}{
{
name: "include_file_fingerprint_true",
identityConfig: "file_identity.fingerprint: ~\n prospector.scanner:\n fingerprint.enabled: true",
includeFileFingerprint: "include_file_fingerprint: true",
expectFingerprint: true,
},
{
name: "include_file_fingerprint_false",
identityConfig: "file_identity.fingerprint: ~\n prospector.scanner:\n fingerprint.enabled: true",
includeFileFingerprint: "include_file_fingerprint: false",
expectFingerprint: false,
},
{
name: "include_file_fingerprint_absent",
identityConfig: "file_identity.fingerprint: ~\n prospector.scanner:\n fingerprint.enabled: true",
includeFileFingerprint: "",
expectFingerprint: false,
expectFingerprint: true,
},
}

Expand Down Expand Up @@ -174,7 +172,7 @@ output:
path: ${path.home}
filename: "output"
rotate_on_startup: false
`, tc.name, logFilePath, tc.identityConfig, tc.includeFileFingerprint)
`, tc.name, logFilePath, fingerprintIdentity, tc.includeFileFingerprint)

filebeat.WriteConfigFile(cfg)
filebeat.Start()
Expand All @@ -186,10 +184,7 @@ output:
var failedFilePath []int
var failedFingerprint []int
for i, event := range events {
if tc.expectFingerprint && event.Log.File.Fingerprint == nil {
failedFingerprint = append(failedFingerprint, i)
}
if !tc.expectFingerprint && event.Log.File.Fingerprint != nil {
if (event.Log.File.Fingerprint != nil) != tc.expectFingerprint {
failedFingerprint = append(failedFingerprint, i)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ filebeat.inputs:
fingerprint.enabled: true
paths:
- {{ .logfile }}
include_file_fingerprint: true

output.file:
path: ${path.home}
Expand Down
4 changes: 2 additions & 2 deletions x-pack/filebeat/filebeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2582,10 +2582,10 @@ filebeat.inputs:
#include_file_owner_group_name: false

# Whether to add log.file.fingerprint to published events. Only takes
# effect when file_identity.fingerprint is configured. Defaults to false.
# effect when file_identity.fingerprint is configured. Defaults to true.
# The file path (log.file.path) is always present in events regardless
# of this setting.
#include_file_fingerprint: false
#include_file_fingerprint: true

# Optional additional fields. These fields can be freely picked
# to add additional information to the crawled log files for filtering
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ service:
"log.file.path",
// only present in beats receivers
"log.file.device_id",
"log.file.fingerprint",
}

compareOutputFiles(t, fbFilePath, otelFilePath, ignoredFields)
Expand Down
Loading