Skip to content

Conversation

@dyl10s
Copy link
Collaborator

@dyl10s dyl10s commented Aug 18, 2025

Description

Refactored the Rabbitmq parser to use the LoggingReceiverMacro. This shares some similarities with #1987 where we specifically need to register the processor for the transformation test.

Related issue

How has this been tested?

Generated golden files before the refactor. Refactored Rabbitmq and verified there were no changes.

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.

@dyl10s dyl10s marked this pull request as draft August 18, 2025 14:45
@dyl10s dyl10s marked this pull request as ready for review August 18, 2025 15:18
apps/rabbitmq.go Outdated
{
StateName: "cont",
NextState: "cont",
Regex: `^(?!\d+-\d+-\d+ \d+:\d+:\d+\.\d+\+\d+:\d+)`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move the r.ReceiverMixin.MultilineRules to a standalone confgenerator.LoggingProcessorParseMultilineRegex within the Expand method of "LoggingProcessorMacro".

The template for this update is elasticsearch.go in master after #2025 .

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I moved this into the Expand method and it seemed to not correctly parse the multiline entries. You can see with the diff in the golden files on my most recent commit.

2025-08-18 05:07:43.557042+00:00 [erro] <0.130.0>
BOOT FAILED
===========
ERROR: could not bind to distribution port 25672, it is in use by another node: rabbit@keith-testing-rabbitmq No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add more log line samples at the end of input.log so the last multiline log entry is parsed completely.

Nit : Add a new line at the end of the file.

Copy link
Collaborator Author

@dyl10s dyl10s Aug 18, 2025

Choose a reason for hiding this comment

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

Made this change but the parsing still does not seem to be working correctly. No changes are made after running make transformation_test_update

Copy link
Contributor

Choose a reason for hiding this comment

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

I see 🤔 ! Let me try to debug the reason of the multiline parse is not working.

Copy link
Contributor

Choose a reason for hiding this comment

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

I added two "sample" log lines at the end of the input.log and the multiline parsing worked (see sample output at the end of the comment). My suggestion is two add more sample lines at the bottom of input.log.

Why this works ?

The way fluent-bit multiparse rules work is using a start_state and a cont state. The cont state in rabbitmq (^(?!\d+-\d+-\d+ \d+:\d+:\d+\.\d+\+\d+:\d+)) will keep matching lines that doesn't look as the start_state (don't have the timestamp log format). This means, for a multiline log entry to be completely parsed it needs a followup log that matches start_state so fluent-bit know the previous log ended.

input.log

...
2025-08-18 05:07:43.557042+00:00 [erro] <0.130.0>
BOOT FAILED
===========
ERROR: could not bind to distribution port 25672, it is in use by another node: rabbit@keith-testing-rabbitmq
2025-08-19 04:07:07.777+00:00 [noti] <123.456.789> {shutdown,{connection_closed, "Broken pipe"}}
2025-08-19 04:07:07.777+00:00 [noti] <123.456.789> {shutdown,{connection_closed, "Broken pipe"}}

output_fluentbit.yaml

...
    severity: 0.0
    timestamp: 2025-08-18T04:07:07.777000000Z
  - jsonPayload:
      message: |-
        2025-08-18 05:07:43.557042+00:00 [erro] <0.130.0>
        BOOT FAILED
        ===========
        ERROR: could not bind to distribution port 25672, it is in use by another node: rabbit@keith-testing-rabbitmq
    labels:
      compute.googleapis.com/resource_name: hostname
      logging.googleapis.com/instrumentation_source: agent.googleapis.com/rabbitmq
    logName: projects/my-project/logs/transformation_test
    timestamp: now
  - jsonPayload:
      message: "{shutdown,{connection_closed, \"Broken pipe\"}}"
      process_id: 123.456.789
      severity: noti
    labels:
      compute.googleapis.com/resource_name: hostname
      logging.googleapis.com/instrumentation_source: agent.googleapis.com/rabbitmq
    logName: projects/my-project/logs/transformation_test
    severity: 0.0
    timestamp: now
  partialSuccess: true
  resource:
    labels: {}
    type: gce_instance

Copy link
Member

@quentinmit quentinmit Aug 18, 2025

Choose a reason for hiding this comment

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

This feels like a fluent-bit bug. The flush_timeout setting is supposed to cause the final log entry to be emitted after the timeout expires even if there isn't another line. I'm guessing that the exit_on_eof setting is causing fluent-bit to exit before it has a chance to flush.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added the additional log lines here but it does seem like a bug that could get fixed. This can work as a temporary solution though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good ! I created b/439825446 to track this bug.

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!

We will address separately the bug with missing last log in fluent-bit transformation tests.

@franciscovalentecastro franciscovalentecastro merged commit db05d06 into GoogleCloudPlatform:master Aug 25, 2025
4 checks passed
rafaelwestphal pushed a commit that referenced this pull request Aug 26, 2025
Co-authored-by: Francisco Valente Castro <1435136+franciscovalentecastro@users.noreply.github.com>
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.

3 participants