-
Notifications
You must be signed in to change notification settings - Fork 80
feat: Update Rabbitmq parser to use LoggingReceiverMacro
#2038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
7f88f4b
17a2140
767500b
755a922
e5c5cb4
365aa01
4bd1f84
b17cc6e
a337abf
1cd1ee5
a938396
2a2aaa5
7e16303
f10691d
6974f64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,45 +18,41 @@ import ( | |
| "context" | ||
|
|
||
| "github.com/GoogleCloudPlatform/ops-agent/confgenerator" | ||
| "github.com/GoogleCloudPlatform/ops-agent/confgenerator/fluentbit" | ||
| "github.com/GoogleCloudPlatform/ops-agent/confgenerator/otel" | ||
| "github.com/GoogleCloudPlatform/ops-agent/internal/secret" | ||
| ) | ||
|
|
||
| type LoggingProcessorRabbitmq struct { | ||
| confgenerator.ConfigComponent `yaml:",inline"` | ||
| } | ||
| type LoggingProcessorMacroRabbitmq struct{} | ||
|
|
||
| func (*LoggingProcessorRabbitmq) Type() string { | ||
| func (LoggingProcessorMacroRabbitmq) Type() string { | ||
| return "rabbitmq" | ||
| } | ||
|
|
||
| func (p *LoggingProcessorRabbitmq) Components(ctx context.Context, tag, uid string) []fluentbit.Component { | ||
| c := confgenerator.LoggingProcessorParseRegexComplex{ | ||
| Parsers: []confgenerator.RegexParser{ | ||
| { | ||
| // Sample log line: | ||
| // 2022-01-31 18:01:20.441571+00:00 [erro] <0.692.0> ** Connection attempt from node 'rabbit_ctl_17@keith-testing-rabbitmq' rejected. Invalid challenge reply. ** | ||
| Regex: `^(?<timestamp>\d+-\d+-\d+\s+\d+:\d+:\d+[.,]\d+\+\d+:\d+) \[(?<severity>\w+)\] \<(?<process_id>\d+\.\d+\.\d+)\> (?<message>.*)$`, | ||
| Parser: confgenerator.ParserShared{ | ||
| TimeKey: "timestamp", | ||
| TimeFormat: "%Y-%m-%d %H:%M:%S.%L%z", | ||
| func (p LoggingProcessorMacroRabbitmq) Expand(ctx context.Context) []confgenerator.InternalLoggingProcessor { | ||
| return []confgenerator.InternalLoggingProcessor{ | ||
| confgenerator.LoggingProcessorParseRegexComplex{ | ||
| Parsers: []confgenerator.RegexParser{ | ||
| { | ||
| // Sample log line: | ||
| // 2022-01-31 18:01:20.441571+00:00 [erro] <0.692.0> ** Connection attempt from node 'rabbit_ctl_17@keith-testing-rabbitmq' rejected. Invalid challenge reply. ** | ||
| Regex: `^(?<timestamp>\d+-\d+-\d+\s+\d+:\d+:\d+[.,]\d+\+\d+:\d+) \[(?<severity>\w+)\] \<(?<process_id>\d+\.\d+\.\d+)\> (?<message>.*)$`, | ||
| Parser: confgenerator.ParserShared{ | ||
| TimeKey: "timestamp", | ||
| TimeFormat: "%Y-%m-%d %H:%M:%S.%L%z", | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| // Sample log line: | ||
| // 2023-02-01 12:45:14.705 [info] <0.801.0> Successfully set user tags for user 'admin' to [administrator] | ||
| Regex: `^(?<timestamp>\d+-\d+-\d+\s+\d+:\d+:\d+[.,]\d+\d+\d+) \[(?<severity>\w+)\] \<(?<process_id>\d+\.\d+\.\d+)\> (?<message>.*)$`, | ||
| Parser: confgenerator.ParserShared{ | ||
| TimeKey: "timestamp", | ||
| TimeFormat: "%Y-%m-%d %H:%M:%S.%L", | ||
| { | ||
| // Sample log line: | ||
| // 2023-02-01 12:45:14.705 [info] <0.801.0> Successfully set user tags for user 'admin' to [administrator] | ||
| Regex: `^(?<timestamp>\d+-\d+-\d+\s+\d+:\d+:\d+[.,]\d+\d+\d+) \[(?<severity>\w+)\] \<(?<process_id>\d+\.\d+\.\d+)\> (?<message>.*)$`, | ||
| Parser: confgenerator.ParserShared{ | ||
| TimeKey: "timestamp", | ||
| TimeFormat: "%Y-%m-%d %H:%M:%S.%L", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }.Components(ctx, tag, uid) | ||
|
|
||
| // severities documented here: https://www.rabbitmq.com/logging.html#log-levels | ||
| c = append(c, | ||
| // severities documented here: https://www.rabbitmq.com/logging.html#log-levels | ||
| confgenerator.LoggingProcessorModifyFields{ | ||
| Fields: map[string]*confgenerator.ModifyField{ | ||
| "severity": { | ||
|
|
@@ -72,18 +68,16 @@ func (p *LoggingProcessorRabbitmq) Components(ctx context.Context, tag, uid stri | |
| }, | ||
| InstrumentationSourceLabel: instrumentationSourceValue(p.Type()), | ||
| }, | ||
| }.Components(ctx, tag, uid)..., | ||
| ) | ||
|
|
||
| return c | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| type LoggingReceiverRabbitmq struct { | ||
| LoggingProcessorRabbitmq `yaml:",inline"` | ||
| ReceiverMixin confgenerator.LoggingReceiverFilesMixin `yaml:",inline" validate:"structonly"` | ||
| type LoggingReceiverMacroRabbitmq struct { | ||
| LoggingProcessorMacroRabbitmq `yaml:",inline"` | ||
| ReceiverMixin confgenerator.LoggingReceiverFilesMixin `yaml:",inline" validate:"structonly"` | ||
| } | ||
|
|
||
| func (r LoggingReceiverRabbitmq) Components(ctx context.Context, tag string) []fluentbit.Component { | ||
| func (r LoggingReceiverMacroRabbitmq) Expand(ctx context.Context) (confgenerator.InternalLoggingReceiver, []confgenerator.InternalLoggingProcessor) { | ||
| if len(r.ReceiverMixin.IncludePaths) == 0 { | ||
| r.ReceiverMixin.IncludePaths = []string{ | ||
| "/var/log/rabbitmq/rabbit*.log", | ||
|
|
@@ -108,13 +102,14 @@ func (r LoggingReceiverRabbitmq) Components(ctx context.Context, tag string) []f | |
| Regex: `^(?!\d+-\d+-\d+ \d+:\d+:\d+\.\d+\+\d+:\d+)`, | ||
|
||
| }, | ||
| } | ||
| c := r.ReceiverMixin.Components(ctx, tag) | ||
| c = append(c, r.LoggingProcessorRabbitmq.Components(ctx, tag, "rabbitmq")...) | ||
| return c | ||
|
|
||
| return &r.ReceiverMixin, r.LoggingProcessorMacroRabbitmq.Expand(ctx) | ||
| } | ||
|
|
||
| func init() { | ||
| confgenerator.LoggingReceiverTypes.RegisterType(func() confgenerator.LoggingReceiver { return &LoggingReceiverRabbitmq{} }) | ||
| confgenerator.RegisterLoggingReceiverMacro(func() LoggingReceiverMacroRabbitmq { | ||
franciscovalentecastro marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return LoggingReceiverMacroRabbitmq{} | ||
| }) | ||
| } | ||
|
|
||
| type MetricsReceiverRabbitmq struct { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - type: rabbitmq |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| 2025-08-18 01:01:20.441571+00:00 [erro] <0.692.0> ** Connection attempt from node 'rabbit_ctl_17@keith-testing-rabbitmq' rejected. Invalid challenge reply. ** | ||
| 2025-08-18 01:05:10.000123+02:00 [info] <0.801.0> Successfully set user tags for user 'admin' to [administrator] | ||
| 2025-08-18 01:06:33.987654-07:00 [warning] <0.550.0> Queue 'task_queue' is nearing memory threshold. | ||
| 2025-08-18 01:45:14.705 [info] <0.801.0> Successfully set user tags for user 'guest' to [] | ||
| 2025-08-18 01:46:00.123 [debug] <0.200.0> Accepting AMQP connection <0.200.0> from 127.0.0.1:5672 | ||
| 2025-08-18 02:15:45.987+00:00 [error] <0.310.0> Login failed for user 'guest': invalid credentials | ||
| 2025-08-18 02:16:01.001+00:00 [warning] <0.312.0> User 'guest' attempted to access vhost '/' but was denied | ||
| 2025-08-18 02:22:33.444+00:00 [noti] <0.400.0> Node rabbit@node1 down: lost connection | ||
| 2025-08-18 02:23:00.999+00:00 [info] <0.401.0> Node rabbit@node1 recovered and rejoined cluster | ||
| 2025-08-18 02:55:55.123+00:00 [warning] <0.500.0> Memory high watermark reached (used: 2048MB, limit: 2000MB) | ||
| 2025-08-18 03:56:01.456+00:00 [erro] <0.501.0> Disk free space too low. Free bytes: 500000, limit: 1000000 | ||
| 2025-08-18 04:06:06.789+00:00 [erro] <0.600.0> AMQP connection <0.600.0> (10.0.0.1:5672 -> 10.0.0.2:5672): connection closed unexpectedly | ||
| 2025-08-18 04:06:10.101+00:00 [debug] <0.601.0> Re-establishing connection to peer rabbit@node2 | ||
| 2025-08-18 04:07:07.777+00:00 [noti] <123.456.789> {shutdown,{connection_closed, "Broken pipe"}} | ||
| 2025-08-18 04:07:08.888 [erro] <0.999.0> Unexpected exception: {'EXIT',{{badmatch,{error,enoent}},[{rabbit_misc,read_config,1,[]}]}} | ||
| 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 | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| - entries: | ||
| - jsonPayload: | ||
| message: "** Connection attempt from node 'rabbit_ctl_17@keith-testing-rabbitmq' rejected. Invalid challenge reply. **" | ||
| process_id: 0.692.0 | ||
| severity: erro | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/rabbitmq | ||
| logName: projects/my-project/logs/transformation_test | ||
| timestamp: 2025-08-18T01:01:20.441571000Z | ||
| - jsonPayload: | ||
| message: Successfully set user tags for user 'admin' to [administrator] | ||
| process_id: 0.801.0 | ||
| severity: info | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/rabbitmq | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 200.0 | ||
| timestamp: 2025-08-17T23:05:10.000123000Z | ||
| - jsonPayload: | ||
| message: 2025-08-18 01:06:33.987654-07:00 [warning] <0.550.0> Queue 'task_queue' is nearing memory threshold. | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/rabbitmq | ||
| logName: projects/my-project/logs/transformation_test | ||
| timestamp: now | ||
| - jsonPayload: | ||
| message: Successfully set user tags for user 'guest' to [] | ||
| process_id: 0.801.0 | ||
| severity: info | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/rabbitmq | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 200.0 | ||
| timestamp: 2025-08-18T01:45:14.705000000Z | ||
| - jsonPayload: | ||
| message: Accepting AMQP connection <0.200.0> from 127.0.0.1:5672 | ||
| process_id: 0.200.0 | ||
| severity: debug | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/rabbitmq | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 100.0 | ||
| timestamp: 2025-08-18T01:46:00.123000000Z | ||
| - jsonPayload: | ||
| message: "Login failed for user 'guest': invalid credentials" | ||
| process_id: 0.310.0 | ||
| severity: error | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/rabbitmq | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 500.0 | ||
| timestamp: 2025-08-18T02:15:45.987000000Z | ||
| - jsonPayload: | ||
| message: User 'guest' attempted to access vhost '/' but was denied | ||
| process_id: 0.312.0 | ||
| severity: warning | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/rabbitmq | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 400.0 | ||
| timestamp: 2025-08-18T02:16:01.001000000Z | ||
| - jsonPayload: | ||
| message: "Node rabbit@node1 down: lost connection" | ||
| process_id: 0.400.0 | ||
| severity: noti | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/rabbitmq | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 0.0 | ||
| timestamp: 2025-08-18T02:22:33.444000000Z | ||
| - jsonPayload: | ||
| message: Node rabbit@node1 recovered and rejoined cluster | ||
| process_id: 0.401.0 | ||
| severity: info | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/rabbitmq | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 200.0 | ||
| timestamp: 2025-08-18T02:23:00.999000000Z | ||
| - jsonPayload: | ||
| message: "Memory high watermark reached (used: 2048MB, limit: 2000MB)" | ||
| process_id: 0.500.0 | ||
| severity: warning | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/rabbitmq | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 400.0 | ||
| timestamp: 2025-08-18T02:55:55.123000000Z | ||
| - jsonPayload: | ||
| message: "Disk free space too low. Free bytes: 500000, limit: 1000000" | ||
| process_id: 0.501.0 | ||
| severity: erro | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/rabbitmq | ||
| logName: projects/my-project/logs/transformation_test | ||
| timestamp: 2025-08-18T03:56:01.456000000Z | ||
| - jsonPayload: | ||
| message: "AMQP connection <0.600.0> (10.0.0.1:5672 -> 10.0.0.2:5672): connection closed unexpectedly" | ||
| process_id: 0.600.0 | ||
| severity: erro | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/rabbitmq | ||
| logName: projects/my-project/logs/transformation_test | ||
| timestamp: 2025-08-18T04:06:06.789000000Z | ||
| - jsonPayload: | ||
| message: Re-establishing connection to peer rabbit@node2 | ||
| process_id: 0.601.0 | ||
| severity: debug | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/rabbitmq | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 100.0 | ||
| timestamp: 2025-08-18T04:06:10.101000000Z | ||
| - jsonPayload: | ||
| message: "{shutdown,{connection_closed, \"Broken pipe\"}}" | ||
| process_id: 123.456.789 | ||
| severity: noti | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/rabbitmq | ||
| logName: projects/my-project/logs/transformation_test | ||
| severity: 0.0 | ||
| timestamp: 2025-08-18T04:07:07.777000000Z | ||
| - jsonPayload: | ||
| message: "Unexpected exception: {'EXIT',{{badmatch,{error,enoent}},[{rabbit_misc,read_config,1,[]}]}}" | ||
| process_id: 0.999.0 | ||
| severity: erro | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/rabbitmq | ||
| logName: projects/my-project/logs/transformation_test | ||
| timestamp: 2025-08-18T04:07:08.888000000Z | ||
| - jsonPayload: | ||
| message: 2025-08-18 05:07:43.557042+00:00 [erro] <0.130.0> | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/rabbitmq | ||
| logName: projects/my-project/logs/transformation_test | ||
| timestamp: now | ||
| - jsonPayload: | ||
| message: BOOT FAILED | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/rabbitmq | ||
| logName: projects/my-project/logs/transformation_test | ||
| timestamp: now | ||
| - jsonPayload: | ||
| message: =========== | ||
| labels: | ||
| logging.googleapis.com/instrumentation_source: agent.googleapis.com/rabbitmq | ||
| logName: projects/my-project/logs/transformation_test | ||
| timestamp: now | ||
| partialSuccess: true | ||
| resource: | ||
| labels: {} | ||
| type: gce_instance |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - config_error: "failed generating OTel processor: &confgenerator.loggingProcessorMacroAdapter[github.com/GoogleCloudPlatform/ops-agent/apps.LoggingProcessorMacroRabbitmq]{ConfigComponent:confgenerator.ConfigComponent{Type:\"rabbitmq\"}, ProcessorMacro:apps.LoggingProcessorMacroRabbitmq{}}, err: unimplemented" |
Uh oh!
There was an error while loading. Please reload this page.