# Parse logstash file format

**URL:** <https://discuss.elastic.co/t/parse-logstash-file-format/274237>\
**Category:** Logstash\
**Created:** [May 27, 2021, 4:26pm UTC](https://discuss.elastic.co/t/parse-logstash-file-format/274237 "2021-05-27T16:26:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sulsulatoff](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@sulsulatoff](https://discuss.elastic.co/u/sulsulatoff)\
**Post date:** [May 27, 2021, 4:26pm UTC](https://discuss.elastic.co/t/parse-logstash-file-format/274237/1 "2021-05-27T16:26:38Z")

</div>

we have an input file with a format like below. How to process it with logstash?

```
{
	"message" => "test",
	"@timestamp" => "2013-12-23T22:30:01.000Z",
	"@version" => "1",
	"type" => "syslog",
	"host" => "0:0:0:0:0:0:0:1:52617",                         
	"received_at" => "2013-12-23 22:49:22 UTC",
	"received_from" => "0:0:0:0:0:0:0:1:52617",
	"headers" =>{
		"key1" => "value1",
		"key2" => "value2"
	}
}

```

PS: I don't know what this format is known so difficult to google it 🙂

---

<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:** [May 27, 2021, 5:00pm UTC](https://discuss.elastic.co/t/parse-logstash-file-format/274237/2 "2021-05-27T17:00:47Z")

</div>

That looks like output from the rubydebug codec, which uses the [amazing print](https://github.com/amazing-print/amazing_print) library. I would suggest converting it to JSON and then parsing it with a json filter.

I assume you are consuming that as a single event.

A simple gsub will get you most of the way there

```
mutate { gsub => ["message", " => ", ": "] }

```

If you have arrays you may need to remove the indexes. If your arrays look like

```
"someField" => [
    [0] "foo",
    [1] "bar"
]

```

you will also need

```
mutate { gsub => ["message", " \[\d+\] ", "" ] }
```

---

<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:** [June 24, 2021, 5:01pm UTC](https://discuss.elastic.co/t/parse-logstash-file-format/274237/3 "2021-06-24T17:01:46Z")

</div>

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