You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Ops Agent配置中设置正确的时间解析格式?

解决Ops Agent时间串解析失败的问题

你的问题出在时区偏移部分的格式配置错误:你用了+%H:%M来匹配+00:00,但Ops Agent的时间格式语法中,带冒号的时区偏移需要用%:z来匹配,而非拆分出+和%H:%M。

正确的时间格式

将你的时间格式替换为:

%Y-%m-%dT%H:%M:%S.%6N%:z

各部分说明:

  • %Y-%m-%dT%H:%M:%S:匹配日期(年-月-日)和时分秒部分
  • %6N:精确匹配6位微秒(对应时间串中的.103467)
  • %:z:匹配带冒号的时区偏移(对应+00:00)

示例配置片段

在Ops Agent的配置文件中,修改parser部分的time_format:

logging:
  receivers:
    your_receiver_name:
      type: file
      include_paths:
        - /path/to/your/logs.log
      parsers:
        - type: custom
          time_key: time
          time_format: "%Y-%m-%dT%H:%M:%S.%6N%:z"

替换后重新加载Ops Agent配置,即可正确解析目标时间串。

内容的提问来源于stack exchange,提问作者Ray

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.17 13:52:09