I’m trying to parse a log file containing Unix timestamps with Promtail, but am running into the following error:
level=info ts=2021-06-18T14:10:00.26531019Z caller=tailer.go:125 component=tailer msg=“tail routine: started” path=/path/to/testlog
ts=2021-06-18T14:10:00.265463196Z caller=log.go:124 level=info msg=“Seeked /path/to/testlog - &{Offset:0 Whence:0}”
level=debug ts=2021-06-18T14:10:00.266096682Z caller=timestamp.go:196 component=file_pipeline msg=“failed to parse time” err=“parsing time “1623180831.246”: month out of range” format=1136235845.000 value=1623180831.246
My config is as follows:
scrape_configs:
- job_name: akamai
static_configs:- labels:
job: logs
path: /path/to/testlog
targets: localhost
pipeline_stages: - match:
selector: ‘{job=“logs”}’
stages:- regex:
expression: “(?s)^(?P\d{10}.{4})” - timestamp:
source: time
format: ‘1136235845.000’
- regex:
- labels:
I’ve tried multiple iterations of regex and config parameters and this combination appears to get me the closest, but I’ve run out of ideas. Golang appears to require Jan 2, 2006 at 3:04pm (MST) as a reference time, which I’ve converted to epoch with no luck.
Below is a sample log line for reference:
1623180831.246 192.168.0.1 POST TLSv1.2 /domain.com/java/somepath/anotherpath/en/somemodule/someservice.asmx 200 75201 76955 75201 - 5568 “-” “Java/1.8.0_281” “-” “domain.com” “text/xml” 0 153 69 “306dd6ab” - “miss” “origin” 1 1 192.168.0.1