func()

in apps/saphana.go [34:96]


func (p LoggingProcessorSapHanaTrace) Components(ctx context.Context, tag string, uid string) []fluentbit.Component {
	c := confgenerator.LoggingProcessorParseRegex{
		// Undocumented Format: [thread_id]{connection_id}[transaction_id/update_transaction_id] timestamp severity_flag component source_file : message
		// Sample line: [7893]{200068}[20/40637286] 2021-11-04 13:13:25.025767 w FileIO           FileSystem.cpp(00085) : Unsupported file system "ext4" for "/usr/sap/MMM/SYS/global/hdb/data/mnt00001"
		// Sample line: [18048]{-1}[-1/-1] 2020-11-10 12:24:23.424024 i Crypto           RootKeyStoreAccessor.cpp(00818) : Created new root key /usr/sap/MMM/SYS/global/hdb/security/ssfs:HDB_SERVER/3/PERSISTENCE
		// Sample line: [18048]{-1}[-1/-1] 2020-11-10 12:24:20.988943 e commlib          commlibImpl.cpp(00986) : ERROR: comm::connect to Host: 127.0.0.1, port: 30001, Error: exception  1: no.2110017  (Basis/IO/Stream/impl/NetworkChannel.cpp:2989)
		// 				System error: SO_ERROR has pending error for socket. rc=111: Connection refused. channel={<NetworkChannel>={<NetworkChannelBase>={this=139745749931736, fd=21, refCnt=1, local=127.0.0.1/58654_tcp, remote=127.0.0.1/30001_tcp, state=ConnectWait, pending=[----]}}}
		// 				exception throw location:
		// 				 1: 0x00007f1937d9095c in .LTHUNK27.lto_priv.2256+0x558 (libhdbbasis.so)
		// 				 ...
		//				 25: 0x0000563f44888831 in _GLOBAL__sub_I_setServiceStarting.cpp.lto_priv.239+0x520 (hdbnsutil)
		Regex: `^\[(?<thread_id>\d+)\]\{(?<connection_id>-?\d+)\}\[(?<transaction_id>-?\d+)\/(?<update_transaction_id>-?\d+)\]\s+(?<time>\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\.\d{3,6}\d+)\s+(?<severity_flag>\w+)\s+(?<component>\w+)\s+(?<source_file>[\w\.]+)(?:\((?<source_line>\d+)\))\s+:\s+(?<message>[\s\S]+)`,
		ParserShared: confgenerator.ParserShared{
			TimeKey:    "time",
			TimeFormat: "%Y-%m-%d %H:%M:%S.%L",
			Types: map[string]string{
				"thread_id":             "int",
				"connection_id":         "int",
				"transaction_id":        "int",
				"update_transaction_id": "int",
				"source_line":           "int",
			},
		},
	}.Components(ctx, tag, uid)

	c = append(c,
		confgenerator.LoggingProcessorModifyFields{
			Fields: map[string]*confgenerator.ModifyField{
				"severity": {
					CopyFrom: "jsonPayload.severity_flag",
					MapValues: map[string]string{
						"d": "DEBUG",
						"i": "INFO",
						"w": "WARNING",
						"e": "ERROR",
						"f": "ALERT",
					},
					MapValuesExclusive: true,
				},
				// If a log is not associated with a connection/transaction the related
				// fields will be "-1", and we do not want to report those fields
				"jsonPayload.connection_id": {
					OmitIf: "jsonPayload.connection_id = -1",
				},
				"jsonPayload.transaction_id": {
					OmitIf: "jsonPayload.transaction_id = -1",
				},
				"jsonPayload.update_transaction_id": {
					OmitIf: "jsonPayload.update_transaction_id = -1",
				},
				`sourceLocation.file`: {
					MoveFrom: "jsonPayload.source_file",
				},
				`sourceLocation.line`: {
					MoveFrom: "jsonPayload.source_line",
				},
				InstrumentationSourceLabel: instrumentationSourceValue(p.Type()),
			},
		}.Components(ctx, tag, uid)...,
	)

	return c
}