Skip to content

Conversation

@khushijain21
Copy link
Contributor

@khushijain21 khushijain21 commented Aug 13, 2025

What does this PR do?

This PR was already reviewed/approved here #8988. The original had to be closed due to security reason.

This PR enables telemetry logs for failed input docs on ES exporter.

This PR also adds a test to ensure sensitive logs from ES exporter or elastic-owned components are not shipped by filestream-monitoring.


And for sensitive logs from ES exporter are also blocked. The reasoning follows

If a document is failed to index for any reason, ES exporter logs the document at debug level.

The format looks something like this

 {"log.level":"debug",
 "@timestamp":"2025-07-14T06:35:24.235Z",
 "message":"failed to index document; input may contain sensitive data",
 "input":"{\"create\":{\"_index\":\"logs-test-default\"}}\n{\"host\":{\"hostname\":\"Khushis-MacBook-Pro.local\",\...}\n", 
 "index":"logs-test-default",
 "error.type":"strict_dynamic_mapping_exception",
 "error.reason":"",
 "ecs.version":"1.6.0",
}

Since the input field above contains a json document and filestream-monitoring's ndjson parser does not recurseively parse JSON - we can be sure this field in never indexed.

This test explicity ensure this behavior is always true

This test is a follow up as part of the discussion here #8738 (comment)

Why is it important?

Checklist

  • I have read and understood the pull request guidelines of this project.
  • 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/fragments using the changelog tool
  • I have added an integration test or an E2E test

How to test this PR locally

source ./env.sh; AGENT_VERSION=9.2.0 go test -tags integration -run TestSensitiveLogsESExporter ./testing/integration/ess -count=1 -v

Related issues

…and test to ensure sensitive logs are not shipped
@khushijain21
Copy link
Contributor Author

This PR is going to be flaky because of global paths in filebeat. Keeping this in draft mode until elastic/beats#44903 is resolved

@mergify
Copy link
Contributor

mergify bot commented Aug 13, 2025

This pull request does not have a backport label. Could you fix it @khushijain21? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-./d./d is the label that automatically backports to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.

@khushijain21 khushijain21 added skip-changelog backport-8.19 Automated backport to the 8.19 branch backport-9.1 Automated backport to the 9.1 branch labels Aug 13, 2025
@elastic-sonarqube
Copy link

@khushijain21 khushijain21 marked this pull request as ready for review October 7, 2025 05:38
@khushijain21 khushijain21 requested a review from a team as a code owner October 7, 2025 05:38
@khushijain21 khushijain21 added the backport-9.2 Automated backport to the 9.2 branch label Oct 7, 2025
@khushijain21 khushijain21 requested a review from swiatekm October 7, 2025 05:43
@pchila pchila removed their request for review October 7, 2025 06:05
@elasticmachine
Copy link
Contributor

@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Oct 7, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@khushijain21 khushijain21 merged commit eb098ec into elastic:main Oct 7, 2025
25 checks passed
mergify bot pushed a commit that referenced this pull request Oct 7, 2025
…and test to ensure sensitive logs are not shipped (#9341)

* [beatreceiver] Enable telemetry for indexing errors on ES exporter - and test to ensure sensitive logs are not shipped

* remove extra line

(cherry picked from commit eb098ec)

# Conflicts:
#	internal/pkg/otel/translate/otelconfig_test.go
#	testing/integration/ess/beat_receivers_test.go
mergify bot pushed a commit that referenced this pull request Oct 7, 2025
…and test to ensure sensitive logs are not shipped (#9341)

* [beatreceiver] Enable telemetry for indexing errors on ES exporter - and test to ensure sensitive logs are not shipped

* remove extra line

(cherry picked from commit eb098ec)

# Conflicts:
#	internal/pkg/otel/translate/otelconfig_test.go
mergify bot pushed a commit that referenced this pull request Oct 7, 2025
…and test to ensure sensitive logs are not shipped (#9341)

* [beatreceiver] Enable telemetry for indexing errors on ES exporter - and test to ensure sensitive logs are not shipped

* remove extra line

(cherry picked from commit eb098ec)
khushijain21 added a commit that referenced this pull request Oct 7, 2025
…and test to ensure sensitive logs are not shipped (#9341) (#10377)

* [beatreceiver] Enable telemetry for indexing errors on ES exporter - and test to ensure sensitive logs are not shipped

* remove extra line

(cherry picked from commit eb098ec)

Co-authored-by: Khushi Jain <khushi.jain@elastic.co>
@pchila pchila mentioned this pull request Oct 7, 2025
8 tasks
khushijain21 pushed a commit that referenced this pull request Oct 22, 2025
…errors on ES exporter - and test to ensure sensitive logs are not shipped (#10375)

* [beatreceiver] Enable telemetry for indexing errors on ES exporter - and test to ensure sensitive logs are not shipped (#9341)
ycombinator pushed a commit that referenced this pull request Oct 24, 2025
…and test to ensure sensitive logs are not shipped (#9341)

* [beatreceiver] Enable telemetry for indexing errors on ES exporter - and test to ensure sensitive logs are not shipped

* remove extra line

(cherry picked from commit eb098ec)
khushijain21 pushed a commit that referenced this pull request Oct 29, 2025
…rrors on ES exporter - and test to ensure sensitive logs are not shipped (#10376)

* [beatreceiver] Enable telemetry for indexing errors on ES exporter - and test to ensure sensitive logs are not shipped (#9341)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-8.19 Automated backport to the 8.19 branch backport-9.1 Automated backport to the 9.1 branch backport-9.2 Automated backport to the 9.2 branch skip-changelog Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[beat_receivers] Redact or drop logs that could contain event data in the monitoring filestream instance

4 participants