in apps/couchdb.go [79:154]
func (p LoggingProcessorCouchdb) Components(ctx context.Context, tag string, uid string) []fluentbit.Component {
c := confgenerator.LoggingProcessorParseMultilineRegex{
LoggingProcessorParseRegexComplex: confgenerator.LoggingProcessorParseRegexComplex{
Parsers: []confgenerator.RegexParser{
{
// Format https://github.com/apache/couchdb/blob/main/src/couch_log/src/couch_log_writer_syslog.erl#L72
// Sample line: [notice] 2021-12-02T23:36:42.555157Z nonode@nohost <0.17165.1> a5f585a0d3 localhost:5984 127.0.0.1 otelu PUT /oteld 201 ok 16
Regex: `^\[(?<level>\w*)\] (?<timestamp>[\d\-\.:TZ]+) (?<node>\S+)@(?<host>[^\s]+) \<(?<pid>[^ ]*)\> [\w-]+ (?<http_request_serverIp>[^ ]*) (?<http_request_remoteIp>[^ ]*) (?<message>(?<remote_user>[^ ]*) (?<http_request_requestMethod>[^ ]*) (?<path>[^ ]*) (?<http_request_status>[^ ]*) (?<status_message>[^ ]*) (?<http_request_responseSize>[\d]*)$)`,
Parser: confgenerator.ParserShared{
TimeKey: "timestamp",
TimeFormat: "%Y-%m-%dT%H:%M:%S.%L%z",
Types: map[string]string{
"http_request_status": "integer",
},
},
},
{
/* Format https://github.com/apache/couchdb/blob/main/src/couch_log/src/couch_log_writer_syslog.erl#L72
Sample line1: [info] 2022-01-12T16:52:56.998128Z nonode@nohost <0.216.0> -------- Apache CouchDB has started. Time to relax.
Sample line2:
[error] 2022-01-12T16:53:03.094488Z nonode@nohost emulator -------- Error in process <0.463.0> with exit value:
{database_does_not_exist,[{mem3_shards,load_shards_from_db,"_users",[{file,"src/mem3_shards.erl"},{line,399}]},{mem3_shards,load_shards_from_disk,1,[{file,"src/mem3_shards.erl"},{line,374}]},{mem3_shards,load_shards_from_disk,2,[{file,"src/mem3_shards.erl"},{line,403}]},{mem3_shards,for_docid,3,[{file,"src/mem3_shards.erl"},{line,96}]},{fabric_doc_open,go,3,[{file,"src/fabric_doc_open.erl"},{line,39}]},{chttpd_auth_cache,ensure_auth_ddoc_exists,2,[{file,"src/chttpd_auth_cache.erl"},{line,198}]},{chttpd_auth_cache,listen_for_changes,1,[{file,"src/chttpd_auth_cache.erl"},{line,145}]}]}
*/
Regex: `^\[(?<level>\w*)\] (?<timestamp>[\d\-\.:TZ]+) (?<node>\S+)@(?<host>[^\s]+) (?<message>[\s\S]*(\<(?<pid>[^>]+)\>)[\s\S]*)`,
Parser: confgenerator.ParserShared{
TimeKey: "timestamp",
TimeFormat: "%Y-%m-%dT%H:%M:%S.%L%z",
},
},
},
},
}.Components(ctx, tag, uid)
fields := map[string]*confgenerator.ModifyField{
"severity": {
CopyFrom: "jsonPayload.level",
MapValues: map[string]string{
"emerg": "EMERGENCY",
"emergency": "EMERGENCY",
"alert": "ALERT",
"crit": "CRITICAL",
"critical": "CRITICAL",
"error": "ERROR",
"err": "ERROR",
"warn": "WARNING",
"warning": "WARNING",
"notice": "NOTICE",
"info": "INFO",
"debug": "DEBUG",
},
MapValuesExclusive: true,
},
InstrumentationSourceLabel: instrumentationSourceValue(p.Type()),
}
// Generate the httpRequest structure.
for _, field := range []string{
"serverIp",
"remoteIp",
"requestMethod",
"status",
"responseSize",
} {
fields[fmt.Sprintf("httpRequest.%s", field)] = &confgenerator.ModifyField{
MoveFrom: fmt.Sprintf("jsonPayload.http_request_%s", field),
}
}
// Log levels documented: https://docs.couchdb.org/en/stable/config/logging.html#log/level
c = append(c,
confgenerator.LoggingProcessorModifyFields{
Fields: fields,
}.Components(ctx, tag, uid)...,
)
return c
}