【问题标题】:Datadog dogstream custom parser errorDatadog dogstream 自定义解析器错误
【发布时间】:2015-04-29 16:34:08
【问题描述】:

我想通过dogstream添加我的自定义日志解析器,但是重启datadog代理时出现异常:

2015-04-29 19:19:06 MSK | INFO | dd.collector | checks.collector(datadog.py:117) | Instantiating function-based dogstream
2015-04-29 19:19:06 MSK | INFO | dd.collector | checks.collector(datadog.py:124) | dogstream: parsing /var/www/api.clearspending.ru_v3/api/var/log/tornadoCS9031.log with <function parse_api_response_time at 0x7f9d0981a398> (requested dogstream/clearspending_parser:parse_api_response_time)
2015-04-29 19:19:06 MSK | INFO | dd.collector | checks.collector(datadog.py:67) | Dogstream parsers: [<checks.datadog.Dogstream object at 0x7f9d09820410>]
2015-04-29 19:19:07 MSK | INFO | dd.collector | checks.collector(collector.py:486) | Hostnames: {'socket-hostname': 'clearspending.ru', 'hostname': 'clearspending.ru', 'socket-fqdn': 'clearspending.ru'}, tags: {}
2015-04-29 19:19:07 MSK | ERROR | dd.collector | checks.collector(unix.py:370) | Cannot extract IO statistics
Traceback (most recent call last):
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 284, in check
    io.update(self._parse_linux2(stdout))
  File "/opt/datadog-agent/agent/checks/system/unix.py", line 185, in _parse_linux2
    recentStats = output.split('Device:')[2].split('\n')
IndexError: list index out of range

解析器代码:

def parse_api_response_time(logger, line):
    """
    Just parser API log :)
    parse_api_response_time(None, "16-02-2015 15:46:36     INFO     200 GET /apishechka/v3/contracts/select/?customerregion=29&get_report=True&sort=-price (127.0.0.1) 28102.86ms")
    ('api_time', 1424090796.0, 28102.86, {})
    """
    metric_name = "api_time"
    date, status, time_response = re.match(API_LOG_REGEX, line).groups()
    date = mktime(datetime.strptime(date, "%d-%m-%Y %H:%M:%S").timetuple())
    attr_dict = {}
    # Convert the time_response value into a float
    metric_value = float(time_response[:-2])
    # Return the output as a tuple
    return (metric_name, date, metric_value, attr_dict)

有人知道为什么会发生这样的事情吗?有什么想法吗?

【问题讨论】:

    标签: python datadog


    【解决方案1】:

    您看到的异常与 IO 系统指标收集有关,与您的自定义 dogstream 解析器无关。

    如果您查看堆栈跟踪,它会说它无法应用 _parse_linux2 函数。要进一步排除故障,您应该查看

    的输出
    /opt/datadog-agent/embedded/bin/iostat -d 1 2 -x -k
    

    这是代理启动的命令。随意在代理 GitHub 存储库上打开一个错误。

    参考资料:

    【讨论】:

      猜你喜欢
      • 2019-11-21
      • 1970-01-01
      • 2011-01-18
      • 2014-04-16
      • 1970-01-01
      • 2014-03-27
      • 1970-01-01
      • 1970-01-01
      • 2011-04-17
      相关资源
      最近更新 更多