# Custom index filter

**URL:** <https://discuss.elastic.co/t/custom-index-filter/270714>\
**Category:** Beats\
**Tags:** winlogbeat\
**Created:** [April 20, 2021, 1:39pm UTC](https://discuss.elastic.co/t/custom-index-filter/270714 "2021-04-20T13:39:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ARDiver86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ardiver86/32/85266_2.png) [@ARDiver86](https://discuss.elastic.co/u/ARDiver86)\
**Post date:** [April 20, 2021, 1:39pm UTC](https://discuss.elastic.co/t/custom-index-filter/270714/1 "2021-04-20T13:39:01Z")

</div>

I am attempting to put specific messages from sysmon into their own index so I can apply a separate lifecycle policy to them. I thought I had this policy correct but it does not seem to be working properly.

The query I am looking for is "winlog.channel = Microsoft-Windows-Sysmon/Operational" AND (event.code = 1 OR event.code = 2 OR event.code = 5 OR event.code = 10 OR event.code = 25)

This is what I have that doesn't appear to be working:

```auto
- index: "winlogbeat-process-%{[agent.version]}"
      when:
         and:
            - equals:
                winlog.channel: "Microsoft-Windows-Sysmon/Operational"
            - or:
                - equals:
                    event.code: "1"
                - equals:
                    event.code: "2"
                - equals:
                    event.code: "5"
                - equals:
                    event.code: "10"
                - equals:
                    event.code: "25"

```

What would be the correct way to do this in the configuration file?

---

<div class="post-metadata">

**Author:** ![ARDiver86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ardiver86/32/85266_2.png) [@ARDiver86](https://discuss.elastic.co/u/ARDiver86)\
**Post date:** [April 20, 2021, 3:39pm UTC](https://discuss.elastic.co/t/custom-index-filter/270714/2 "2021-04-20T15:39:49Z")

</div>

I have made a little progress but I am making sure this works properly. I think the format is more like "event.code: 1 or event.code: 5 or event.code:10 and winlog.channel: "Microsoft-Windows-Sysmon/Operational" instead of the format I wanted at the top. Maybe it is not possible:

```auto
- index: "winlogbeat-process-%{[agent.version]}"
      when:
         or:
            - equals:
                event.code: "1"
            - equals:
                event.code: "2"
            - equals:
                event.code: "5"
            - equals:
                event.code: "10"
            - equals:
                event.code: "25"
            - and:
                - equals:
                    winlog.channel: "Microsoft-Windows-Sysmon/Operational"

```

---

<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 18, 2021, 5:40pm UTC](https://discuss.elastic.co/t/custom-index-filter/270714/3 "2021-05-18T17:40:28Z")

</div>

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