# Conditional Index Value in output

**URL:** <https://discuss.elastic.co/t/conditional-index-value-in-output/201448>\
**Category:** Logstash\
**Created:** [September 27, 2019, 5:26pm UTC](https://discuss.elastic.co/t/conditional-index-value-in-output/201448 "2019-09-27T17:26:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ccaviris89](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@ccaviris89](https://discuss.elastic.co/u/ccaviris89)\
**Post date:** [September 27, 2019, 5:26pm UTC](https://discuss.elastic.co/t/conditional-index-value-in-output/201448/1 "2019-09-27T17:26:29Z")

</div>

I was looking at [this](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html) and trying to work in conditional logic on my pipeline.conf output so that if a given field exists, the index with have one values, and otherwise it will default to another value.

I currently have something like this:  
output {  
elasticsearch {  
hosts =\> ["\<host\_name\>:\<port\_number\>"]  
index =\> "logstash-%{+YYYY.MM}"  
}  
}

I've tried a few different things, but keep getting something like:  
Failed to execute action {:action=\>LogStash::PipelineAction::Create/pipeline\_id:main, :exception=\>"LogStash::ConfigurationError", :message=\>"Expected one of #, =\> at line 53, column 11 (byte 758) after output

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [September 30, 2019, 2:17pm UTC](https://discuss.elastic.co/t/conditional-index-value-in-output/201448/2 "2019-09-30T14:17:47Z")

</div>

What does the complete configuration look like, and is that the complete error message?

---

<div class="post-metadata">

**Author:** ![ccaviris89](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@ccaviris89](https://discuss.elastic.co/u/ccaviris89)\
**Post date:** [September 30, 2019, 4:08pm UTC](https://discuss.elastic.co/t/conditional-index-value-in-output/201448/3 "2019-09-30T16:08:28Z")

</div>

That's the message. The full config looks like this:

input {  
http {  
}  
}

filter {

```
json {
    source => "message"
}

mutate {
    rename => ["_duration", "duration"]
}

mutate {

    convert => {

```

...  
several conversions  
...  
}

```
}

mutate {
    remove_field => ["headers", "message"]
}

```

}

output {  
elasticsearch {  
hosts =\> ["hostName:portNumber"]  
index =\> "logstash-%{+YYYY.MM}"  
}  
}

---

<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 28, 2019, 4:08pm UTC](https://discuss.elastic.co/t/conditional-index-value-in-output/201448/4 "2019-10-28T16:08:32Z")

</div>

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