# Invalid Index Name Exception

**URL:** <https://discuss.elastic.co/t/invalid-index-name-exception/312908>\
**Category:** Logstash\
**Created:** [August 25, 2022, 11:07am UTC](https://discuss.elastic.co/t/invalid-index-name-exception/312908 "2022-08-25T11:07:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hnf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hnf/32/109840_2.png) [@hnf](https://discuss.elastic.co/u/hnf)\
**Post date:** [August 25, 2022, 11:07am UTC](https://discuss.elastic.co/t/invalid-index-name-exception/312908/1 "2022-08-25T11:07:34Z")

</div>

Hello everyone,

I have an issue when I try to make an index a field created using **add\_field** by referencing them when outputing. I create three .conf files that begin by a number , like **1file.conf** , **2file.conf** and **99output.conf** , this in order the output file be the last file to compile. In the first 2 files, I create the field by using the same name, for example, I `add_field => { "indexname" => "field_reference1" }`

Here i my output file:

```auto
output {
        elasticsearch {
                hosts => ["https://10.173.86.15:9200"]
                ...
                index => "%{[indexname]}"
        }
}

```

I'm getting an invalid index name exception with the error below:

```auto
response=>{"index"=>{"_index"=>"field_reference1,field_reference2", "_id"=>nil, "status"=>400, "error"=>{"type"=>"invalid_index_name_exception", "reason"=>"Invalid index name [field_reference1,field_reference2], must not contain the following characters ['\\','/','*','?','\"','<','>','|',' ',',']", "index_uuid"=>"_na_", "index"=>"field_reference1,field_reference2"}}}}

```

I don't know what I'm missing. Please help.  
Thanks a lot in advance.

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [August 25, 2022, 1:06pm UTC](https://discuss.elastic.co/t/invalid-index-name-exception/312908/2 "2022-08-25T13:06:08Z")

</div>

You need to share your configurations because it is not possible to understand what is happening.

But from your error, it means that the field `indexname` has a comma (`,`) in it, which is not allowed.

From what you shared, the index name you are trying to create is this `field_reference1,field_reference2`, which will not work because of the comma.

---

<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:** [August 25, 2022, 4:42pm UTC](https://discuss.elastic.co/t/invalid-index-name-exception/312908/3 "2022-08-25T16:42:29Z")

</div>

> [@hnf](#):
>
> "reason"=\>"Invalid index name [field\_reference1,field\_reference2]

I suspect you are unconditionally doing both the

```
add_field => { "indexname" => "field_reference1" }

```

and

```
add_field => { "indexname" => "field_reference2" }

```

for the same events. In that case indexname will be an array and if the logstash calls .to\_s to convert that to a string (which the index option has to be) then it will end up with comma separated names, causing elasticsearch to throw that exception.

---

<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:** [September 22, 2022, 4:43pm UTC](https://discuss.elastic.co/t/invalid-index-name-exception/312908/4 "2022-09-22T16:43:09Z")

</div>

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