Fluentd Time Key String Format

52 Views Asked by At

Fluentd is listening to the logs of my applications and storing them in MongoDB. Each log has a time key. I want this time key to be stored as a string, but it is being stored as a date type. How can I change the type as string?

this is my filter config:

<filter requesterrors>
  @type parser
  key_name log
  reserve_data true
  remove_key_name_field true
  <parse>
    @type json
    time_type string
    time_format string
    keep_time_key true
    time_format "%Y-%m-%dT%H:%M:%S.%NZ"
  </parse>
</filter>

and this is my match config:

<match requesterrors>
  @type copy  
  <store>
    @type mongo
    host mongodb
    port 27017
    database logs
    collection requestlogs
    user root
    password 12234234
    mechanism SCRAM-SHA-1
    logstash_format true
    logstash_prefix requestlogs
    logstash_dateformat %Y%m%d
    index_name requestlogs
    type_name requestlogs
    flush_interval 1s
  </store>
</match>
0

There are 0 best solutions below