Skip to content

fix: preserve integer/float types in Logstash plugin serialization (#14272)#14342

Open
dcaayushd wants to merge 2 commits into
Azure:masterfrom
dcaayushd:fix/logstash-integer-type-fidelity-14272
Open

fix: preserve integer/float types in Logstash plugin serialization (#14272)#14342
dcaayushd wants to merge 2 commits into
Azure:masterfrom
dcaayushd:fix/logstash-integer-type-fidelity-14272

Conversation

@dcaayushd
Copy link
Copy Markdown

@dcaayushd dcaayushd commented May 25, 2026

Change(s):

  • Modified logStashEventsBatcher.rb to detect and preserve native integer and float types during JSON serialization
  • Updated customSizeBasedBuffer.rb, logStashAutoResizeBuffer.rb, logStashCompressedStream.rb, and sampleFileCreator.rb with related type handling fixes
  • Added specs in spec/ to cover integer and float field serialization

Reason for Change(s):

Version Updated:

  • N/A (this is a plugin bug fix, not a Detections/Analytic Rule template)

Testing Completed:

  • Yes, tested locally with Logstash 8 by sending events with integer and float fields and verifying the serialized JSON payload contains numeric values instead of quoted strings
  • Added unit tests in spec/ covering the fix

Checked that the validations are passing and have addressed any issues that are present:

  • Yes

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR restores v1.x behavior by switching the Logstash plugin’s JSON serialization to LogStash::Json, preserving native integer/float types so DCR ingestion won’t drop strictly-typed numeric columns.

Changes:

  • Replaced .to_json usage with LogStash::Json.dump across buffering/compression/sample-file paths to preserve numeric types.
  • Added a minimal LogStash::Json shim for the spec environment (avoids loading logstash-core).
  • Added an RSpec that validates integers/floats remain JSON numbers after serialization.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
DataConnectors/microsoft-sentinel-log-analytics-logstash-output-plugin/spec/support/logstash/json.rb Adds a minimal LogStash::Json shim for unit tests.
DataConnectors/microsoft-sentinel-log-analytics-logstash-output-plugin/spec/outputs/serialization_spec.rb Adds spec coverage asserting numeric fields remain numeric after serialization.
DataConnectors/microsoft-sentinel-log-analytics-logstash-output-plugin/lib/logstash/sentinel_la/sampleFileCreator.rb Uses LogStash::Json.dump when writing sample payloads.
DataConnectors/microsoft-sentinel-log-analytics-logstash-output-plugin/lib/logstash/sentinel_la/logStashEventsBatcher.rb Uses LogStash::Json.dump for document-size calculation.
DataConnectors/microsoft-sentinel-log-analytics-logstash-output-plugin/lib/logstash/sentinel_la/logStashCompressedStream.rb Uses LogStash::Json.dump when adding events to the compressed stream.
DataConnectors/microsoft-sentinel-log-analytics-logstash-output-plugin/lib/logstash/sentinel_la/logStashAutoResizeBuffer.rb Uses LogStash::Json.dump for payload serialization and sizing.
DataConnectors/microsoft-sentinel-log-analytics-logstash-output-plugin/lib/logstash/sentinel_la/customSizeBasedBuffer.rb Uses LogStash::Json.dump for var_size calculation.

@v-atulyadav
Copy link
Copy Markdown
Collaborator

Hi @dcaayushd,

Please check Copilot’s suggestions and act accordingly. Once done, click the “Resolve conversation” button. Thanks

@dcaayushd dcaayushd closed this May 26, 2026
@dcaayushd dcaayushd reopened this May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Logstash output plugin 2.x loss of integer type fidelity for numeric fields (e.g., ports)

4 participants