Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 50 additions & 61 deletions apps/rabbitmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,62 @@ 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.LoggingProcessorParseMultilineRegex{
LoggingProcessorParseRegexComplex: 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",
// Some multiline entries related to crash logs are important to capture and end in
//
// 2022-01-31 18: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
//
Rules: []confgenerator.MultilineRule{
{
StateName: "start_state",
NextState: "cont",
Regex: `^\d+-\d+-\d+ \d+:\d+:\d+\.\d+\+\d+:\d+`,
},
{
StateName: "cont",
NextState: "cont",
Regex: `^(?!\d+-\d+-\d+ \d+:\d+:\d+\.\d+\+\d+:\d+)`,
},
},
},
}.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": {
Expand All @@ -72,49 +89,21 @@ 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"`
},
}
}

func (r LoggingReceiverRabbitmq) Components(ctx context.Context, tag string) []fluentbit.Component {
if len(r.ReceiverMixin.IncludePaths) == 0 {
r.ReceiverMixin.IncludePaths = []string{
func loggingReceiverFilesMixinRabbitmq() confgenerator.LoggingReceiverFilesMixin {
return confgenerator.LoggingReceiverFilesMixin{
IncludePaths: []string{
"/var/log/rabbitmq/rabbit*.log",
}
}
// Some multiline entries related to crash logs are important to capture and end in
//
// 2022-01-31 18: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
//
r.ReceiverMixin.MultilineRules = []confgenerator.MultilineRule{
{
StateName: "start_state",
NextState: "cont",
Regex: `^\d+-\d+-\d+ \d+:\d+:\d+\.\d+\+\d+:\d+`,
},
{
StateName: "cont",
NextState: "cont",
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

}

func init() {
confgenerator.LoggingReceiverTypes.RegisterType(func() confgenerator.LoggingReceiver { return &LoggingReceiverRabbitmq{} })
confgenerator.RegisterLoggingFilesProcessorMacro[LoggingProcessorMacroRabbitmq](loggingReceiverFilesMixinRabbitmq)
}

type MetricsReceiverRabbitmq struct {
Expand Down
7 changes: 3 additions & 4 deletions confgenerator/testdata/feature/golden.csv
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ App,Field,Override,
*apps.LoggingReceiverOracleDBAudit,confgenerator.LoggingReceiverFilesMixin.BufferInMemory,
*apps.LoggingReceiverOracleDBAudit,confgenerator.LoggingReceiverFilesMixin.RecordLogFilePath,
*apps.LoggingReceiverOracleDBAudit,confgenerator.LoggingReceiverFilesMixin.WildcardRefreshInterval,
*apps.LoggingReceiverRabbitmq,apps.LoggingProcessorRabbitmq.confgenerator.ConfigComponent.Type,
*apps.LoggingReceiverRabbitmq,confgenerator.LoggingReceiverFilesMixin.BufferInMemory,
*apps.LoggingReceiverRabbitmq,confgenerator.LoggingReceiverFilesMixin.RecordLogFilePath,
*apps.LoggingReceiverRabbitmq,confgenerator.LoggingReceiverFilesMixin.WildcardRefreshInterval,
*apps.LoggingReceiverSapHanaTrace,apps.LoggingProcessorSapHanaTrace.confgenerator.ConfigComponent.Type,
*apps.LoggingReceiverSapHanaTrace,confgenerator.LoggingReceiverFilesMixin.BufferInMemory,
*apps.LoggingReceiverSapHanaTrace,confgenerator.LoggingReceiverFilesMixin.RecordLogFilePath,
Expand Down Expand Up @@ -178,6 +174,7 @@ App,Field,Override,
*confgenerator.loggingProcessorMacroAdapter[github.com/GoogleCloudPlatform/ops-agent/apps.LoggingProcessorMacroNginxAccess],confgenerator.ConfigComponent.Type,
*confgenerator.loggingProcessorMacroAdapter[github.com/GoogleCloudPlatform/ops-agent/apps.LoggingProcessorMacroNginxError],confgenerator.ConfigComponent.Type,
*confgenerator.loggingProcessorMacroAdapter[github.com/GoogleCloudPlatform/ops-agent/apps.LoggingProcessorMacroPostgresql],confgenerator.ConfigComponent.Type,
*confgenerator.loggingProcessorMacroAdapter[github.com/GoogleCloudPlatform/ops-agent/apps.LoggingProcessorMacroRabbitmq],confgenerator.ConfigComponent.Type,
*confgenerator.loggingProcessorMacroAdapter[github.com/GoogleCloudPlatform/ops-agent/apps.LoggingProcessorMacroRedis],confgenerator.ConfigComponent.Type,
*confgenerator.loggingProcessorMacroAdapter[github.com/GoogleCloudPlatform/ops-agent/apps.LoggingProcessorMacroSolrSystem],apps.LoggingProcessorMacroSolrSystem.confgenerator.ConfigComponent.Type,
*confgenerator.loggingProcessorMacroAdapter[github.com/GoogleCloudPlatform/ops-agent/apps.LoggingProcessorMacroSolrSystem],confgenerator.ConfigComponent.Type,
Expand Down Expand Up @@ -218,6 +215,8 @@ App,Field,Override,
*confgenerator.loggingReceiverMacroAdapter[*github.com/GoogleCloudPlatform/ops-agent/confgenerator.loggingFilesProcessorMacroAdapter[github.com/GoogleCloudPlatform/ops-agent/apps.LoggingProcessorMacroNginxError]],confgenerator.ConfigComponent.Type,
*confgenerator.loggingReceiverMacroAdapter[*github.com/GoogleCloudPlatform/ops-agent/confgenerator.loggingFilesProcessorMacroAdapter[github.com/GoogleCloudPlatform/ops-agent/apps.LoggingProcessorMacroPostgresql]],ReceiverMacro,
*confgenerator.loggingReceiverMacroAdapter[*github.com/GoogleCloudPlatform/ops-agent/confgenerator.loggingFilesProcessorMacroAdapter[github.com/GoogleCloudPlatform/ops-agent/apps.LoggingProcessorMacroPostgresql]],confgenerator.ConfigComponent.Type,
*confgenerator.loggingReceiverMacroAdapter[*github.com/GoogleCloudPlatform/ops-agent/confgenerator.loggingFilesProcessorMacroAdapter[github.com/GoogleCloudPlatform/ops-agent/apps.LoggingProcessorMacroRabbitmq]],ReceiverMacro,
*confgenerator.loggingReceiverMacroAdapter[*github.com/GoogleCloudPlatform/ops-agent/confgenerator.loggingFilesProcessorMacroAdapter[github.com/GoogleCloudPlatform/ops-agent/apps.LoggingProcessorMacroRabbitmq]],confgenerator.ConfigComponent.Type,
*confgenerator.loggingReceiverMacroAdapter[*github.com/GoogleCloudPlatform/ops-agent/confgenerator.loggingFilesProcessorMacroAdapter[github.com/GoogleCloudPlatform/ops-agent/apps.LoggingProcessorMacroRedis]],ReceiverMacro,
*confgenerator.loggingReceiverMacroAdapter[*github.com/GoogleCloudPlatform/ops-agent/confgenerator.loggingFilesProcessorMacroAdapter[github.com/GoogleCloudPlatform/ops-agent/apps.LoggingProcessorMacroRedis]],confgenerator.ConfigComponent.Type,
*confgenerator.loggingReceiverMacroAdapter[*github.com/GoogleCloudPlatform/ops-agent/confgenerator.loggingFilesProcessorMacroAdapter[github.com/GoogleCloudPlatform/ops-agent/apps.LoggingProcessorMacroSolrSystem]],ReceiverMacro,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
logging processor with type "unsupported" is not supported. Supported logging processor types: [apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchdb, elasticsearch_gc, elasticsearch_json, exclude_logs, flink, hbase_system, jetty_access, kafka, modify_fields, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, parse_json, parse_multiline, parse_regex, postgresql_general, redis, saphana, solr_system, tomcat_access, tomcat_system, varnish, wildfly_system].
logging processor with type "unsupported" is not supported. Supported logging processor types: [apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchdb, elasticsearch_gc, elasticsearch_json, exclude_logs, flink, hbase_system, jetty_access, kafka, modify_fields, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, parse_json, parse_multiline, parse_regex, postgresql_general, rabbitmq, redis, saphana, solr_system, tomcat_access, tomcat_system, varnish, wildfly_system].
Original file line number Diff line number Diff line change
@@ -1 +1 @@
logging processor with type "unsupported" is not supported. Supported logging processor types: [apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchdb, elasticsearch_gc, elasticsearch_json, exclude_logs, flink, hbase_system, jetty_access, kafka, modify_fields, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, parse_json, parse_multiline, parse_regex, postgresql_general, redis, saphana, solr_system, tomcat_access, tomcat_system, varnish, wildfly_system].
logging processor with type "unsupported" is not supported. Supported logging processor types: [apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchdb, elasticsearch_gc, elasticsearch_json, exclude_logs, flink, hbase_system, jetty_access, kafka, modify_fields, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, parse_json, parse_multiline, parse_regex, postgresql_general, rabbitmq, redis, saphana, solr_system, tomcat_access, tomcat_system, varnish, wildfly_system].
Original file line number Diff line number Diff line change
@@ -1 +1 @@
logging processor with type "unsupported" is not supported. Supported logging processor types: [apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchdb, elasticsearch_gc, elasticsearch_json, exclude_logs, flink, hbase_system, iis_access, jetty_access, kafka, modify_fields, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, parse_json, parse_multiline, parse_regex, postgresql_general, redis, saphana, solr_system, tomcat_access, tomcat_system, varnish, wildfly_system].
logging processor with type "unsupported" is not supported. Supported logging processor types: [apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchdb, elasticsearch_gc, elasticsearch_json, exclude_logs, flink, hbase_system, iis_access, jetty_access, kafka, modify_fields, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, parse_json, parse_multiline, parse_regex, postgresql_general, rabbitmq, redis, saphana, solr_system, tomcat_access, tomcat_system, varnish, wildfly_system].
Original file line number Diff line number Diff line change
@@ -1 +1 @@
logging processor with type "unsupported" is not supported. Supported logging processor types: [apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchdb, elasticsearch_gc, elasticsearch_json, exclude_logs, flink, hbase_system, iis_access, jetty_access, kafka, modify_fields, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, parse_json, parse_multiline, parse_regex, postgresql_general, redis, saphana, solr_system, tomcat_access, tomcat_system, varnish, wildfly_system].
logging processor with type "unsupported" is not supported. Supported logging processor types: [apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchdb, elasticsearch_gc, elasticsearch_json, exclude_logs, flink, hbase_system, iis_access, jetty_access, kafka, modify_fields, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, parse_json, parse_multiline, parse_regex, postgresql_general, rabbitmq, redis, saphana, solr_system, tomcat_access, tomcat_system, varnish, wildfly_system].
Original file line number Diff line number Diff line change
@@ -1 +1 @@
logging processor with type "unsupported_type" is not supported. Supported logging processor types: [apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchdb, elasticsearch_gc, elasticsearch_json, exclude_logs, flink, hbase_system, jetty_access, kafka, modify_fields, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, parse_json, parse_multiline, parse_regex, postgresql_general, redis, saphana, solr_system, tomcat_access, tomcat_system, varnish, wildfly_system].
logging processor with type "unsupported_type" is not supported. Supported logging processor types: [apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchdb, elasticsearch_gc, elasticsearch_json, exclude_logs, flink, hbase_system, jetty_access, kafka, modify_fields, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, parse_json, parse_multiline, parse_regex, postgresql_general, rabbitmq, redis, saphana, solr_system, tomcat_access, tomcat_system, varnish, wildfly_system].
Original file line number Diff line number Diff line change
@@ -1 +1 @@
logging processor with type "unsupported_type" is not supported. Supported logging processor types: [apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchdb, elasticsearch_gc, elasticsearch_json, exclude_logs, flink, hbase_system, jetty_access, kafka, modify_fields, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, parse_json, parse_multiline, parse_regex, postgresql_general, redis, saphana, solr_system, tomcat_access, tomcat_system, varnish, wildfly_system].
logging processor with type "unsupported_type" is not supported. Supported logging processor types: [apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchdb, elasticsearch_gc, elasticsearch_json, exclude_logs, flink, hbase_system, jetty_access, kafka, modify_fields, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, parse_json, parse_multiline, parse_regex, postgresql_general, rabbitmq, redis, saphana, solr_system, tomcat_access, tomcat_system, varnish, wildfly_system].
Original file line number Diff line number Diff line change
@@ -1 +1 @@
logging processor with type "unsupported_type" is not supported. Supported logging processor types: [apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchdb, elasticsearch_gc, elasticsearch_json, exclude_logs, flink, hbase_system, iis_access, jetty_access, kafka, modify_fields, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, parse_json, parse_multiline, parse_regex, postgresql_general, redis, saphana, solr_system, tomcat_access, tomcat_system, varnish, wildfly_system].
logging processor with type "unsupported_type" is not supported. Supported logging processor types: [apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchdb, elasticsearch_gc, elasticsearch_json, exclude_logs, flink, hbase_system, iis_access, jetty_access, kafka, modify_fields, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, parse_json, parse_multiline, parse_regex, postgresql_general, rabbitmq, redis, saphana, solr_system, tomcat_access, tomcat_system, varnish, wildfly_system].
Original file line number Diff line number Diff line change
@@ -1 +1 @@
logging processor with type "unsupported_type" is not supported. Supported logging processor types: [apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchdb, elasticsearch_gc, elasticsearch_json, exclude_logs, flink, hbase_system, iis_access, jetty_access, kafka, modify_fields, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, parse_json, parse_multiline, parse_regex, postgresql_general, redis, saphana, solr_system, tomcat_access, tomcat_system, varnish, wildfly_system].
logging processor with type "unsupported_type" is not supported. Supported logging processor types: [apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchdb, elasticsearch_gc, elasticsearch_json, exclude_logs, flink, hbase_system, iis_access, jetty_access, kafka, modify_fields, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, parse_json, parse_multiline, parse_regex, postgresql_general, rabbitmq, redis, saphana, solr_system, tomcat_access, tomcat_system, varnish, wildfly_system].
Loading
Loading