# Filebeat apache module add\_labels process and if conditions

**URL:** <https://discuss.elastic.co/t/filebeat-apache-module-add-labels-process-and-if-conditions/279675>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [July 26, 2021, 10:43pm UTC](https://discuss.elastic.co/t/filebeat-apache-module-add-labels-process-and-if-conditions/279675 "2021-07-26T22:43:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nico\_Ga](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nico_ga/32/92172_2.png) [@nico\_Ga](https://discuss.elastic.co/u/nico_Ga)\
**Post date:** [July 26, 2021, 10:43pm UTC](https://discuss.elastic.co/t/filebeat-apache-module-add-labels-process-and-if-conditions/279675/1 "2021-07-26T22:43:31Z")

</div>

Hi,  
I would like to add labels in filebeat apache module conf file with 3 conditions.  
I use input processors and if/then/else statements in apache.yml. Like that it's works :

> ```
> input:
> processors:
> - if:
> regexp:
> log.file.path: ".*foo.*"
> then:
> add_labels:
> labels:
> env: foo
> else:
> add_labels:
> labels:
> env: nobody
> 
> ```

But when i introduce the 3rd condition like that, filebeat starts but no harvester are launched and no logs sent to elasticsearch :

> ```
> input:
> processors:
> - if:
> regexp:
> log.file.path: ".*foo.*"
> then:
> add_labels:
> labels:
> env: foo
> else if:
> regexp:
> log.file.path: ".*bar.*"
> then:
> add_labels:
> labels: bar
> else:
> add_labels:
> labels:
> env: nobody
> 
> ```

I have also tried like that (but still the same behaviour) :

> ```
> input:
> processors:
> - if:
> regexp:
> log.file.path: ".*foo.*"
> then:
> add_labels:
> labels:
> env: foo
> elif:
> regexp:
> log.file.path: ".*bar.*"
> then:
> add_labels:
> labels: bar
> else:
> add_labels:
> labels:
> env: nobody
> 
> ```

or :

> ```
> input:
> processors:
> - if:
> regexp:
> log.file.path: ".*foo.*"
> then:
> add_labels:
> labels:
> env: foo
> - if:
> regexp:
> log.file.path: ".*bar.*"
> then:
> add_labels:
> labels: bar
> else:
> add_labels:
> labels:
> env: nobody
> 
> ```

It seems filebeat supports only one if statement in the input processor context.  
Or i simply do something wrong ☹

Thanks for your read ... and answer.  
nico

---

<div class="post-metadata">

**Author:** ![nico\_Ga](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nico_ga/32/92172_2.png) [@nico\_Ga](https://discuss.elastic.co/u/nico_Ga)\
**Post date:** [July 27, 2021, 7:48am UTC](https://discuss.elastic.co/t/filebeat-apache-module-add-labels-process-and-if-conditions/279675/2 "2021-07-27T07:48:19Z")

</div>

Hi

With this syntax it's work :

```auto
input:
  processors:
    - if:
        regexp:
          log.file.path: ".*foo.*"
      then:
        add_labels:
          labels:
            env: foo
      else:
        if:
          regexp:
            log.file.path: ".*bar.*"
        then:
          add_labels:
            labels:
              env: bar
        else:
          add_labels:
            labels: nobody

```

nico

---

<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:** [August 24, 2021, 9:48am UTC](https://discuss.elastic.co/t/filebeat-apache-module-add-labels-process-and-if-conditions/279675/3 "2021-08-24T09:48:35Z")

</div>

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