# Timestamp grok pattern \[SOLVED\]

**URL:** <https://discuss.elastic.co/t/timestamp-grok-pattern-solved/134657>\
**Category:** Logstash\
**Created:** [June 5, 2018, 3:26pm UTC](https://discuss.elastic.co/t/timestamp-grok-pattern-solved/134657 "2018-06-05T15:26:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dr01](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dr01/32/8482_2.png) [@dr01](https://discuss.elastic.co/u/dr01)\
**Post date:** [June 5, 2018, 3:26pm UTC](https://discuss.elastic.co/t/timestamp-grok-pattern-solved/134657/1 "2018-06-05T15:26:09Z")

</div>

I need to parse a cloud-init logfile:

```
122.81 - Tue, 05 Jun 2018 11:53:21 +0000 - v. 0.7.9

```

Here's the grok pattern I wrote:

```
%{NUMBER:time} - %{DAY}, %{MONTHDAY} %{MONTH} %{YEAR} %{TIME} %{ISO8601_TIMEZONE} - v. %{NUMBER:version}

```

This pattern works. However, how can I capture the timestamp as a whole? Is there a way to nest grok patterns inline, apart from defining them in a separate pattern file and use the `patterns_dir` option?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [June 5, 2018, 3:59pm UTC](https://discuss.elastic.co/t/timestamp-grok-pattern-solved/134657/2 "2018-06-05T15:59:16Z")

</div>

Use dissect in place of grok.

```
dissect { mapping => { "message" => "%{time} - %{ts} %{+ts} %{+ts} %{+ts} %{+ts} %{+ts} - v. %{version}" } }
date { match => ["ts", "EEE, dd MMM yyyy HH:mm:ss Z"] }
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 3, 2018, 3:59pm UTC](https://discuss.elastic.co/t/timestamp-grok-pattern-solved/134657/3 "2018-07-03T15:59:17Z")

</div>

Closed on July 3, 2018, 3:59pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
