Skip to content

Commit

Permalink
Documented timestamp's custom format syntax (#763)
Browse files Browse the repository at this point in the history
  • Loading branch information
pracucci authored and cyriltovena committed Jul 16, 2019
1 parent e6f8d6f commit c08ec79
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion docs/logentry/processing-log-lines.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,24 @@ UnixNs = 1562708916000000123

Finally any custom format can be supplied, and will be passed directly in as the layout parameter in `time.Parse()`. If the custom format has no year component specified (ie. syslog's default logs), promtail will assume the current year should be used, correctly handling the edge cases around new year's eve.

__Read the [time.parse](https://golang.org/pkg/time/#Parse) docs closely if passing a custom format and make sure your custom format uses the special date they specify: `Mon Jan 2 15:04:05 -0700 MST 2006`__
The syntax used by the custom format defines the reference date and time using specific values for each component of the timestamp (ie. `Mon Jan 2 15:04:05 -0700 MST 2006`). The following table shows supported reference values which should be used in the custom format.

| Timestamp component | Format value |
| ------------------- | ------------ |
| Year | `06`, `2006` |
| Month | `1`, `01`, `Jan`, `January` |
| Day | `2`, `02`, `_2` (two digits right justified) |
| Day of the week | `Mon`, `Monday` |
| Hour | `3` (12-hour), `03` (12-hour zero prefixed), `15` (24-hour) |
| Minute | `4`, `04` |
| Second | `5`, `05` |
| Fraction of second | `.000` (ms zero prefixed), `.000000` (μs), `.000000000` (ns), `.999` (ms without trailing zeroes), `.999999` (μs), `.999999999` (ns) |
| 12-hour period | `pm`, `PM` |
| Timezone name | `MST` |
| Timezone offset | `-0700`, `-070000` (with seconds), `-07`, `07:00`, `-07:00:00` (with seconds) |
| Timezone ISO-8601 | `Z0700` (Z for UTC or time offset), `Z070000`, `Z07`, `Z07:00`, `Z07:00:00`

_For more details, read the [`time.Parse()`](https://golang.org/pkg/time/#Parse) docs and [`format.go`](https://golang.org/src/time/format.go) sources._

##### Example:

Expand Down

0 comments on commit c08ec79

Please sign in to comment.