Имеется nginx.conf
nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '"$remote_addr" "$time_iso8601"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
Логи access.log
"127.0.0.1" "2019-12-28T10:53:20+00:00"
"127.0.0.1" "2019-12-28T10:53:20+00:00"
Имеется fluent(td-agent)
td-agent.conf
<source>
@type tail
path /var/log/nginx/access.log
pos_file /tmp/nginx-access-log.pos
tag nginx
format /"(?<remote_addr>[0-9,\.]*)" "(?<time_iso8601>[^ ]*)"/
time_format %Y-%m-%dT%H:%M:%S.%NZ
</source>
<filter foo.bar>
@type record_transformer
enable_ruby
<record>
time_iso8601 ${Time.strptime(record['time_iso8601'], '%Y-%m-%d %H:%M:%S').iso8601}
</record>
</filter>
<match nginx>
@type clickhousejson
host 127.0.0.1
port 8123
database fluent
table fluent
datetime_name time_iso8601
</match>
В clickhouse создал бд и таблицу.
create database fluent;
CREATE TABLE fluent.fluent (Date Date MATERIALIZED toDate(DateTime), remoteip String, DateTime DateTime) ENGINE = MergeTree(Date, DateTime, 8192);
Логи отправляются в clickhouse.
│ │ 0000-00-00 00:00:00 │
│ │ 0000-00-00 00:00:00 │
│ │ 0000-00-00 00:00:00 │
Как изменить time_format в fluentd(td-agent) из time_iso8601 в %Y-%m-%d %H:%M:%S и отправить их в clickhouse?