How to use td-agent-bit to output log files as messages?

54 Views Asked by At

How to use td-agent-bit to output log files as messages, either on a per-line basis or for lines that start with "HH:mm:ss," and send them downstream, instead of outputting multiple lines of logs together each time? logs:

15:42:43 [cmd:local,tid:xxx]
15:42:43 [tid:xxx]

I want messages like below:

{
    "message":" 15:42:43 [cmd:local,tid:xxx]",
    "type":"test-log",
    "@version":"1",
    "port":31426,
    "@timestamp":"2023-09-08T10:59:45.806Z",
    "host":"172.31.48.61"
}

{
    "message":" 15:42:43 [tid:xxx]    ",
    "type":"test-log",
    "@version":"1",
    "port":31426,
    "@timestamp":"2023-09-08T10:59:45.806Z",
    "host":"172.31.48.61"
}

not:

{
    "message":" 15:42:43 [cmd:local,tid:xxx] 15:42:43 [tid:xxx]",
    "type":"test-log",
    "@version":"1",
    "port":31426,
    "@timestamp":"2023-09-08T10:59:45.806Z",
    "host":"172.31.48.61"
}

0

There are 0 best solutions below