# Unable to set a boolean plugin property dynamically

**URL:** <https://discuss.elastic.co/t/unable-to-set-a-boolean-plugin-property-dynamically/128061>\
**Category:** Logstash\
**Created:** [April 15, 2018, 6:52am UTC](https://discuss.elastic.co/t/unable-to-set-a-boolean-plugin-property-dynamically/128061 "2018-04-15T06:52:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ItamarBenjamin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/itamarbenjamin/32/22863_2.png) [@ItamarBenjamin](https://discuss.elastic.co/u/ItamarBenjamin)\
**Post date:** [April 15, 2018, 6:52am UTC](https://discuss.elastic.co/t/unable-to-set-a-boolean-plugin-property-dynamically/128061/1 "2018-04-15T06:52:21Z")

</div>

Hi, there's an open issue for this in logstash-output-elasticsearch github ([here](https://github.com/logstash-plugins/logstash-output-elasticsearch/issues/384)) but i think it is not a specific plugin bug but logstash bug.

In short: if i want to set a boolean property dynamically, i cannot. if i configure my plugin with this:

```
output{
        elasticsearch {
                doc_as_upsert => "%{[@metadata][doc_as_upsert]}"
        }
}

```

it will complain for string to boolean assignment, and if i configure my plugin with this:

```
output{
        elasticsearch {
                doc_as_upsert => [@metadata][doc_as_upsert]
        }
}

```

it gets parsing error. as the parser probably comes from logstash and not from each plugin, i think it is more suitable to open the bug in the logstash level.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [April 15, 2018, 7:25pm UTC](https://discuss.elastic.co/t/unable-to-set-a-boolean-plugin-property-dynamically/128061/2 "2018-04-15T19:25:46Z")

</div>

This isn't a generic problem. By design not all options support sprintf interpolations. In many cases it's an oversight but there are cases when the option value can't be dynamic (or it would be too expensive to make it dynamic).

---

<div class="post-metadata">

**Author:** ![ItamarBenjamin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/itamarbenjamin/32/22863_2.png) [@ItamarBenjamin](https://discuss.elastic.co/u/ItamarBenjamin)\
**Post date:** [April 15, 2018, 7:54pm UTC](https://discuss.elastic.co/t/unable-to-set-a-boolean-plugin-property-dynamically/128061/3 "2018-04-15T19:54:16Z")

</div>

Thanks for the quick response. In this case its not really expensive to make it dynamic as this flag is simply sent to the http request sent to elastic search. All other fields like index and routing are also dynamic. What is your opinion on solving this? Can this be solved on the plugin level without breaking changes like changing the property to be a string value?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [April 16, 2018, 5:54am UTC](https://discuss.elastic.co/t/unable-to-set-a-boolean-plugin-property-dynamically/128061/4 "2018-04-16T05:54:17Z")

</div>

I don't think it would be difficult to fix. It's definitely a plugin-level change.

---

<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 14, 2018, 5:54am UTC](https://discuss.elastic.co/t/unable-to-set-a-boolean-plugin-property-dynamically/128061/5 "2018-05-14T05:54:21Z")

</div>

Closed on May 14, 2018, 5:54am UTC

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