外部命令使td-agent失败

时间:2020-03-19 21:05:04

标签: fluentd td-agent

此bash命令“ SELECT ZMATNR, ZLPN FROM tblZMMGPNXREF WHERE ZMATNR IN ('89187605', '89363059'); ”返回UTC或系统时间类型。现在我想用它来将时间转换成相同的格式。我怎样才能做到这一点?

我尝试过此操作,但它无法运行td-agent。

etcdctl get system config/log/timestamp

现在我想使用该timeType将我的时间从给定日志转换为该timeType

<source>
  @type exec
  command etcdctl get system config/log/timestamp
  <parse>
    keys timeType
  </parse>
</source>

这是我要使用该$ timeType的地方

{"host":"sp-1","level":"INFO","log":{"classname":"common.server.hacluster.CSFHATopologyChangeHandlerMBean:93","message":"Finished processing CSF HA 'become standby' message.","stacktrace":"","threadname":"RMI TCP Connection(1784)-192.168.20.11"},"process":"becomeStandby","service":"SP","time":"2020-03-19T10:15:36.514Z","timezone":"America/Toronto","type":"log","system":"SP_IG_20_3_R1_I2002","systemid":"SP_IG_20_3_R1_I2002"}

1 个答案:

答案 0 :(得分:0)

使用记录修饰符的prepare_value解决了该问题

<filter com.logging.tmplog> @type record_modifier prepare_value @timeType =`etcdctl获取系统配置/日志/时间戳`.strip

<record> timeType ${@timeType} time ${if @timeType == 'UTC' then Time.at(time).utc.strftime('%FT%T') else Time.at(time).to_s; end} </record> </filter>