Hello,
I have the problem.
I use Fluentd (td-agent, but I think it doesn't matter so much) for analyzing Nginx logs.
I have field "response_time" and I need to replace "dash" (-) to number (e.g. 0.000), because I need to use float field in Elasticsearch.
I use this:
<filter td.logstash.nginx.log>
@type record_transformer
enable_ruby
<record>
response_time == - ? 0.000 : ${response_time}
</record>
</filter>
<source>
type tail
path /var/log/nginx/access.log
pos_file /var/log/td-agent/access.pos
tag td.logstash.nginx.log
format /^(?<code>[^ ]*) (?<vhost>[^ ]*) (?<ip>[^ ]*) [^ ]* (?<user>[^ ]*) \[(?<timestamp>[^\]]*)\] "(?<method>\S+)(?: +(?<path>[^ ]*) +\S*)?" "(?<referer>[^\"]*)" "(?<agent>[^\"]*)" (?<size>[^ ]*) (?<processing_time>[^ ]*) (?<scheme>[^ ]*) (?<response_time>[^ ]*) (?<upstream_addr>[^ ]*)?$/
</source>
It doesn't work. I tested also rewrite_plugin, but no success too.
Of course, I can use Unix tools (sed, for example), but wouldn't it be better to do this in Fluentd itself? I thought that this task should be easy... only change one field to other one...
Best regards,
Eugene