# How can I set elasticsearch type in logstash conf file when importing?

**URL:** <https://discuss.elastic.co/t/how-can-i-set-elasticsearch-type-in-logstash-conf-file-when-importing/67579>\
**Category:** Logstash\
**Created:** [November 30, 2016, 5:58am UTC](https://discuss.elastic.co/t/how-can-i-set-elasticsearch-type-in-logstash-conf-file-when-importing/67579 "2016-11-30T05:58:25Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![tanimoto](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@tanimoto](https://discuss.elastic.co/u/tanimoto)\
**Post date:** [November 30, 2016, 5:58am UTC](https://discuss.elastic.co/t/how-can-i-set-elasticsearch-type-in-logstash-conf-file-when-importing/67579/1 "2016-11-30T05:58:25Z")

</div>

I'm trying to import CSV file to elasticsearch through logstash.  
data can be imported and type name is logs.  
Is there any way to change type name?  
Any setting to type name in logstash conf file when importing??

---

<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:** [November 30, 2016, 6:30am UTC](https://discuss.elastic.co/t/how-can-i-set-elasticsearch-type-in-logstash-conf-file-when-importing/67579/2 "2016-11-30T06:30:15Z")

</div>

Are you talking about the event's document type or the field's mapping type?

---

<div class="post-metadata">

**Author:** ![tanimoto](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@tanimoto](https://discuss.elastic.co/u/tanimoto)\
**Post date:** [November 30, 2016, 8:43am UTC](https://discuss.elastic.co/t/how-can-i-set-elasticsearch-type-in-logstash-conf-file-when-importing/67579/3 "2016-11-30T08:43:46Z")

</div>

i think field's document type.  
it automatically names as 'logs' when I import data through logstash.

my conf file is as below

```auto
input {
  file {
    path => "/tmp/es_data_ori.csv"
    start_position => "beginning"
  }
}
filter {
  csv {
    columns => ["column1","column2","column3"]
    separator => ";"
  }
}
output {
  elasticsearch {
    hosts => ["192.168.33.10"]
    index => "test"
    type => "items" //any property to set type name like this??
  }
}

```

I'm just beginning to use ES and logstash.  
I apologize in advance if I confuse any.

---

<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:** [November 30, 2016, 8:50am UTC](https://discuss.elastic.co/t/how-can-i-set-elasticsearch-type-in-logstash-conf-file-when-importing/67579/4 "2016-11-30T08:50:24Z")

</div>

Add

```
type => "items"

```

to your file input or set

```
document_type => "items"

```

in your elasticsearch output. I prefer the former way since it gives you a `type` field that you can use to filter events from different sources in different ways.

---

<div class="post-metadata">

**Author:** ![tanimoto](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@tanimoto](https://discuss.elastic.co/u/tanimoto)\
**Post date:** [November 30, 2016, 10:30am UTC](https://discuss.elastic.co/t/how-can-i-set-elasticsearch-type-in-logstash-conf-file-when-importing/67579/5 "2016-11-30T10:30:22Z")

</div>

i tried the setting that you mentioned above.  
suddenly, logstash doesn't run itself.  
according to log, logstash can't find /etc/logstash/conf.d.

i didn't change anything except the setting .  
as I returned the setting yet logstash doesnt run...  
what happend??

Is this irrelevant to this page issue???

---

<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:** [November 30, 2016, 12:04pm UTC](https://discuss.elastic.co/t/how-can-i-set-elasticsearch-type-in-logstash-conf-file-when-importing/67579/6 "2016-11-30T12:04:56Z")

</div>

> according to log, logstash can't find /etc/logstash/conf.d.

Please show the exact error message.

---

<div class="post-metadata">

**Author:** ![tanimoto](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@tanimoto](https://discuss.elastic.co/u/tanimoto)\
**Post date:** [December 1, 2016, 1:44am UTC](https://discuss.elastic.co/t/how-can-i-set-elasticsearch-type-in-logstash-conf-file-when-importing/67579/7 "2016-12-01T01:44:52Z")

</div>

/var/log/logstash/logstash.err

```auto
{:timestamp=>"2016-11-29T02:40:01.820000+0000", :message=>"No config files found: /etc/logstash/conf.d/*\nCan you make sure this path is a logstash config file?", :level=>:error}

```

i checked the directory `/etc/logstash/conf.d` and there is no file in it.  
I haven't changed or removed anything.

---

<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:** [December 2, 2016, 6:51am UTC](https://discuss.elastic.co/t/how-can-i-set-elasticsearch-type-in-logstash-conf-file-when-importing/67579/8 "2016-12-02T06:51:26Z")

</div>

I'm confused. What are you asking?

- Logstash never deletes configuration files.
- Logstash typically expects configuration files to reside in /etc/logstash/conf.d (and it obviously does in your case).
- It's up to you to store the configuration files in /etc/logstash/conf.d.

---

<div class="post-metadata">

**Author:** ![tanimoto](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@tanimoto](https://discuss.elastic.co/u/tanimoto)\
**Post date:** [December 2, 2016, 7:46am UTC](https://discuss.elastic.co/t/how-can-i-set-elasticsearch-type-in-logstash-conf-file-when-importing/67579/9 "2016-12-02T07:46:51Z")

</div>

sorry to make you confused.

I thought conf file was deleted or moved by logstash process but it was wrong.  
just ignore these lines.

```auto
i checked the directory /etc/logstash/conf.d and there is no file in it.
I haven't changed or removed anything.

```

my question is simply why is logstash not able to start after trying to imprt CSV file?  
If you have heard similar issue before, any suggestion?

---

<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:** [December 2, 2016, 8:24am UTC](https://discuss.elastic.co/t/how-can-i-set-elasticsearch-type-in-logstash-conf-file-when-importing/67579/10 "2016-12-02T08:24:44Z")

</div>

> my question is simply why is logstash not able to start after trying to imprt CSV file?

Have you stored your configuration file in /etc/logstash/conf.d? If yes, what's the new error message you get in the log?

---

<div class="post-metadata">

**Author:** ![tanimoto](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@tanimoto](https://discuss.elastic.co/u/tanimoto)\
**Post date:** [December 2, 2016, 8:41am UTC](https://discuss.elastic.co/t/how-can-i-set-elasticsearch-type-in-logstash-conf-file-when-importing/67579/11 "2016-12-02T08:41:17Z")

</div>

I put empty conf file named conf.d as test in /etc/logstash/conf.d/ directory and error message is like this.

```auto
message=>"fetched an invalid config", :config=>"\n", :reason=>"Expected one of #, input, filter, output at line 2, column 1 (byte 2) after \n", :level=>:error}

```

---

<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:** [December 2, 2016, 8:45am UTC](https://discuss.elastic.co/t/how-can-i-set-elasticsearch-type-in-logstash-conf-file-when-importing/67579/12 "2016-12-02T08:45:01Z")

</div>

Put the configuration file with the CSV import stuff in a file in /etc/logstash/conf.d. Over and out.

---

<div class="post-metadata">

**Author:** ![tanimoto](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@tanimoto](https://discuss.elastic.co/u/tanimoto)\
**Post date:** [December 2, 2016, 9:00am UTC](https://discuss.elastic.co/t/how-can-i-set-elasticsearch-type-in-logstash-conf-file-when-importing/67579/13 "2016-12-02T09:00:19Z")

</div>

OK.  
Thanks.

---

<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:** [December 30, 2016, 9:00am UTC](https://discuss.elastic.co/t/how-can-i-set-elasticsearch-type-in-logstash-conf-file-when-importing/67579/14 "2016-12-30T09:00:22Z")

</div>

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