Skip to content

type inference converts "05" to "5" which then isn't usable in strptime() #230

@sevaTechoPark

Description

@sevaTechoPark
/^/ +
/(?P<year>\d{4})\/(?P<month>\d{2})\/(?P<day>\d{2}) (?P<time>\d{2}:\d{2}:\d{2}) / +
/.*/ +
/$/ {
    getfilename() !~ /(error\.log)$/ {
        stop
    }

    hidden gauge time_rfc3339
    time_rfc3339 = $year + "-" + $month + "-" + $day + "T" + $time + "Z03:00"
    strptime(time_rfc3339, "2006-01-02T15:04:05Z07:00")

    error_log_count++
}

error.log:

2019/05/14 11:10:05 [warn] ...
2019/05/14 11:11:06 [warn] ...

logfile:

I0514 11:13:15.029268   49162 vm.go:90] nginx.mtail: Runtime error: strptime (2006-01-02T15:04:05Z07:00, 2019-5-14T11:11:06Z03:00, UTC) failed: parsing time "2019-5-14T11:13:15Z03:00": month out of range

I think mtail transform 05 to 5 because think that it is number.

How can I tell to mtail that I wanna regexp numbers but wanna work with string type?


time_rfc3339 = $year + "-" + string($month) + "-" + $day + "T" + $time + "Z03:00"
does not help me

$ mtail -version

mtail version v3.0.0-rc29-12-gc95b546 git revision c95b546631bf7b6077d3377f25aff2d5306d305f go version go1.12.4 go arch amd64 go os freebsd

Metadata

Metadata

Assignees

Labels

bugThis is considered a bug and shall get fixedmtail-Language/VMIssues related to the mtail language, compiler, or VM

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions