# Ingest pipeline with conditions runs tests correct but no documents are processed

**URL:** https://discuss.elastic.co/t/ingest-pipeline-with-conditions-runs-tests-correct-but-no-documents-are-processed/339150
**Category:** Elasticsearch
**Tags:** ingest-pipeline
**Created:** [July 25, 2023, 6:58am UTC](https://discuss.elastic.co/t/ingest-pipeline-with-conditions-runs-tests-correct-but-no-documents-are-processed/339150 "2023-07-25T06:58:26Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![fgjensen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fgjensen/32/62320_2.png) [@fgjensen](https://discuss.elastic.co/u/fgjensen)
#### Post date: [July 25, 2023, 6:58am UTC](https://discuss.elastic.co/t/ingest-pipeline-with-conditions-runs-tests-correct-but-no-documents-are-processed/339150/1 "2023-07-25T06:58:26Z")

</div>

Hi;

Elasticsearch version: 8.6.2  
Logstash version: 8.6.2

I have created and tested at simple ingest pipeline, which adds an event.ingested field to Filebeat documents, which do not already have this field set by other Filebeat pipelines.

All events are received by Logstash before ingestion into Elasticsearch ingestion nodes.

The pipeline is configured like this:

```auto
{
  "set_event_ingested": {
    "description": "Add a event.ingested field to filebeat events with the value _ingest.timestamp if the field is not set in the document",
    "processors": [
      {
        "set": {
          "field": "event.ingested",
          "value": "{{_ingest.timestamp}}",
          "if": "ctx?.agent?.type == 'filebeat' && !ctx.containsKey('event.ingested')"
        }
      }
    ],
    "version": 1,
    "on_failure": [
      {
        "append": {
          "field": "error.message",
          "value": [
            "{{ _ingest.on_failure_message }}"
          ]
        }
      }
    ]
  }
}

```

I have tested the pipeline from Kibana with documents which fulfill the conditions and other documents which do not fulfill the conditions. The pipeline works as expected.

However looking in nodes/stats it is seen the pipeline never executes:

```auto
         "set_event_ingested": {
            "count": 0,
            "time_in_millis": 0,
            "current": 0,
            "failed": 0,
            "processors": [
              {
                "set": {
                  "type": "conditional",
                  "stats": {
                    "count": 0,
                    "time_in_millis": 0,
                    "current": 0,
                    "failed": 0
                  }
                }
              }
            ]
          },

```

I have search other blog posts for similar problems, but cannot find a solution.

I have loaded many filebeat pipelines into Elasticsearch, so with the default pipelines around 200 ingest pipelines are loaded. However, several of these pipelines do not process any data events, since the beats have been upgraded from version 7.15 to 7.17.

Could this impact the ingest pipeline I have created? How can I force Elasticsearch to apply the set\_event\_ingested to all filebeat documents, which fulfill the conditions?

Best regards  
Flemming

---

<div class="post-metadata">

### Author: ![Opster\_support](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/opster_support/32/56687_2.png) [@Opster\_support](https://discuss.elastic.co/u/Opster_support)
#### Post date: [July 25, 2023, 8:06am UTC](https://discuss.elastic.co/t/ingest-pipeline-with-conditions-runs-tests-correct-but-no-documents-are-processed/339150/2 "2023-07-25T08:06:52Z")

</div>

It seems like your ingest pipeline is correctly defined but it's not being used. In Elasticsearch, an ingest pipeline is not automatically applied to all incoming documents. You need to specify the pipeline during the index or bulk request.

Since you're using Logstash to ingest data into Elasticsearch, you need to specify the pipeline in your Logstash Elasticsearch output configuration. Here's an example:

```shell
output {
  elasticsearch {
    hosts => ["localhost:9200"]
    index => "my_index"
    pipeline => "set_event_ingested"
  }
}

```

This configuration tells Logstash to use the "set\_event\_ingested" pipeline when indexing documents into Elasticsearch, remember to restart Logstash after making changes to its configuration.

---

<div class="post-metadata">

### Author: ![fgjensen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fgjensen/32/62320_2.png) [@fgjensen](https://discuss.elastic.co/u/fgjensen)
#### Post date: [July 25, 2023, 9:03am UTC](https://discuss.elastic.co/t/ingest-pipeline-with-conditions-runs-tests-correct-but-no-documents-are-processed/339150/3 "2023-07-25T09:03:47Z")

</div>

Hi @Opster_support ;

Thanks, I will try that.

However, in the Logstash output I do not specify the various Filebeat ingest pipelines f.x.

```auto
         "filebeat-7.15.0-apache-access-pipeline": {
            "count": 20138,
            "time_in_millis": 1583,

```

Why does this work without the pipeline specification? And will these pipelines still be applied to the events from the modules enabled in some filebeats?

Best regards  
Flemming

---

<div class="post-metadata">

### Author: ![Opster\_support](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/opster_support/32/56687_2.png) [@Opster\_support](https://discuss.elastic.co/u/Opster_support)
#### Post date: [July 25, 2023, 10:28am UTC](https://discuss.elastic.co/t/ingest-pipeline-with-conditions-runs-tests-correct-but-no-documents-are-processed/339150/4 "2023-07-25T10:28:52Z")

</div>

The reason why the "filebeat-7.15.0-apache-access-pipeline" is being applied without being specified in the Logstash output is likely because it's being set in Filebeat itself.

Filebeat has a feature where it can set the ingest pipeline to be used for each event. This is typically used when you enable modules in Filebeat. Each module can specify a default ingest pipeline to process its data.

When Filebeat sends data to Logstash, it includes the pipeline name in the metadata of each event. Logstash then forwards this metadata along with the event to Elasticsearch, which uses the specified pipeline to process the event.

If you specify a pipeline in the Logstash output, it will override the pipeline set by Filebeat. So, if you want to apply the "set\_event\_ingested" pipeline to all events, but also want to keep the pipelines set by Filebeat modules, you might need to create a new pipeline that first calls your "set\_event\_ingested" pipeline and then the module pipeline.

Here's an example of how you can do this:

```shell
PUT _ingest/pipeline/set_event_ingested_and_module_pipeline
{
  "description" : "first apply set_event_ingested, then the module pipeline",
  "processors" : [
    {
      "pipeline" : {
        "name" : "set_event_ingested"
      }
    },
    {
      "pipeline" : {
        "name" : "filebeat-7.15.0-apache-access-pipeline"
      }
    }
  ]
}

```

Then, in your Logstash output, you would specify this new pipeline:

```shell
output {
  elasticsearch {
    hosts => ["localhost:9200"]
    index => "my_index"
    pipeline => "set_event_ingested_and_module_pipeline"
  }
}

```

This way, both your "set\_event\_ingested" pipeline and the module pipeline will be applied to the events.

Please note i used [opsgpt.io](http://opsgpt.io) to build the examples here

---

<div class="post-metadata">

### Author: ![fgjensen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fgjensen/32/62320_2.png) [@fgjensen](https://discuss.elastic.co/u/fgjensen)
#### Post date: [July 25, 2023, 11:55am UTC](https://discuss.elastic.co/t/ingest-pipeline-with-conditions-runs-tests-correct-but-no-documents-are-processed/339150/5 "2023-07-25T11:55:45Z")

</div>

First, thanks for pointing me to [opsgpt.io](http://opsgpt.io). I'll take a closer look at that IA.

Yes, it correct filebeat events from modules set the ingest pipeline the module requires. I have noticed this when we upgrade the Filebeats and I have to load the corresponding ingest pipelines in advance.

Our use case for Filebeat and other beats modules, which uses ingest pipelines is a bit complex. When the beats are upgraded they are distributed with apt and chocolatey packages to many different hosts in the infrastructure. I cannot control exactly when a beat is upgraded, so for a period at last 2 versions of each pipeline have to be supported. Some times more than 2 versions. I should be able to resolve this by adding all required pipelines to you example set\_event\_ingested\_and\_module\_pipelines. This solution requires some maintenance, but should be a possible.

---

<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 22, 2023, 11:56am UTC](https://discuss.elastic.co/t/ingest-pipeline-with-conditions-runs-tests-correct-but-no-documents-are-processed/339150/6 "2023-08-22T11:56:35Z")

</div>

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