# Grok pattern for Logstash Logs

**URL:** <https://discuss.elastic.co/t/grok-pattern-for-logstash-logs/42070>\
**Category:** Logstash\
**Created:** [February 17, 2016, 9:06pm UTC](https://discuss.elastic.co/t/grok-pattern-for-logstash-logs/42070 "2016-02-17T21:06:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![parthu](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@parthu](https://discuss.elastic.co/u/parthu)\
**Post date:** [February 17, 2016, 9:06pm UTC](https://discuss.elastic.co/t/grok-pattern-for-logstash-logs/42070/1 "2016-02-17T21:06:57Z")

</div>

I am writing the configuration file in Logstash to shove logs from Logstash into Elasticsearch (so that I get to see them in Kibana eventually).

A typical Logstash Log file looks like this:

{:timestamp=\>"2016-02-17T14:59:36.052000-0600", :message=\>"Pipeline started", :level=\>:info}  
{:timestamp=\>"2016-02-17T14:59:36.980000-0600", :message=\>"Automatic template management enabled", :manage\_template=\>"true", :level=\>:info}

I want to capture the "level =\> info" as a field, i.e., field name should be "level" and field value should be "info"

I wrote the following:

filter {

if [type] == "logstash\_indexer" {

```
    mutate {
    replace => ["message", "%{message}}"]
    gsub => ['message', '\n', '']

```

}

```
    if [message] =~ /^{.*}$/

```

{  
json { source =\> message }  
}  
if [message] =~ /info/  
{  
mutate {  
add\_field =\> ["level" , "info"]  
}

}

}  
}

But I don't see what I want happening. Could any of you guide me through getting level=\>info recognized? Where am I going wrong?

Thanks !

---

<div class="post-metadata">

**Author:** ![sukhada369](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@sukhada369](https://discuss.elastic.co/u/sukhada369)\
**Post date:** [February 18, 2016, 4:51am UTC](https://discuss.elastic.co/t/grok-pattern-for-logstash-logs/42070/2 "2016-02-18T04:51:55Z")

</div>

Excluding mutate part, are you able to send logs to Elasticsearch?

---

<div class="post-metadata">

**Author:** ![parthu](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@parthu](https://discuss.elastic.co/u/parthu)\
**Post date:** [February 18, 2016, 2:07pm UTC](https://discuss.elastic.co/t/grok-pattern-for-logstash-logs/42070/3 "2016-02-18T14:07:20Z")

</div>

Even with the mutate part, I am able to send logs, but I can't see the field "level" with value "info" in Kibana. How can I edit so that I get the field and value on Kibana?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [February 19, 2016, 6:41am UTC](https://discuss.elastic.co/t/grok-pattern-for-logstash-logs/42070/4 "2016-02-19T06:41:40Z")

</div>

Use a grok filter. The json filter isn't useful since the log isn't in JSON format.

---

<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 6, 2017, 5:10am UTC](https://discuss.elastic.co/t/grok-pattern-for-logstash-logs/42070/5 "2017-07-06T05:10:42Z")

</div>


