Skip to content

Commit

Permalink
Enable compression by default for Elasticsearch outputs (#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

(cherry picked from commit 231e93a)

# Conflicts:
#	libbeat/outputs/elasticsearch/config_test.go
  • Loading branch information
faec authored and mergify[bot] committed Sep 29, 2023
1 parent a5d6006 commit f6f64c8
Show file tree
Hide file tree
Showing 19 changed files with 75 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/v7.0.0-alpha2...master[Check the HEAD d
==== 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 @@ -453,8 +453,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 @@ -1477,8 +1477,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 @@ -598,8 +598,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
26 changes: 26 additions & 0 deletions libbeat/outputs/elasticsearch/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,33 @@ non_indexable_policy.dead_letter_index:
}
}

<<<<<<< HEAD

Check failure on line 100 in libbeat/outputs/elasticsearch/config_test.go

View workflow job for this annotation

GitHub Actions / lint (darwin)

expected declaration, found '<<' (typecheck)
func readConfig(cfg *common.Config) (*elasticsearchConfig, error) {
=======
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) {
>>>>>>> 231e93a6d2 (Enable compression by default for Elasticsearch outputs (#36681))

Check failure on line 126 in libbeat/outputs/elasticsearch/config_test.go

View workflow job for this annotation

GitHub Actions / lint (darwin)

illegal character U+0023 '#' (typecheck)
c := defaultConfig
if err := cfg.Unpack(&c); err != nil {
return nil, err
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 @@ -102,7 +102,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 @@ -1265,8 +1265,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 @@ -947,8 +947,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 @@ -383,8 +383,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 @@ -509,8 +509,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 @@ -3738,8 +3738,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 @@ -630,8 +630,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 @@ -598,8 +598,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 @@ -1796,8 +1796,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 @@ -349,8 +349,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 @@ -947,8 +947,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 @@ -426,8 +426,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 f6f64c8

Please sign in to comment.