使用系统时间作为日志时间上传
日志样例
使用系统时间作为日志时间上传
日志样例
- [backcolor=transparent]10.116[backcolor=transparent].[backcolor=transparent]14.201[backcolor=transparent],-,[backcolor=transparent]2[backcolor=transparent]/[backcolor=transparent]25[backcolor=transparent]/[backcolor=transparent]2016[backcolor=transparent],[backcolor=transparent]11[backcolor=transparent]:[backcolor=transparent]53[backcolor=transparent]:[backcolor=transparent]17[backcolor=transparent],[backcolor=transparent]W3SVC7[backcolor=transparent],[backcolor=transparent]2132[backcolor=transparent],[backcolor=transparent]200[backcolor=transparent],[backcolor=transparent]0[backcolor=transparent],[backcolor=transparent]GET[backcolor=transparent],[backcolor=transparent]project[backcolor=transparent]/[backcolor=transparent]shenzhen[backcolor=transparent]-[backcolor=transparent]test[backcolor=transparent]/[backcolor=transparent]logstore[backcolor=transparent]/[backcolor=transparent]logstash[backcolor=transparent]/[backcolor=transparent]detail[backcolor=transparent],[backcolor=transparent]C[backcolor=transparent]:[backcolor=transparent]\test\csv\test_csv[backcolor=transparent].[backcolor=transparent]log
采集配置
- [backcolor=transparent]input [backcolor=transparent]{
- [backcolor=transparent] file [backcolor=transparent]{
- [backcolor=transparent] type [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]"csv_log_1"
- [backcolor=transparent] path [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent][[backcolor=transparent]"C:/test/csv/*.log"[backcolor=transparent]]
- [backcolor=transparent] start_position [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]"beginning"
- [backcolor=transparent] [backcolor=transparent]}
- [backcolor=transparent]}
- [backcolor=transparent]filter [backcolor=transparent]{
- [backcolor=transparent] [backcolor=transparent]if[backcolor=transparent] [backcolor=transparent][[backcolor=transparent]type[backcolor=transparent]][backcolor=transparent] [backcolor=transparent]==[backcolor=transparent] [backcolor=transparent]"csv_log_1"[backcolor=transparent] [backcolor=transparent]{
- [backcolor=transparent] csv [backcolor=transparent]{
- [backcolor=transparent] separator [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]","
- [backcolor=transparent] columns [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent][[backcolor=transparent]"ip"[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]"a"[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]"date"[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]"time"[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]"b"[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]"latency"[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]"status"[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]"size"[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]"method"[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]"url"[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]"file"[backcolor=transparent]]
- [backcolor=transparent] [backcolor=transparent]}[backcolor=transparent]
- [backcolor=transparent] [backcolor=transparent]}
- [backcolor=transparent]}
- [backcolor=transparent]output [backcolor=transparent]{
- [backcolor=transparent] [backcolor=transparent]if[backcolor=transparent] [backcolor=transparent][[backcolor=transparent]type[backcolor=transparent]][backcolor=transparent] [backcolor=transparent]==[backcolor=transparent] [backcolor=transparent]"csv_log_1"[backcolor=transparent] [backcolor=transparent]{
- [backcolor=transparent] logservice [backcolor=transparent]{
- [backcolor=transparent] codec [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]"json"
- [backcolor=transparent] endpoint [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]"***"
- [backcolor=transparent] project [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]"***"
- [backcolor=transparent] logstore [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]"***"
- [backcolor=transparent] topic [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]""
- [backcolor=transparent] source [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]""
- [backcolor=transparent] access_key_id [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]"***"
- [backcolor=transparent] access_key_secret [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]"***"
- [backcolor=transparent] max_send_retry [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]10
- [backcolor=transparent] [backcolor=transparent]}
- [backcolor=transparent] [backcolor=transparent]}
- [backcolor=transparent]}
[backcolor=transparent]注意:
- 配置文件格式必须以 UTF-8 无 BOM 格式编码,可以下载 notepad++ 修改文件编码格式。
- path 填写文件路径时请使用 UNIX 模式的分隔符,如:C:/test/multiline/*.log,否则无法支持模糊匹配。
- type 字段需要统一修改并在该文件内保持一致,如果单台机器存在多个Logstash配置文件,需要保证各配置type 字段唯一,否则会导致数据处理的错乱。
相关插件:
file、
csv。
重启Logstash生效
创建配置文件到 conf 目录,参考
配置Logstash重启Logstash生效。
使用日志字段内容作为日志时间上传
日志样例
- [backcolor=transparent]10.116[backcolor=transparent].[backcolor=transparent]14.201[backcolor=transparent],-,[backcolor=transparent]Feb[backcolor=transparent] [backcolor=transparent]25[backcolor=transparent] [backcolor=transparent]2016[backcolor=transparent] [backcolor=transparent]14[backcolor=transparent]:[backcolor=transparent]03[backcolor=transparent]:[backcolor=transparent]44[backcolor=transparent],[backcolor=transparent]W3SVC7[backcolor=transparent],[backcolor=transparent]1332[backcolor=transparent],[backcolor=transparent]200[backcolor=transparent],[backcolor=transparent]0[backcolor=transparent],[backcolor=transparent]GET[backcolor=transparent],[backcolor=transparent]project[backcolor=transparent]/[backcolor=transparent]shenzhen[backcolor=transparent]-[backcolor=transparent]test[backcolor=transparent]/[backcolor=transparent]logstore[backcolor=transparent]/[backcolor=transparent]logstash[backcolor=transparent]/[backcolor=transparent]detail[backcolor=transparent],[backcolor=transparent]C[backcolor=transparent]:[backcolor=transparent]\test\csv\test_csv_withtime[backcolor=transparent].[backcolor=transparent]log
采集配置
- [backcolor=transparent]input [backcolor=transparent]{
- [backcolor=transparent] file [backcolor=transparent]{
- [backcolor=transparent] type [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]"csv_log_2"
- [backcolor=transparent] path [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent][[backcolor=transparent]"C:/test/csv_withtime/*.log"[backcolor=transparent]]
- [backcolor=transparent] start_position [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]"beginning"
- [backcolor=transparent] [backcolor=transparent]}
- [backcolor=transparent]}
- [backcolor=transparent]filter [backcolor=transparent]{
- [backcolor=transparent] [backcolor=transparent]if[backcolor=transparent] [backcolor=transparent][[backcolor=transparent]type[backcolor=transparent]][backcolor=transparent] [backcolor=transparent]==[backcolor=transparent] [backcolor=transparent]"csv_log_2"[backcolor=transparent] [backcolor=transparent]{
- [backcolor=transparent] csv [backcolor=transparent]{
- [backcolor=transparent] separator [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]","
- [backcolor=transparent] columns [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent][[backcolor=transparent]"ip"[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]"a"[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]"datetime"[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]"b"[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]"latency"[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]"status"[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]"size"[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]"method"[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]"url"[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]"file"[backcolor=transparent]]
- [backcolor=transparent] [backcolor=transparent]}[backcolor=transparent]
- [backcolor=transparent] date [backcolor=transparent]{
- [backcolor=transparent] match [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent][[backcolor=transparent] [backcolor=transparent]"datetime"[backcolor=transparent] [backcolor=transparent],[backcolor=transparent] [backcolor=transparent]"MMM dd YYYY HH:mm:ss"[backcolor=transparent] [backcolor=transparent]]
- [backcolor=transparent] [backcolor=transparent]}
- [backcolor=transparent] [backcolor=transparent]}
- [backcolor=transparent]}
- [backcolor=transparent]output [backcolor=transparent]{
- [backcolor=transparent] [backcolor=transparent]if[backcolor=transparent] [backcolor=transparent][[backcolor=transparent]type[backcolor=transparent]][backcolor=transparent] [backcolor=transparent]==[backcolor=transparent] [backcolor=transparent]"csv_log_2"[backcolor=transparent] [backcolor=transparent]{
- [backcolor=transparent] logservice [backcolor=transparent]{
- [backcolor=transparent] codec [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]"json"
- [backcolor=transparent] endpoint [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]"***"
- [backcolor=transparent] project [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]"***"
- [backcolor=transparent] logstore [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]"***"
- [backcolor=transparent] topic [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]""
- [backcolor=transparent] source [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]""
- [backcolor=transparent] access_key_id [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]"***"
- [backcolor=transparent] access_key_secret [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]"***"
- [backcolor=transparent] max_send_retry [backcolor=transparent]=>[backcolor=transparent] [backcolor=transparent]10
- [backcolor=transparent] [backcolor=transparent]}
- [backcolor=transparent] [backcolor=transparent]}
- [backcolor=transparent]}
[backcolor=transparent]注意:
- 配置文件格式必须以 UTF-8 无 BOM 格式编码,可以下载 notepad++ 修改文件编码格式。
- path 填写文件路径时请使用 UNIX 模式的分隔符,如:C:/test/multiline/*.log,否则无法支持模糊匹配。
- type 字段需要统一修改并在该文件内保持一致,如果单台机器存在多个Logstash配置文件,需要保证各配置type 字段唯一,否则会导致数据处理的错乱。
相关插件:
file、
csv、
date。
重启Logstash生效
创建配置文件到 conf 目录,参考
配置Logstash重启Logstash生效。