Custom TimeStamp for SYSLOGTIMESTAMP and Telegraf


Hello everyone,

I’ve tried to configure the logparser plugin in order to parse my existing postfix mail.log.
Using Grok pattern I manage successfully to integrate the logs into influxdb but I have a problem for the timestamp.
I’m catching the log timestamp by using the %{SYSLOGTIMESTAMP} Grok pattern; which is actually working, but when converting it in order to replace the time into influxdb Telegraf doesn’t manage to convert it.
I think it’s do to the lack of year as the SYSLOGTIMESTAMP is the following format :
Sep 25 08:27:29

As per the documentation, I’ve tried several combination of custom timestamp modifiers without success.

Does anyone has already fall into this ?


Can you post the grok section of your config?


Yes sure, forgot about it; my bad

Here you go :

Stream and parse log file(s).

files = ["/root/samples/*mail.log"]
from_beginning = true

patterns = ["%{SYSLOGTIMESTAMP:timestamp:ts-“Sep 25 09:01:55”} %{SYSLOGHOST:hostname} mta-in/milter\[%{MILTER_PROCESSID}\]: %{POSTFIX_QUEUEID:postfix_queue_id}: from=<%{DATA:postfix_from}>, firstto=<%{DATA:postfix_firstto}>, nrcpt=%{DATA:postfix_nrcpt}, size=%{DATA:postfix_msg_size}, score=%{DATA:score}, state=%{DATA:state:int}, status=%{DATA:status:tag}, level=%{DATA:level}, actions=%{DATA:actions}, subject="%{DATA:subject}", cause="%{DATA:cause}""]
## Name of the outputted measurement name.
measurement = “test”

custom_patterns = ‘’‘
POSTFIX_QUEUEID ([0-9A-F]{6,}|[0-9a-zA-Z]{15,})

I’ve tried several custom timestamp like :
%{SYSLOGTIMESTAMP:timestamp:ts-“Sep 25 09:01:55 2017”}
%{SYSLOGTIMESTAMP:timestamp:ts-“Sep 25 09:01:55”}


The first problem I notice is that you need to use the exact magic “reference time”: Mon Jan 2 15:04:05 MST 2006 when using a custom timestamp string:
%{SYSLOGTIMESTAMP:timestamp:ts-“Jan 02 15:04:05”

I tried this and ran into another problem, since there is no year in this pattern the timestamp is set to year 0. The Go standard library puts it like this:

Elements omitted from the value are assumed to be zero or, when zero is impossible, one, so parsing “3:04pm” returns the time corresponding to Jan 1, year 0, 15:04:00 UTC (note that because the year is 0, this time is before the zero Time). Years must be in the range 0000…9999. The day of the week is checked for syntax but it is otherwise ignored.

Perhaps we could have Telegraf fill in the current year if it is not set, or add a way to manually specify missing parts like we have for timezone. Could you open a new issue about this?


@daniel finally made it :