From 694a66a50c325499ad8ac7e901f243ccf33f1f53 Mon Sep 17 00:00:00 2001 From: Marco Pracucci Date: Tue, 16 Jul 2019 15:08:46 +0200 Subject: [PATCH] Documented timestamp's custom format syntax --- docs/logentry/processing-log-lines.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/logentry/processing-log-lines.md b/docs/logentry/processing-log-lines.md index baac228a3c8fb..b039143267bc5 100644 --- a/docs/logentry/processing-log-lines.md +++ b/docs/logentry/processing-log-lines.md @@ -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() -__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: