Skip to content

Commit

Permalink
Enable compression by default for Elasticsearch outputs (elastic#36681)
Browse files Browse the repository at this point in the history
* Enable compression by default for Elasticsearch outputs

* update config template

* update changelog

* regenerate config templates

* update docs

* make check
  • Loading branch information
faec authored and Scholar-Li committed Feb 5, 2024
1 parent 829abda commit 70cdc44
Show file tree
Hide file tree
Showing 19 changed files with 71 additions and 32 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
==== Breaking changes

*Affecting all Beats*
- The Elasticsearch output now enables compression by default. This decreases network data usage by an average of 70-80%, in exchange for 20-25% increased CPU use and ~10% increased ingestion time. The previous default can be restored by setting the flag `compression_level: 0` under `output.elasticsearch`. {pull}36681[36681]


*Auditbeat*

Expand Down
5 changes: 3 additions & 2 deletions auditbeat/auditbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,9 @@ output.elasticsearch:
# IPv6 addresses should always be defined as: https://[2001:db8::1]:9200
hosts: ["localhost:9200"]

# Set gzip compression level.
#compression_level: 0
# Set gzip compression level. Set to 0 to disable compression.
# The default is 1.
#compression_level: 1

# Configure escaping HTML symbols in strings.
#escape_html: false
Expand Down
5 changes: 3 additions & 2 deletions filebeat/filebeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1546,8 +1546,9 @@ output.elasticsearch:
# IPv6 addresses should always be defined as: https://[2001:db8::1]:9200
hosts: ["localhost:9200"]

# Set gzip compression level.
#compression_level: 0
# Set gzip compression level. Set to 0 to disable compression.
# The default is 1.
#compression_level: 1

# Configure escaping HTML symbols in strings.
#escape_html: false
Expand Down
5 changes: 3 additions & 2 deletions heartbeat/heartbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,9 @@ output.elasticsearch:
# IPv6 addresses should always be defined as: https://[2001:db8::1]:9200
hosts: ["localhost:9200"]

# Set gzip compression level.
#compression_level: 0
# Set gzip compression level. Set to 0 to disable compression.
# The default is 1.
#compression_level: 1

# Configure escaping HTML symbols in strings.
#escape_html: false
Expand Down
5 changes: 3 additions & 2 deletions libbeat/_meta/config/output-elasticsearch.reference.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ output.elasticsearch:
# IPv6 addresses should always be defined as: https://[2001:db8::1]:9200
hosts: ["localhost:9200"]

# Set gzip compression level.
#compression_level: 0
# Set gzip compression level. Set to 0 to disable compression.
# The default is 1.
#compression_level: 1

# Configure escaping HTML symbols in strings.
#escape_html: false
Expand Down
2 changes: 1 addition & 1 deletion libbeat/outputs/elasticsearch/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var (
Password: "",
APIKey: "",
MaxRetries: 3,
CompressionLevel: 0,
CompressionLevel: 1,
EscapeHTML: false,
Kerberos: nil,
LoadBalance: true,
Expand Down
22 changes: 22 additions & 0 deletions libbeat/outputs/elasticsearch/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,28 @@ non_indexable_policy.dead_letter_index:
}
}

func TestCompressionIsOnByDefault(t *testing.T) {
config := ""
c := conf.MustNewConfigFrom(config)
elasticsearchOutputConfig, err := readConfig(c)
if err != nil {
t.Fatalf("Can't create test configuration from valid input")
}
assert.Equal(t, 1, elasticsearchOutputConfig.CompressionLevel, "Default compression level should be 1")
}

func TestExplicitCompressionLevelOverridesDefault(t *testing.T) {
config := `
compression_level: 0
`
c := conf.MustNewConfigFrom(config)
elasticsearchOutputConfig, err := readConfig(c)
if err != nil {
t.Fatalf("Can't create test configuration from valid input")
}
assert.Equal(t, 0, elasticsearchOutputConfig.CompressionLevel, "Explicit compression level should override defaults")
}

