external command fails td-agent

三世轮回 提交于 2020-04-07 10:34:16

问题


This bash command "etcdctl get system config/log/timestamp" returns time type either UTC or System. Now i want to use this to convert time to same format. How can i do that?

I tried this but it failed td-agent running.

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

Now i want to use that timeType to convert my time from given log to that 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"}

This is where i want to use that $timeType

<filter com.logging.tmplog>
  @type record_modifier
  <record>
  type log
  time ${record["time"]}.$timeType   ## It's not working
  arun ${tag}
  </record>
</filter>

回答1:


The issue is solved by using record-modifier's prepare_value

<filter com.logging.tmplog> @type record_modifier prepare_value @timeType =`etcdctl get system config/log/timestamp`.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>



来源:https://stackoverflow.com/questions/60765041/external-command-fails-td-agent

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!