# Logstash: access name of current pipeline within cfg?

**URL:** https://discuss.elastic.co/t/logstash-access-name-of-current-pipeline-within-cfg/195786
**Category:** Logstash
**Created:** [August 19, 2019, 5:19pm UTC](https://discuss.elastic.co/t/logstash-access-name-of-current-pipeline-within-cfg/195786 "2019-08-19T17:19:10Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![barnetta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/barnetta/32/52383_2.png) [@barnetta](https://discuss.elastic.co/u/barnetta)
#### Post date: [August 19, 2019, 5:19pm UTC](https://discuss.elastic.co/t/logstash-access-name-of-current-pipeline-within-cfg/195786/1 "2019-08-19T17:19:11Z")

</div>

Is it possible to access the name of the current pipeline within cfg?

For example, my `pipelines.yml` might contain:

```auto
- pipeline.id: pipeline.triage
  path.config: "/etc/logstash/pipelines/pipeline.triage.conf"
- pipeline.id: pipeline.fallback
  path.config: "/etc/logstash/pipelines/pipeline.fallback.conf"

```

Within `pipeline.triage.conf`, I want to have something like:

```auto
  mutate {
    add_field => { "[pipeline][history]" => "%{[_pipeline]}" ]
  }

```

Goal: I would like `[pipeline][history]` to end up with a literal value of `pipeline.fallback`, but without having to hardcode that value in the config.

I hoped that [Accessing Event Data and Fields in the Configuration](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html) might contain a hint, but if it's there, I couldn't see it.

---

<div class="post-metadata">

### Author: ![Luca\_Belluccini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luca_belluccini/32/33239_2.png) [@Luca\_Belluccini](https://discuss.elastic.co/u/Luca_Belluccini)
#### Post date: [September 6, 2019, 10:55am UTC](https://discuss.elastic.co/t/logstash-access-name-of-current-pipeline-within-cfg/195786/2 "2019-09-06T10:55:07Z")

</div>

Hello,  
At the moment it's not possible to have the name of the pipeline from the `[@metadata]` fields, but you can get them via Ruby using:

```auto
ruby { code => "event.set(\"pipeline_id\", execution_context.pipeline.pipeline_id)" }

```

Please note this will trigger an error if you're not using multiple pipelines.

Hope it helps!

Best regards,  
Luca

---

<div class="post-metadata">

### Author: ![barnetta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/barnetta/32/52383_2.png) [@barnetta](https://discuss.elastic.co/u/barnetta)
#### Post date: [September 10, 2019, 3:51pm UTC](https://discuss.elastic.co/t/logstash-access-name-of-current-pipeline-within-cfg/195786/3 "2019-09-10T15:51:19Z")

</div>

Very useful. Thank you @Luca_Belluccini.

Is there some documentation which covers `execution_context` and its attributes? I did have a look, but couldn't find it.

---

<div class="post-metadata">

### Author: ![Luca\_Belluccini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luca_belluccini/32/33239_2.png) [@Luca\_Belluccini](https://discuss.elastic.co/u/Luca_Belluccini)
#### Post date: [September 10, 2019, 4:39pm UTC](https://discuss.elastic.co/t/logstash-access-name-of-current-pipeline-within-cfg/195786/4 "2019-09-10T16:39:37Z")

</div>

I agree it's missing from the documentation, but probably because this is a **non-public** attribute which is passed to all plugins (inputs, filters, outputs - see [here](https://github.com/elastic/logstash/search?q=include_context+%22execution_context%22&unscoped_q=include_context+%22execution_context%22)). It is subject to change without notice.

We could raise an issue to check if this is expected to be public or not in the future.

---

<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: [October 8, 2019, 4:39pm UTC](https://discuss.elastic.co/t/logstash-access-name-of-current-pipeline-within-cfg/195786/5 "2019-10-08T16:39:46Z")

</div>

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