ilogtail收集nginx accesslog文档
nginx 日志配置
Nginx.conf
log_format main '{"@timestamp": "$time_iso8601", '
'"remote_addr": "$remote_addr", '
'"referer": "$http_referer", '
'"request": "$request", '
'"status": $status, '
'"bytes": $body_bytes_sent, '
'"agent": "$http_user_agent", '
'"x_forwarded": "$http_x_forwarded_for", '
'"up_addr": "$upstream_addr",'
'"up_host": "$upstream_http_host",'
'"up_resp_time": "$upstream_response_time",'
'"request_time": "$request_time"'
' }';
access_log /var/log/nginx/access.log main;
ilogtail 配置
user_yaml_config.d/file_simple.yaml
enable: true
inputs: # 收集器
- Type: file_log
LogPath: /var/log/nginx
FilePattern: access.log
processors: # 处理器
- Type: processor_json # json处理器
SourceKey: content
KeepSource: false
ExpandDepth: 1
ExpandConnector: ""
flushers: # 输出器
- Type: flusher_elasticsearch
Addresses:
- http://127.0.0.1:9200
Authentication:
PlainText:
Username: elastic
Password: 123456
Convert: # 数据平铺写入
Protocol: custom_single_flatten
Encoding: json
Index: nginx_accesslog_%{+yyyyMMdd}
kibana
Stack Management =》 Data Views =》 Create data view 创建
浙公网安备 33010602011771号