我想通过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)
有人知道为什么会这样吗?有什么想法吗?