2

我想通过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)

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

4

1 回答 1

2

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

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

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

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

参考:

于 2015-05-01T20:26:19.440 回答