Skip to content

Update the Logstash output doc with guidance on using a single ES output - #8203

Open
vishaangelova wants to merge 3 commits into
mainfrom
7854-logstash-output-single-es
Open

vishaangelova wants to merge 3 commits into
mainfrom
7854-logstash-output-single-es

Conversation

@vishaangelova

@vishaangelova vishaangelova commented Sep 4, 2026 •

Copy link
Copy Markdown
Member

Summary

This PR adds a Use a single Elasticsearch output section documenting an alternative to the dual-output example in the Fleet Logstash output doc.

Closes #7854

Verification

Used Claude to check against logstash-plugins/logstash-output-elasticsearch at HEAD:

  • data_stream_event_action_tuple calls the same common_event_params, which reads [@metadata][_ingest_document], so this works with data_stream => true.
  • The behavior landed in Elasticsearch output plugin 11.21.0; Logstash 8.12.0 is the first release that bundles it.
  • resolve_document_id prefers an explicit document_id, so the two must not be combined. Documented as a caveat.
  • The elastic_integration filter replaces the whole [@metadata][_ingest_document] map via event.setField, so the mutate must come after it. Also documented.

Reviewer note

[@metadata][_ingest_document][id] is documented as an output of the elastic_integration filter, but the Elasticsearch output plugin's docs never mention that it consumes the field. Documenting it here makes an internal contract semi-public, so I'd like a Logstash maintainer (cc @robbavey, per the issue) to confirm this is acceptable before merge.

A follow-up PR will apply the same treatment to docs/reference/filebeat/filebeat-deduplication.md in elastic/beats, which carries the identical dual-output pattern.

Generative AI disclosure

  1. Did you use a generative AI (GenAI) tool to assist in creating this contribution?
  • Yes
  • No

Tool(s) and model(s) used: Cursor (Claude Opus 5)

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Elastic Docs AI PR menu

Check the box to run an AI review for this pull request.

  • Review docs changes (docs-review). Status: not started.

Powered by GitHub Agentic Workflows and docs-actions. For more information, reach out to the docs team.

@vishaangelova
vishaangelova marked this pull request as ready for review September 4, 2026 12:38
@vishaangelova
vishaangelova requested a review from a team as a code owner September 4, 2026 12:38
@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🔍 Preview links for changed docs

@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Elastic Docs Style Checker (Vale)

Summary: 10 warnings, 1 suggestion found

⚠️ Warnings (10): Fix when the suggestion improves clarity or correctness.
File Line Rule Message
reference/fleet/logstash-output.md 96 Elastic.MenuArrows Use '→' to separate menu items, not '' or '='. Example: Select Manage index → Add lifecycle policy.
reference/fleet/logstash-output.md 96 Elastic.MenuArrows Use '→' to separate menu items, not '' or '='. Example: Select Manage index → Add lifecycle policy.
reference/fleet/logstash-output.md 103 Elastic.MenuArrows Use '→' to separate menu items, not '' or '='. Example: Select Manage index → Add lifecycle policy.
reference/fleet/logstash-output.md 103 Elastic.QuotesPunctuation Place punctuation inside closing quotation marks.
reference/fleet/logstash-output.md 104 Elastic.MenuArrows Use '→' to separate menu items, not '' or '='. Example: Select Manage index → Add lifecycle policy.
reference/fleet/logstash-output.md 105 Elastic.MenuArrows Use '→' to separate menu items, not '' or '='. Example: Select Manage index → Add lifecycle policy.
reference/fleet/logstash-output.md 106 Elastic.MenuArrows Use '→' to separate menu items, not '' or '='. Example: Select Manage index → Add lifecycle policy.
reference/fleet/logstash-output.md 107 Elastic.MenuArrows Use '→' to separate menu items, not '' or '='. Example: Select Manage index → Add lifecycle policy.
reference/fleet/logstash-output.md 108 Elastic.MenuArrows Use '→' to separate menu items, not '' or '='. Example: Select Manage index → Add lifecycle policy.
reference/fleet/logstash-output.md 109 Elastic.MenuArrows Use '→' to separate menu items, not '' or '='. Example: Select Manage index → Add lifecycle policy.
💡 Suggestions (1): Optional style improvements. Apply when helpful.
File Line Rule Message
reference/fleet/logstash-output.md 104 Elastic.Ellipses Use ellipses sparingly. Remove the ellipsis unless it appears in UI text.

The Vale linter checks documentation changes against the Elastic Docs style guide. To use Vale locally or report issues, refer to Elastic style guide for Vale.

@alexandra5000 alexandra5000 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@vishaangelova

Copy link
Copy Markdown
Member Author

@robbavey, could you or someone from your team have a look at the changes in this PR? Thanks!

@lucabelluccini lucabelluccini left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think a Logstash developer should review this. We are relying on [@metadata][_ingest_document][id] which is not really well publicly documented.

Comment thread reference/fleet/logstash-output.md Outdated
```yaml
filter {
mutate {
copy => { "[@metadata][_id]" => "[@metadata][_ingest_document][id]" }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I do not know if we should protect this copy by if [@metadata][_id] { ...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated in 3996c3b.

Comment thread reference/fleet/logstash-output.md Outdated
`[@metadata][_ingest_document][id]` is read internally by the {{es}} output plugin and is not part of that plugin's documented configuration surface. Keep two things in mind when you use it:

* Don't also set `document_id` on the output. An explicit `document_id` overrides the metadata field.
* If your pipeline also uses the [`elastic_integration` filter](logstash-docs-md://lsr/plugins-filters-elastic_integration.md), add the `mutate` after that filter. The filter replaces the whole `[@metadata][_ingest_document]` map, so an earlier `copy` is discarded.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If one uses the elastic_integration for all the events, the mutate is un-necessary.

If one uses the elastic_integration only on a part of the data, then we would need something like this (pseudocode):

if [... criteria to use elastic_integration] {
  elastic_integration {
    ...
  }
} else {
  // Here we have the events which are not processed by elastic_integration
  mutate {
    copy => { "[@metadata][_id]" => "[@metadata][_ingest_document][id]" }
  }
}

@vishaangelova vishaangelova Sep 23, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I used Claude to research this a bit. It checked logstash-filter-elastic_integration and logstash-output-elasticsearch at HEAD, and flagged the following:

The filter does not copy Agent [@metadata][_id] into [@metadata][_ingest_document][id]. It writes that field only when the ingest pipeline sets _id, and it replaces the whole _ingest_document map, so a mutate before the filter is discarded. The Elasticsearch output reads _ingest_document[id], not [@metadata][_id].

So omitting mutate when every event goes through the filter would drop Agent IDs unless the ingest pipeline also set _id. An unconditional copy after the filter would overwrite an ID the pipeline did set.

Updated in 3996c3b: the section now uses one condition that covers both cases.

@robbavey

Copy link
Copy Markdown
Member

@vishaangelova @lucabelluccini Let's chat about this

This branch was successfully deployed

1 active deployment
docs-preview — 567be9f8 Deployed Sep 24, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Website]: Improve docs for using Logstash output with Fleet (_id situation)

4 participants