func readConfig(cfg *conf.C) (*elasticsearchConfig, error) {
c := defaultConfig
if err := cfg.Unpack(&c); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion libbeat/outputs/elasticsearch/docs/elasticsearch.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ The compression level must be in the range of `1` (best speed) to `9` (best comp

Increasing the compression level will reduce the network usage but will increase the cpu usage.

The default value is `0`.
The default value is `1`.

===== `escape_html`

Expand Down
5 changes: 3 additions & 2 deletions metricbeat/metricbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1285,8 +1285,9 @@ output.elasticsearch:
# IPv6 addresses should always be defined as: https://[2001:db8::1]:9200
hosts: ["localhost:9200"]

# Set gzip compression level.
#compression_level: 0
# Set gzip compression level. Set to 0 to disable compression.
# The default is 1.
#compression_level: 1

# Configure escaping HTML symbols in strings.
#escape_html: false
Expand Down
5 changes: 3 additions & 2 deletions packetbeat/packetbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,9 @@ output.elasticsearch:
# IPv6 addresses should always be defined as: https://[2001:db8::1]:9200
hosts: ["localhost:9200"]

# Set gzip compression level.
#compression_level: 0
# Set gzip compression level. Set to 0 to disable compression.
# The default is 1.
#compression_level: 1

# Configure escaping HTML symbols in strings.
#escape_html: false
Expand Down
5 changes: 3 additions & 2 deletions winlogbeat/winlogbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,9 @@ output.elasticsearch:
# IPv6 addresses should always be defined as: https://[2001:db8::1]:9200
hosts: ["localhost:9200"]

# Set gzip compression level.
#compression_level: 0
# Set gzip compression level. Set to 0 to disable compression.
# The default is 1.
#compression_level: 1

# Configure escaping HTML symbols in strings.
#escape_html: false
Expand Down
5 changes: 3 additions & 2 deletions x-pack/auditbeat/auditbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,9 @@ output.elasticsearch:
# IPv6 addresses should always be defined as: https://[2001:db8::1]:9200
hosts: ["localhost:9200"]

# Set gzip compression level.
#compression_level: 0
# Set gzip compression level. Set to 0 to disable compression.
# The default is 1.
#compression_level: 1

# Configure escaping HTML symbols in strings.
#escape_html: false
Expand Down
5 changes: 3 additions & 2 deletions x-pack/filebeat/filebeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3916,8 +3916,9 @@ output.elasticsearch:
# IPv6 addresses should always be defined as: https://[2001:db8::1]:9200
hosts: ["localhost:9200"]

# Set gzip compression level.
#compression_level: 0
# Set gzip compression level. Set to 0 to disable compression.
# The default is 1.
#compression_level: 1

# Configure escaping HTML symbols in strings.
#escape_html: false
Expand Down
5 changes: 3 additions & 2 deletions x-pack/functionbeat/functionbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,9 @@ output.elasticsearch:
# IPv6 addresses should always be defined as: https://[2001:db8::1]:9200
hosts: ["localhost:9200"]

# Set gzip compression level.
#compression_level: 0
# Set gzip compression level. Set to 0 to disable compression.
# The default is 1.
#compression_level: 1

# Configure escaping HTML symbols in strings.
#escape_html: false
Expand Down
5 changes: 3 additions & 2 deletions x-pack/heartbeat/heartbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,9 @@ output.elasticsearch:
# IPv6 addresses should always be defined as: https://[2001:db8::1]:9200
hosts: ["localhost:9200"]

# Set gzip compression level.
#compression_level: 0
# Set gzip compression level. Set to 0 to disable compression.
# The default is 1.
#compression_level: 1

# Configure escaping HTML symbols in strings.
#escape_html: false
Expand Down
5 changes: 3 additions & 2 deletions x-pack/metricbeat/metricbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1846,8 +1846,9 @@ output.elasticsearch:
# IPv6 addresses should always be defined as: https://[2001:db8::1]:9200
hosts: ["localhost:9200"]

# Set gzip compression level.
#compression_level: 0
# Set gzip compression level. Set to 0 to disable compression.
# The default is 1.
#compression_level: 1

# Configure escaping HTML symbols in strings.
#escape_html: false
Expand Down
5 changes: 3 additions & 2 deletions x-pack/osquerybeat/osquerybeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,9 @@ output.elasticsearch:
# IPv6 addresses should always be defined as: https://[2001:db8::1]:9200
hosts: ["localhost:9200"]

# Set gzip compression level.
#compression_level: 0
# Set gzip compression level. Set to 0 to disable compression.
# The default is 1.
#compression_level: 1

# Configure escaping HTML symbols in strings.
#escape_html: false
Expand Down
5 changes: 3 additions & 2 deletions x-pack/packetbeat/packetbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,9 @@ output.elasticsearch:
# IPv6 addresses should always be defined as: https://[2001:db8::1]:9200
hosts: ["localhost:9200"]

# Set gzip compression level.
#compression_level: 0
# Set gzip compression level. Set to 0 to disable compression.
# The default is 1.
#compression_level: 1

# Configure escaping HTML symbols in strings.
#escape_html: false
Expand Down
5 changes: 3 additions & 2 deletions x-pack/winlogbeat/winlogbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,9 @@ output.elasticsearch:
# IPv6 addresses should always be defined as: https://[2001:db8::1]:9200
hosts: ["localhost:9200"]

# Set gzip compression level.
#compression_level: 0
# Set gzip compression level. Set to 0 to disable compression.
# The default is 1.
#compression_level: 1

# Configure escaping HTML symbols in strings.
#escape_html: false
Expand Down

0 comments on commit 70cdc44

Please sign in to comment.