# Tag with pattern used

**URL:** https://discuss.elastic.co/t/tag-with-pattern-used/81868
**Category:** Logstash
**Created:** [April 10, 2017, 8:27pm UTC](https://discuss.elastic.co/t/tag-with-pattern-used/81868 "2017-04-10T20:27:38Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![lask001](https://avatars.discourse-cdn.com/v4/letter/l/4da419/32.png) [@lask001](https://discuss.elastic.co/u/lask001)
#### Post date: [April 10, 2017, 8:27pm UTC](https://discuss.elastic.co/t/tag-with-pattern-used/81868/1 "2017-04-10T20:27:38Z")

</div>

Below is a basic example of what I'm using for my setup:

I have a patterns file that's defined and works correctly.

`patterns %{pattern1}|%{pattern2}|%{pattern3}`

My filter is similar to the following:

```
filter {
  if [type] == 'test' {
    grok {
      patterns_dir => '/etc/logstash/conf.d/patterns/'
      match => { "message" => "%{patterns}" }
    }
  }
}

```

I know I can add tags, and I know I could do a large set of conditionals to accomplish my goal, but I'm wondering if there is a dynamic way to get my filter to add tags based on which pattern is used. I'd like a tag called pattern1, pattern2, or pattern3 to show up in all of my parsed logs. Anyone have any insight on how I could go about accomplishing this?

Thanks!

---

<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: [April 11, 2017, 5:15am UTC](https://discuss.elastic.co/t/tag-with-pattern-used/81868/2 "2017-04-11T05:15:26Z")

</div>

There's no automatic way of doing this. Your best bet is probably to generate a configuration file with conditionals etc.

---

<div class="post-metadata">

### Author: ![lask001](https://avatars.discourse-cdn.com/v4/letter/l/4da419/32.png) [@lask001](https://discuss.elastic.co/u/lask001)
#### Post date: [April 11, 2017, 6:08am UTC](https://discuss.elastic.co/t/tag-with-pattern-used/81868/3 "2017-04-11T06:08:11Z")

</div>

I was afraid that might be the case. I'm a little worried about the performance hit as I'm running a fairly large cluster, with a lot of different patterns. That's the only reason I didn't just implement it with a lot of conditionals yet. I'll have to do testing I guess. 😕

---

<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: [May 9, 2017, 6:19am UTC](https://discuss.elastic.co/t/tag-with-pattern-used/81868/4 "2017-05-09T06:19:00Z")

</div>

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