# What are best practices for matching incoming log sources?

**URL:** <https://discuss.elastic.co/t/what-are-best-practices-for-matching-incoming-log-sources/206496>\
**Category:** Logstash\
**Created:** [November 4, 2019, 11:06pm UTC](https://discuss.elastic.co/t/what-are-best-practices-for-matching-incoming-log-sources/206496 "2019-11-04T23:06:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![meatwad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/meatwad/32/36031_2.png) [@meatwad](https://discuss.elastic.co/u/meatwad)\
**Post date:** [November 4, 2019, 11:06pm UTC](https://discuss.elastic.co/t/what-are-best-practices-for-matching-incoming-log-sources/206496/1 "2019-11-04T23:06:19Z")

</div>

Hi,

I'm getting started on sorting incoming log sources and was wondering what best practice is for doing so.

For example, I'm collecting logs from a variety of sources including Palo Alto firewalls, Aruba NAC, PulseSecure VPN, etc. Right now, I'm matching "TRAFFIC", "SYSTEM", and "THREAT" strings in an if statement like:

```
if "THREAT" in [message] {
  mutate {
    add_tag => "PA_THREAT" }
}

```

But I don't know if there are performance penalties to looking for strings in each message. Should I think about doing it a different way?

Thanks!

---

<div class="post-metadata">

**Author:** ![meatwad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/meatwad/32/36031_2.png) [@meatwad](https://discuss.elastic.co/u/meatwad)\
**Post date:** [November 7, 2019, 1:58pm UTC](https://discuss.elastic.co/t/what-are-best-practices-for-matching-incoming-log-sources/206496/2 "2019-11-07T13:58:31Z")

</div>

Any help on this would be greatly appreciated!

---

<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:** [November 7, 2019, 2:57pm UTC](https://discuss.elastic.co/t/what-are-best-practices-for-matching-incoming-log-sources/206496/3 "2019-11-07T14:57:51Z")

</div>

If you want to distinguish events within logstash you are going to have to use a conditional that tests some field on the event. It might be message, it might be a tag added at the origin, it might be a [host][name] added at the origin. It is going to depend on the data and we do not know what your data looks like.

---

<div class="post-metadata">

**Author:** ![meatwad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/meatwad/32/36031_2.png) [@meatwad](https://discuss.elastic.co/u/meatwad)\
**Post date:** [November 8, 2019, 3:42pm UTC](https://discuss.elastic.co/t/what-are-best-practices-for-matching-incoming-log-sources/206496/4 "2019-11-08T15:42:50Z")

</div>

Thank you for the response. Yeah, it obviously varies on the log source -- I just didn't know if matching by 'if "foo" in [message]' was more expensive resource-wise than other ways, such as by source host IP.

Thank you again -- I really do appreciate your help!

---

<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 6, 2019, 3:42pm UTC](https://discuss.elastic.co/t/what-are-best-practices-for-matching-incoming-log-sources/206496/5 "2019-12-06T15:42:57Z")

</div>

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