字符串替换
Last updated
Last updated
echo 'hello,how old are you? nice to meet you' >> /home/test-log/string_replace.logenable: true
inputs:
- Type: input_file
FilePaths:
- /home/test-log/*.log
processors:
- Type: processor_string_replace
SourceKey: content
Method: const
Match: 'how old are you?'
ReplaceString: ''
flushers:
- Type: flusher_stdout
OnlyStdout: true{
"__tag__:__path__": "/home/test_log/string_replace.log",
"content": "hello, nice to meet you",
"__time__": "1680353730"
}echo '2022-09-16 09:03:31.013 \u001b[32mINFO \u001b[0;39m \u001b[34m[TID: N/A]\u001b[0;39m [\u001b[35mThread-30\u001b[0;39m] \u001b[36mc.s.govern.polygonsync.job.BlockTask\u001b[0;39m : 区块采集------结束------\r' >> /home/test-log/string_replace.logenable: true
inputs:
- Type: input_file
FilePaths:
- /home/test-log/*.log
processors:
- Type: processor_string_replace
SourceKey: content
Method: regex
Match: \\u\w+\[\d{1,3};*\d{1,3}m|N/A
ReplaceString: ''
flushers:
- Type: flusher_stdout
OnlyStdout: true{
"__tag__:__path__": "/home/test_log/string_replace.log",
"content": "2022-09-16 09:03:31.013 INFO [TID: ] [Thread-30] c.s.govern.polygonsync.job.BlockTask : 区块采集------结束------\r",
"__time__": "1680353730"
}echo '10.10.239.16' >> /home/test-log/string_replace.logenable: true
inputs:
- Type: input_file
FilePaths:
- /home/test-log/*.log
processors:
- Type: processor_string_replace
SourceKey: content
Method: regex
Match: (\d.*\.)\d+
ReplaceString: $1*/24
DestKey: new_ip
flushers:
- Type: flusher_stdout
OnlyStdout: true{
"__tag__:__path__": "/home/test_log/string_replace.log",
"content": "10.10.239.16",
"new_ip": "10.10.239.*/24",
"__time__": "1680353730"
}echo '{\\x22UNAME\\x22:\\x22\\x22,\\x22GID\\x22:\\x22\\x22,\\x22PAID\\x22:\\x22\\x22,\\x22UUID\\x22:\\x22\\x22,\\x22STARTTIME\\x22:\\x22\\x22,\\x22ENDTIME\\x22:\\x22\\x22,\\x22UID\\x22:\\x222154212790\\x22,\\x22page_num\\x22:1,\\x22page_size\\x22:10}' >> /home/test-log/string_replace.log
echo '\\u554a\\u554a\\u554a' >> /home/test-log/string_replace.logenable: true
inputs:
- Type: input_file
FilePaths:
- /home/test-log/*.log
processors:
- Type: processor_string_replace
SourceKey: content
Method: unquote
flushers:
- Type: flusher_stdout
OnlyStdout: true{
"__tag__:__path__": "/home/test_log/string_replace.log",
"content": "{\"UNAME\":\"\",\"GID\":\"\",\"PAID\":\"\",\"UUID\":\"\",\"STARTTIME\":\"\",\"ENDTIME\":\"\",\"UID\":\"2154212790\",\"page_num\":1,\"page_size\":10}",
"__time__": "1680353730"
}
{
"__tag__:__path__": "/home/test_log/string_replace.log",
"content": "啊啊啊",
"__time__": "1680353730"
}