in apps/mysql.go [236:307]
func (p LoggingProcessorMysqlGeneral) Components(ctx context.Context, tag string, uid string) []fluentbit.Component {
c := confgenerator.LoggingProcessorParseMultilineRegex{
LoggingProcessorParseRegexComplex: confgenerator.LoggingProcessorParseRegexComplex{
Parsers: []confgenerator.RegexParser{
{
// Limited documentation: https://dev.mysql.com/doc/refman/8.0/en/query-log.html
// Sample line: 2021-10-12T01:12:37.732966Z 14 Connect root@localhost on using Socket
// Sample line: 2021-10-12T01:12:37.733135Z 14 Query select @@version_comment limit 1
Regex: fmt.Sprintf(
`^(?<time>%s)\s+(?<tid>\d+)\s+(?<command>\w+)(\s+(?<message>[\s|\S]*))?`,
timeRegexMySQLNew,
),
Parser: confgenerator.ParserShared{
TimeKey: "time",
TimeFormat: timeFormatMySQLNew,
Types: map[string]string{
"tid": "integer",
},
},
},
{
// MariaDB uses the same timestamp format here as old versions do for the error log:
// https://mariadb.com/kb/en/error-log/#format
// Sample line: 230707 1:41:38 40 Query select table_catalog, table_schema, table_name from information_schema.tables
// Sample line: 5 Connect root@localhost on using Socket
// When a timestamp is present, it is followed by a single tab character.
// When it is not, it means the timestamp is the same as a previous line, and it is replaced by another tab character.
Regex: fmt.Sprintf(
`^((?<time>%s)|\t)\s+(?<tid>\d+)\s+(?<command>\w+)(\s+(?<message>[\s|\S]*))?`,
timeRegexOld,
),
Parser: confgenerator.ParserShared{
TimeKey: "time",
TimeFormat: timeFormatOld,
Types: map[string]string{
"tid": "integer",
},
},
},
},
},
Rules: []confgenerator.MultilineRule{
{
StateName: "start_state",
NextState: "cont",
Regex: fmt.Sprintf(
`^(%s|%s|\t\t)`,
timeRegexMySQLNew,
timeRegexOld,
),
},
{
StateName: "cont",
NextState: "cont",
Regex: fmt.Sprintf(
`^(?!(%s|%s|\t\t))`,
timeRegexMySQLNew,
timeRegexOld,
),
},
},
}.Components(ctx, tag, uid)
c = append(c,
confgenerator.LoggingProcessorModifyFields{
Fields: map[string]*confgenerator.ModifyField{
InstrumentationSourceLabel: instrumentationSourceValue(p.Type()),
},
}.Components(ctx, tag, uid)...,
)
return c
}