# Filter Active Directory logs

**URL:** <https://discuss.elastic.co/t/filter-active-directory-logs/124145>\
**Category:** Logstash\
**Created:** [March 15, 2018, 5:05pm UTC](https://discuss.elastic.co/t/filter-active-directory-logs/124145 "2018-03-15T17:05:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hanen](https://avatars.discourse-cdn.com/v4/letter/h/5f8ce5/32.png) [@Hanen](https://discuss.elastic.co/u/Hanen)\
**Post date:** [March 15, 2018, 5:05pm UTC](https://discuss.elastic.co/t/filter-active-directory-logs/124145/1 "2018-03-15T17:05:26Z")

</div>

Hello,

I would like to send **only** active directory logs with **specific Id** from logstash to

Elasticsearch.

Please! What config do I need to do at logstash configuration file to achieve this?

example of event\_Id:"4625"===\> "An account failed to log on",

thanks!!!!

---

<div class="post-metadata">

**Author:** ![yaauie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yaauie/32/23363_2.png) [@yaauie](https://discuss.elastic.co/u/yaauie)\
**Post date:** [March 15, 2018, 5:32pm UTC](https://discuss.elastic.co/t/filter-active-directory-logs/124145/2 "2018-03-15T17:32:05Z")

</div>

The simplest way to do it is to wrap your `elasticsearch` output in a conditional:

```auto
input {
  # ...
}
filter {
  # ...
}
output {
  if [event_Id] == "4625" {
    elasticsearch {
      # ... Elasticsearch output config
    }
  }
}

```

It can get a bit cumbersome though, especially if your logic about whether or not to export an event gets complex; instead, I would change my logic to output on the presence of a _tag_ (say, `export`), and would add a filter to inject this tag; that way when business requirements change and I need to export more things, I can just add simple statements to tag them and not worry about making a more complex conditional:

```auto
input {
  # ...
}
filter {
  # ...
  if [event_Id] == "4625" {
    mutate {
      add_tag => ["export"]
    }
  }
}
output {
  if "export" in [tags] {
    elasticsearch {
      # ... Elasticsearch output config
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![wwalker](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@wwalker](https://discuss.elastic.co/u/wwalker)\
**Post date:** [March 15, 2018, 7:43pm UTC](https://discuss.elastic.co/t/filter-active-directory-logs/124145/3 "2018-03-15T19:43:39Z")

</div>

Use the Winlogbeat Beats agent. You can specify which logs and event IDs you'd like to have sent over.

[https://www.elastic.co/guide/en/beats/winlogbeat/current/configuration-winlogbeat-options.html](https://www.elastic.co/guide/en/beats/winlogbeat/current/configuration-winlogbeat-options.html)

```
winlogbeat.event_logs:
  - name: Security
    event_id: 4624, 4625, 4700-4800, -4735
```

---

<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:** [April 12, 2018, 7:44pm UTC](https://discuss.elastic.co/t/filter-active-directory-logs/124145/4 "2018-04-12T19:44:04Z")

</div>

Closed on April 12, 2018, 7:44pm UTC

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