# Unable to index a file in elasticsearch

**URL:** https://discuss.elastic.co/t/unable-to-index-a-file-in-elasticsearch/102582
**Category:** Elasticsearch
**Created:** [October 3, 2017, 3:00pm UTC](https://discuss.elastic.co/t/unable-to-index-a-file-in-elasticsearch/102582 "2017-10-03T15:00:50Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![f1ccb489d33b33a0f12a](https://avatars.discourse-cdn.com/v4/letter/f/2bfe46/32.png) [@f1ccb489d33b33a0f12a](https://discuss.elastic.co/u/f1ccb489d33b33a0f12a)
#### Post date: [October 3, 2017, 3:00pm UTC](https://discuss.elastic.co/t/unable-to-index-a-file-in-elasticsearch/102582/1 "2017-10-03T15:00:51Z")

</div>

i'm using elasticsearch 5.6.0 with logstash and filebeats.

i'm trying to index my files by the pattern "filebeat-" and then the source file name.  
when i used a simple string like "hello" the file got indexed correctly. when i tried to add the filename to the index non of it was received in elasticsearch discovery and iwasn't able to find the index.

here is my logstash configfile:  
input {  
beats {  
port =\> 5044  
}  
}  
filter {  
grok {  
break\_on\_match =\> false  
match =\> { "message" =\> "some pattern to match file context"  
"source" =\> "some pattern to match filename.log$" "  
}  
}  
mutate { add\_field =\> { "[@metadata][filename]" =\> "%{filename}" } }  
}  
output {  
elasticsearch {  
hosts =\> ["[http://localhost:9200](http://localhost:9200)"]  
manage\_template =\> false  
index =\> "%{[@metadata][beat]}-%{[@metadata][filename]}"  
document\_type =\> "%{[@metadata][type]}"  
user =\> "elastic"  
password =\> "1234"  
}  
}

when i used output to stdout with ruby debug i saw that "[@metadata][filename]" had the right name in it.  
and the data was parsed as i wanted. only the index is the problem

hope anyone can help.

---

<div class="post-metadata">

### Author: ![immavalls](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/immavalls/32/146501_2.png) [@immavalls](https://discuss.elastic.co/u/immavalls)
#### Post date: [October 4, 2017, 7:27am UTC](https://discuss.elastic.co/t/unable-to-index-a-file-in-elasticsearch/102582/2 "2017-10-04T07:27:04Z")

</div>

What's your filename? Elastic index names have some restrictions, and that might be an issue.

---

<div class="post-metadata">

### Author: ![f1ccb489d33b33a0f12a](https://avatars.discourse-cdn.com/v4/letter/f/2bfe46/32.png) [@f1ccb489d33b33a0f12a](https://discuss.elastic.co/u/f1ccb489d33b33a0f12a)
#### Post date: [October 8, 2017, 8:56am UTC](https://discuss.elastic.co/t/unable-to-index-a-file-in-elasticsearch/102582/3 "2017-10-08T08:56:53Z")

</div>

my file name is in the format of:

"aaa.bbb.d0.ccc.f1-ddd.eee.csv".

can you see the problem? maybe the dots?

---

<div class="post-metadata">

### Author: ![immavalls](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/immavalls/32/146501_2.png) [@immavalls](https://discuss.elastic.co/u/immavalls)
#### Post date: [October 8, 2017, 9:18am UTC](https://discuss.elastic.co/t/unable-to-index-a-file-in-elasticsearch/102582/4 "2017-10-08T09:18:24Z")

</div>

Yes, I think you can't use dots or certain special characters. Try changing the index name, no dots.

It'd be easier to debug the problem if you can create the index directly on elastic search via the API ([https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html)), and see if it gets created or what's the error you get. Then move to logstash.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [October 8, 2017, 9:30am UTC](https://discuss.elastic.co/t/unable-to-index-a-file-in-elasticsearch/102582/5 "2017-10-08T09:30:19Z")

</div>

Are you sure you want to create one index per file?

---

<div class="post-metadata">

### Author: ![f1ccb489d33b33a0f12a](https://avatars.discourse-cdn.com/v4/letter/f/2bfe46/32.png) [@f1ccb489d33b33a0f12a](https://discuss.elastic.co/u/f1ccb489d33b33a0f12a)
#### Post date: [October 8, 2017, 9:55am UTC](https://discuss.elastic.co/t/unable-to-index-a-file-in-elasticsearch/102582/6 "2017-10-08T09:55:28Z")

</div>

this was very helpful.  
i tried my index with the API and saw the error that prevented me from indexing my files. it was a lowercase problem.

thank you very much for your help

---

<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: [November 5, 2017, 9:55am UTC](https://discuss.elastic.co/t/unable-to-index-a-file-in-elasticsearch/102582/7 "2017-11-05T09:55:28Z")

</div>

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