Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[filebeat] Add support for bulk_max_size and preset #42312

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

khushijain21
Copy link
Contributor

@khushijain21 khushijain21 commented Jan 15, 2025

Proposed commit message

This PR is a follow up to #41849. It improves test scenarios. It also adds support for bulk_max_size and preset.

We will have to wait for next release of otel-collector to use compression_level parameter. But the default compression level used by elasticsearchexporter is set to 1. So we can go ahead and support preset paramater now

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Related Issue
Part of https://github.com/elastic/opentelemetry-dev/issues/614
open-telemetry/opentelemetry-collector-contrib#37260

@khushijain21 khushijain21 requested a review from a team as a code owner January 15, 2025 09:03
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jan 15, 2025
Copy link
Contributor

mergify bot commented Jan 15, 2025

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @khushijain21? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit

Copy link
Contributor

mergify bot commented Jan 15, 2025

backport-8.x has been added to help with the transition to the new branch 8.x.
If you don't need it please use backport-skip label and remove the backport-8.x label.

@mergify mergify bot added the backport-8.x Automated backport to the 8.x branch with mergify label Jan 15, 2025
@khushijain21 khushijain21 marked this pull request as draft January 15, 2025 09:04
@khushijain21 khushijain21 changed the title [filebeat] Add support for bulk_max_size [filebeat] Add support for bulk_max_size and preset Jan 15, 2025
@khushijain21 khushijain21 marked this pull request as ready for review January 15, 2025 12:39
@khushijain21 khushijain21 requested a review from rdner January 15, 2025 12:39
@khushijain21 khushijain21 marked this pull request as draft January 15, 2025 12:49
@khushijain21 khushijain21 marked this pull request as ready for review January 15, 2025 16:48
@khushijain21 khushijain21 added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Jan 15, 2025
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jan 15, 2025
@khushijain21
Copy link
Contributor Author

/test

libbeat/otelbeat/beatconverter/beatconverter.go Outdated Show resolved Hide resolved
Comment on lines -43 to -48
if !cfg.HasField("bulk_max_size") {
if err := cfg.SetInt("bulk_max_size", -1, defaultBulkSize); err != nil {
return outputs.Fail(err)
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change the ES output implementation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering the same. I believe the ES output must not change as part of this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only setting bulk_max_size to a default value if not set, I moved it here, to keep it consistent.

https://github.com/elastic/beats/pull/42312/files#diff-8cfe4be190c94b04b508a5fae989f3955e3362dadc14f203190cb2317e8992e7R77-R78

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was it deleted intentionally?

Copy link
Contributor Author

@khushijain21 khushijain21 Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I refactored the test cases to take inputs as yaml strings instead of reading from a file. This helped reuse common parts of the cofe. This also makes sure that as more paramaters will be mapped, we only have to update it in one place.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was it deleted intentionally?

require.NoError(t, err)
})

t.Run("test local queue setting is promoted to global level", func(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm struggling to understand this test case.
Why do we have queue as a part of the output configuration and then move to the filebeatreceiver level? It should always be on the filebeatreceiver level, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the same question as @rdner, the queue configuration in Beats is not part of the output.

Copy link
Contributor Author

@khushijain21 khushijain21 Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible to set queue both under filebeatreceiver level and at output level. When set under output level we make sure to promote it to filbeatreceiver level. This is done to allow existing
behavior of specifying queue settings at the top level. Also, when presets are applied, it is first set under output level. This logic ensures that queue settings that come from both user or presets are promoted one level up.

Ref PR: #36788
Our documentations currently do not mention setting queue at output level. Opened an issue for the same #42310

require.NoError(t, err)
})

t.Run("test local queue setting is promoted to global level", func(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the same question as @rdner, the queue configuration in Beats is not part of the output.

libbeat/outputs/elasticsearch/config_otel.go Outdated Show resolved Hide resolved
})
}
t.Run("basic config translation", func(t *testing.T) {
basicInput := `
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an output configuration, I'm a bit confused why it's called basicInput. Maybe it can be called esOutputCfg.

X-Header-1: foo
X-Bar-Header: bar`

basicOp := `
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name here is also confusing me a bit. What does op stand for here, operation?

What about renaming it to otelOutputCfg?

Suggested change
basicOp := `
otelOutputCfg := `

Copy link
Contributor Author

@khushijain21 khushijain21 Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Op stood for output. I'll rename it to your suggestion, thanks

libbeat/outputs/elasticsearch/config_otel_test.go Outdated Show resolved Hide resolved
Comment on lines -43 to -48
if !cfg.HasField("bulk_max_size") {
if err := cfg.SetInt("bulk_max_size", -1, defaultBulkSize); err != nil {
return outputs.Fail(err)
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering the same. I believe the ES output must not change as part of this PR.

@cmacknz
Copy link
Member

cmacknz commented Jan 16, 2025

It looks like we are mapping existing parameters in Beats to similarly named parameters in the OTel collector. This only makes sense if we know they behave equivalent from a performance perspective.

The bulk_max_size translating to max_size_items looks like it is probably OK, did we test that it behaves exactly the same? https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/elasticsearchexporter/README.md#batching

The presets I am much less sure about and I don't think we should touch them without benchmarking them. The parameter values looking the same doesn't matter, the performance characteristics being the same or better is what matters. How are we measuring that?

@khushijain21
Copy link
Contributor Author

khushijain21 commented Jan 20, 2025

The bulk_max_size translating to max_size_items looks like it is probably OK, did we test that it behaves exactly the same?

Yes. It was tested with setting bulk_max_size to 1 and sending 1000 log events. The behavior in both modes was similar, i.e all documents were indexed

The presets I am much less sure about and I don't think we should touch them without benchmarking them. The parameter values looking the same doesn't matter, the performance characteristics being the same or better is what matters. How are we measuring that?

All parameters that preset overrides are supported including bulk_max_size as part of this PR. Compression level is always set to 1 on es-exporter so we should be good to go. We can compare the performance impact of preset in a follow up PR using the benchmark work being done here https://ingest-metricstore.kb.us-central1.gcp.cloud.es.io:9243/app/dashboards#/view/88664583-01a2-48e5-80e6-fc93db54fc86?_g=h@9d8efc3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.x Automated backport to the 8.x branch with mergify Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants