# Using Template Snippet with Pipeline Processor

**URL:** <https://discuss.elastic.co/t/using-template-snippet-with-pipeline-processor/187842>\
**Category:** Elasticsearch\
**Created:** [June 27, 2019, 1:29pm UTC](https://discuss.elastic.co/t/using-template-snippet-with-pipeline-processor/187842 "2019-06-27T13:29:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeterPain](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@PeterPain](https://discuss.elastic.co/u/PeterPain)\
**Post date:** [June 27, 2019, 1:29pm UTC](https://discuss.elastic.co/t/using-template-snippet-with-pipeline-processor/187842/1 "2019-06-27T13:29:52Z")

</div>

Hey there !  
I have a question about the **pipeline processor.**  
Does the processor provides the functionality of **templating**?  
I want to use different pipelines based on a field name.  
i tried using the following pipeline, but unfortunately it doesn't work.  
elasticsearch is looking for a pipeline called **"netzwerk\_{{myfield}}\_pipeline"** and not  
for the actual pipeline

```
{
  "description" : "outer network pipeline",
  "processors" : [
    {
      "pipeline" : {
        "name": "netzwerk_{{myfield}}_pipeline"
      }
    },
    {
        "script" : {
          "lang" : "painless",
          "source" : """
			    if (ctx.monitor.status == "up"){
              ctx.rtt.ms = ctx.rtt.us * params.divisor;
              }
            """,
            "params": {
              "divisor" : 0.001
            }
          }
    },
    {
      "set" : {
        "field" : "testfield",
        "value" : "testvalue"
      }
    }
  ]
}

```

Is this somehow possible ?

---

<div class="post-metadata">

**Author:** ![PeterPain](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@PeterPain](https://discuss.elastic.co/u/PeterPain)\
**Post date:** [June 28, 2019, 6:15am UTC](https://discuss.elastic.co/t/using-template-snippet-with-pipeline-processor/187842/2 "2019-06-28T06:15:18Z")

</div>

Found a solution for my problem.  
You can use conditional within the pipeline processor.

```
PUT _ingest/pipeline/logs_pipeline
{
  "description": "A pipeline of pipelines for log files",
  "version": 1,
  "processors": [
    {
      "pipeline": {
        "if": "ctx.service?.name == 'apache_httpd'",
        "name": "httpd_pipeline"
      }
    },
    {
      "pipeline": {
        "if": "ctx.service?.name == 'syslog'",
        "name": "syslog_pipeline"
      }
    },
    {
      "fail": {
        "message": "This pipeline requires service.name to be either `syslog` or `apache_httpd`"
      }
    }
  ]
}
```

---

<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:** [July 26, 2019, 6:15am UTC](https://discuss.elastic.co/t/using-template-snippet-with-pipeline-processor/187842/3 "2019-07-26T06:15:29Z")

</div>

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