Skip to content

Conversation

@dyl10s
Copy link
Collaborator

@dyl10s dyl10s commented Jul 21, 2025

Description

Refactored the Elasticsearch json parser to use the LoggingReceiverMacro

I did need to add some yaml tags to fix a parsing panic

Related issue

How has this been tested?

Checklist:

  • Unit tests
    • Unit tests do not apply.
    • Unit tests have been added/modified and passed for this PR.
  • Integration tests
    • Integration tests do not apply.
    • Integration tests have been added/modified and passed for this PR.
  • Documentation
    • This PR introduces no user visible changes.
    • This PR introduces user visible changes and the corresponding documentation change has been made.
  • Minor version bump
    • This PR introduces no new features.
    • This PR introduces new features, and there is a separate PR to bump the minor version since the last release already.
    • This PR bumps the version.

@google-cla
Copy link

google-cla bot commented Jul 21, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Contributor

@franciscovalentecastro franciscovalentecastro Jul 22, 2025

Choose a reason for hiding this comment

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

Note: This is a general comment that i mentioned also in #1978 (comment). Another way of verifying that the refactor is correct is that the output_fluentbit.yaml should be the same before and after the update to elasticsearch.go.

Copy link
Contributor

@franciscovalentecastro franciscovalentecastro left a comment

Choose a reason for hiding this comment

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

LGTM!

@dyl10s dyl10s force-pushed the feat/elasticsearch-json-refactor branch from 65124b7 to b16bece Compare July 24, 2025 17:46
Copy link
Contributor

@franciscovalentecastro franciscovalentecastro left a comment

Choose a reason for hiding this comment

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

Sorry for bringing this comments so late in the review process. Added some last suggested changes.

ReceiverMixin confgenerator.LoggingReceiverFilesMixin `yaml:",inline"`
type LoggingReceiverMacroElasticsearchJson struct {
LoggingProcessorMacroElasticsearchJson `yaml:",inline"`
ReceiverMixin confgenerator.LoggingReceiverFilesMixin `yaml:",inline"`
Copy link
Contributor

Choose a reason for hiding this comment

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

This change should prevent the YAML un-marshalling to validate recursively all fields in ReceiverMixin, thus not causing the panic with missing yaml tags.

Suggested change :

Suggested change
ReceiverMixin confgenerator.LoggingReceiverFilesMixin `yaml:",inline"`
ReceiverMixin confgenerator.LoggingReceiverFilesMixin `yaml:",inline" validate:"structonly"`

Comment on lines 323 to 325
StateName string `yaml:"state_name,omitempty"`
Regex string `yaml:"regex,omitempty"`
NextState string `yaml:"next_state,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for bringing this comments so late in the review process. Now i'm realizing that since MultilineRule 1 is a non-configurable feature (not exposed to users), these fields don't need and shouldn't have named yaml tags.

Note : I remember the updates in elasticsearch.go were causing some issues with a panic (missing tags) when running tests. I haven't been able to reproduce again, but i believe the other suggested change in elasticsearch.go should fix that.

Suggesting the following change :

Suggested change
StateName string `yaml:"state_name,omitempty"`
Regex string `yaml:"regex,omitempty"`
NextState string `yaml:"next_state,omitempty"`
StateName string
Regex string
NextState string

Footnotes

  1. https://github.com/GoogleCloudPlatform/ops-agent/blob/master/confgenerator/logging_receivers.go#L74

@dyl10s
Copy link
Collaborator Author

dyl10s commented Jul 28, 2025

Sorry for bringing this comments so late in the review process. Added some last suggested changes.

All good, got that fixed!

@franciscovalentecastro
Copy link
Contributor

Previous commit passed most tests (see a483257). Merging.

@franciscovalentecastro franciscovalentecastro merged commit 308261b into GoogleCloudPlatform:master Jul 28, 2025
34 of 53 checks passed
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.

2 participants