# Logstash not adding new field tag

**URL:** <https://discuss.elastic.co/t/logstash-not-adding-new-field-tag/254579>\
**Category:** Logstash\
**Created:** [November 6, 2020, 8:56pm UTC](https://discuss.elastic.co/t/logstash-not-adding-new-field-tag/254579 "2020-11-06T20:56:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![inuygoku](https://avatars.discourse-cdn.com/v4/letter/i/e47c2d/32.png) [@inuygoku](https://discuss.elastic.co/u/inuygoku)\
**Post date:** [November 6, 2020, 8:56pm UTC](https://discuss.elastic.co/t/logstash-not-adding-new-field-tag/254579/1 "2020-11-06T20:56:58Z")

</div>

I am trying to create a filter that will for event in my logs and add it to a field called "detected\_event".

The filter I created is the following:

```auto
filter {
    if "Scan completed" in [logline] {
        mutate {
            add_field => { "detected_event" => "scan_completed" }
        }
    }
}

```

In my logs if a Scan has completed it would have the something like the following line in the logline message:

"Scan completed: 5fa2d007d1cc991ff9d90aa2 5fa2d0936e2b8d567f31b5f5"

When I added the filter and run my scans again, logstash had not added the filter I had in the filter configuration file.

My end goal here is to simply have a field I can query against instead of having to parse large log lines in kibana

---

<div class="post-metadata">

**Author:** ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)\
**Post date:** [November 6, 2020, 9:02pm UTC](https://discuss.elastic.co/t/logstash-not-adding-new-field-tag/254579/2 "2020-11-06T21:02:54Z")

</div>

> [@inuygoku](#):
>
> ```auto
> filter {
> if "completed" in [logline] {
> mutate {
> add_field => { "detected_event" => "scan_completed" }
> }
> }
> }
> 
> ```

try as above to see if you have detected\_event created. if it does then your matching is not working.

I might try this as well  
if ([logline] =~ /Scan completed:/) {

}

---

<div class="post-metadata">

**Author:** ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)\
**Post date:** [November 6, 2020, 9:04pm UTC](https://discuss.elastic.co/t/logstash-not-adding-new-field-tag/254579/3 "2020-11-06T21:04:13Z")

</div>

for exact matching I have used == in past

---

<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:** [December 4, 2020, 9:04pm UTC](https://discuss.elastic.co/t/logstash-not-adding-new-field-tag/254579/4 "2020-12-04T21:04:14Z")

</div>

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