# Adding fields containg a log-level?

**URL:** https://discuss.elastic.co/t/adding-fields-containg-a-log-level/57840
**Category:** Beats
**Tags:** filebeat
**Created:** [August 11, 2016, 4:59pm UTC](https://discuss.elastic.co/t/adding-fields-containg-a-log-level/57840 "2016-08-11T16:59:30Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![budm](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@budm](https://discuss.elastic.co/u/budm)
#### Post date: [August 11, 2016, 4:59pm UTC](https://discuss.elastic.co/t/adding-fields-containg-a-log-level/57840/1 "2016-08-11T16:59:30Z")

</div>

In our project we use logback with the following log-back pattern:  
`<pattern>%date{ISO8601} [%thread] %-5level %logger{25} - %message%n</pattern>`  
I.e. all log messages have a format like this:

`2013-03-10 10:14:16,458 [default-dispatcher-21] ERROR - __SOME_DETAILS__ `  
or  
`2015-11-04 15:15:26,458 [event-thread] INFO - __OTHER_DETAILS__ `

I'd like to provide some kind of filtering depending on the log-level . The obvious idea which first came to mind was to just add

```
fields:
   level: debug # <--- How do I know that?

```

or something like this.

The problem is it's not clear how to extract the log level form the message. Is it ever possible? I can specify the `multilline:pattern:`, but how to extract level from it?

---

<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: [August 11, 2016, 5:31pm UTC](https://discuss.elastic.co/t/adding-fields-containg-a-log-level/57840/2 "2016-08-11T17:31:50Z")

</div>

Filebeat doesn't do this kind of parsing, but Logstash does. Even better is to configure Logback to emit JSON logs so that nobody has to do any parsing (although JSON support is only available in the upcoming Filebeat 5).

---

<div class="post-metadata">

### Author: ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)
#### Post date: [August 11, 2016, 9:56pm UTC](https://discuss.elastic.co/t/adding-fields-containg-a-log-level/57840/3 "2016-08-11T21:56:15Z")

</div>

If you want to filter out 'early' in filebeat there is an `exclude/include_lines` option in filebeat. Potential pattern can be ' [.+] INFO - ' to capture INFO log-level messages. This is some pre-filtering support to reduce network usage. Logstash provides additional parsing + filtering capabilities.

---

<div class="post-metadata">

### Author: ![budm](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@budm](https://discuss.elastic.co/u/budm)
#### Post date: [August 12, 2016, 8:29am UTC](https://discuss.elastic.co/t/adding-fields-containg-a-log-level/57840/4 "2016-08-12T08:29:43Z")

</div>

This does not quite fit. I wanted to store an additional log-level field into elastic in order to facilitate indexing and filtering with logstash. This was the reason I wanted to do this parsing on filebeat's side.

---

<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: [August 12, 2016, 8:35am UTC](https://discuss.elastic.co/t/adding-fields-containg-a-log-level/57840/5 "2016-08-12T08:35:11Z")

</div>

Your flow is Filebeat -\> Elasticsearch -\> Logstash? That doesn't appear to make sense. What comes after Logstash?

---

<div class="post-metadata">

### Author: ![budm](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@budm](https://discuss.elastic.co/u/budm)
#### Post date: [August 12, 2016, 8:39am UTC](https://discuss.elastic.co/t/adding-fields-containg-a-log-level/57840/6 "2016-08-12T08:39:49Z")

</div>

Filebeat--\>Graylog--\>Elasticsearch, but as far as I understood graylog does pretty much the same as logstash.

---

<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: [August 12, 2016, 8:42am UTC](https://discuss.elastic.co/t/adding-fields-containg-a-log-level/57840/7 "2016-08-12T08:42:03Z")

</div>

Okay. So what's the problem with parsing things in Graylog and sending the results to ES?

---

<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: [September 1, 2016, 4:59pm UTC](https://discuss.elastic.co/t/adding-fields-containg-a-log-level/57840/8 "2016-09-01T16:59:43Z")

</div>

This topic was automatically closed after 21 days. New replies are no longer allowed.
