Skip to content

Commit 8e39946

Browse files
authored
filebeat/filestream: default include_file_fingerprint to true (#51793)
Soft-revert of #50129, which made log.file.fingerprint in published events opt-in via include_file_fingerprint (default false). Removing the field by default is technically a breaking change that we don't understand fully yet. Users who want to save network, indexing, and storage costs at scale can set include_file_fingerprint to false. A still-growing fingerprint is never published. After further benchmarks we can re-consider if we want to make the breaking change and flip the default to false. Reclassify the changelog fragment from breaking-change to enhancement.
1 parent 768b58b commit 8e39946

11 files changed

Lines changed: 30 additions & 80 deletions

File tree

changelog/fragments/1776242399-filestream-include-file-fingerprint-opt-in.yaml

Lines changed: 0 additions & 54 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
kind: enhancement
2+
summary: "Filestream: include_file_fingerprint controls log.file.fingerprint in events."
3+
description: |
4+
Add an `include_file_fingerprint` option (default: `true`) to the filestream
5+
input. By default `log.file.fingerprint` is included in published events when
6+
`file_identity.fingerprint` is configured, preserving the previous behaviour.
7+
Set `include_file_fingerprint: false` to omit the field and reduce network,
8+
indexing, and storage costs at scale. A still-growing fingerprint is never
9+
added to events; only the completed SHA-256 is published.
10+
component: filebeat
11+
pr: https://github.com/elastic/beats/pull/50129
12+
issue: https://github.com/elastic/beats/issues/50724

docs/reference/filebeat/filebeat-input-filestream.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ This option is not supported on Windows.
723723
```yaml {applies_to}
724724
stack: ga 9.5.0
725725
```
726-
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.
726+
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.
727727

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

filebeat/_meta/config/filebeat.inputs.reference.yml.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,10 @@ filebeat.inputs:
463463
#include_file_owner_group_name: false
464464
465465
# Whether to add log.file.fingerprint to published events. Only takes
466-
# effect when file_identity.fingerprint is configured. Defaults to false.
466+
# effect when file_identity.fingerprint is configured. Defaults to true.
467467
# The file path (log.file.path) is always present in events regardless
468468
# of this setting.
469-
#include_file_fingerprint: false
469+
#include_file_fingerprint: true
470470
471471
# Optional additional fields. These fields can be freely picked
472472
# to add additional information to the crawled log files for filtering

filebeat/filebeat.reference.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,10 +882,10 @@ filebeat.inputs:
882882
#include_file_owner_group_name: false
883883

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

890890
# Optional additional fields. These fields can be freely picked
891891
# to add additional information to the crawled log files for filtering

filebeat/input/filestream/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ type config struct {
7171
IncludeFileOwnerName bool `config:"include_file_owner_name"`
7272
IncludeFileOwnerGroupName bool `config:"include_file_owner_group_name"`
7373
// IncludeFileFingerprint controls whether log.file.fingerprint is added
74-
// to published events. Disabled by default.
74+
// to published events. Enabled by default.
7575
IncludeFileFingerprint bool `config:"include_file_fingerprint"`
7676

7777
// -1 means that registry will never be cleaned, disabling clean_inactive.
@@ -162,7 +162,7 @@ func defaultConfig() config {
162162
ReadUntilEOF: loginp.DefaultReadUntilEOFConfig(),
163163
IncludeFileOwnerName: false,
164164
IncludeFileOwnerGroupName: false,
165-
IncludeFileFingerprint: false,
165+
IncludeFileFingerprint: true,
166166
CleanInactive: -1,
167167
CleanRemoved: true,
168168
HarvesterLimit: 0,

filebeat/input/filestream/input.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -558,12 +558,9 @@ func (inp *filestream) open(
558558

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

561-
// log.file.fingerprint is opt-in (include_file_fingerprint, default false).
562-
// A growing file's raw fingerprint material is the RAW hex of the file
563-
// header, not a SHA-256, so publishing it would expose file content. Only
564-
// publish the SHA-256 once the fingerprint is complete; below the threshold
565-
// we publish no fingerprint at all. A renamed file may still carry the old
566-
// path until the next open — that pre-existing limitation is unchanged here.
561+
// Only publish the completed SHA-256. A still-growing fingerprint's material
562+
// is the raw hex of the file header, not a hash, so publishing it would
563+
// expose file content.
567564
var fingerprint string
568565
if inp.includeFileFingerprint && fs.desc.Fingerprint.Complete() {
569566
fingerprint = fs.desc.Fingerprint.Sum

filebeat/tests/integration/filestream_other_test.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,29 +117,27 @@ func TestFilestreamIncludeFileFingerprint(t *testing.T) {
117117
} `json:"log"`
118118
}
119119

120+
const fingerprintIdentity = "file_identity.fingerprint: ~\n prospector.scanner:\n fingerprint.enabled: true"
121+
120122
tests := []struct {
121123
name string
122-
identityConfig string
123124
includeFileFingerprint string
124125
expectFingerprint bool
125126
}{
126127
{
127128
name: "include_file_fingerprint_true",
128-
identityConfig: "file_identity.fingerprint: ~\n prospector.scanner:\n fingerprint.enabled: true",
129129
includeFileFingerprint: "include_file_fingerprint: true",
130130
expectFingerprint: true,
131131
},
132132
{
133133
name: "include_file_fingerprint_false",
134-
identityConfig: "file_identity.fingerprint: ~\n prospector.scanner:\n fingerprint.enabled: true",
135134
includeFileFingerprint: "include_file_fingerprint: false",
136135
expectFingerprint: false,
137136
},
138137
{
139138
name: "include_file_fingerprint_absent",
140-
identityConfig: "file_identity.fingerprint: ~\n prospector.scanner:\n fingerprint.enabled: true",
141139
includeFileFingerprint: "",
142-
expectFingerprint: false,
140+
expectFingerprint: true,
143141
},
144142
}
145143

@@ -174,7 +172,7 @@ output:
174172
path: ${path.home}
175173
filename: "output"
176174
rotate_on_startup: false
177-
`, tc.name, logFilePath, tc.identityConfig, tc.includeFileFingerprint)
175+
`, tc.name, logFilePath, fingerprintIdentity, tc.includeFileFingerprint)
178176

179177
filebeat.WriteConfigFile(cfg)
180178
filebeat.Start()
@@ -186,10 +184,7 @@ output:
186184
var failedFilePath []int
187185
var failedFingerprint []int
188186
for i, event := range events {
189-
if tc.expectFingerprint && event.Log.File.Fingerprint == nil {
190-
failedFingerprint = append(failedFingerprint, i)
191-
}
192-
if !tc.expectFingerprint && event.Log.File.Fingerprint != nil {
187+
if (event.Log.File.Fingerprint != nil) != tc.expectFingerprint {
193188
failedFingerprint = append(failedFingerprint, i)
194189
}
195190

filebeat/tests/integration/testdata/run_as_filestream/fingerprint.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ filebeat.inputs:
66
fingerprint.enabled: true
77
paths:
88
- {{ .logfile }}
9-
include_file_fingerprint: true
109

1110
output.file:
1211
path: ${path.home}

x-pack/filebeat/filebeat.reference.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2582,10 +2582,10 @@ filebeat.inputs:
25822582
#include_file_owner_group_name: false
25832583

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

25902590
# Optional additional fields. These fields can be freely picked
25912591
# to add additional information to the crawled log files for filtering

0 commit comments

Comments
 (0)