# What are the default data types when Logstash reads from SQL DB?

**URL:** <https://discuss.elastic.co/t/what-are-the-default-data-types-when-logstash-reads-from-sql-db/103996>\
**Category:** Logstash\
**Created:** [October 14, 2017, 2:19pm UTC](https://discuss.elastic.co/t/what-are-the-default-data-types-when-logstash-reads-from-sql-db/103996 "2017-10-14T14:19:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![amruth](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@amruth](https://discuss.elastic.co/u/amruth)\
**Post date:** [October 14, 2017, 2:19pm UTC](https://discuss.elastic.co/t/what-are-the-default-data-types-when-logstash-reads-from-sql-db/103996/1 "2017-10-14T14:19:30Z")

</div>

Hi,

Can someone please say what are the default data types when Logstash reads data from SQL DB. Will it be the same as declared in the Sql server Database? And when I want to send it to Elasticsearch do I need to perform mutate convert option?

Thanks

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 14, 2017, 2:46pm UTC](https://discuss.elastic.co/t/what-are-the-default-data-types-when-logstash-reads-from-sql-db/103996/2 "2017-10-14T14:46:53Z")

</div>

> [@amruth](#):
>
> Will it be the same as declared in the Sql server Database?

No, Logstash has no concept of the types in the database.

> [@amruth](#):
>
> And when I want to send it to Elasticsearch do I need to perform mutate convert option?

Yes, or use a template or mapping.

---

<div class="post-metadata">

**Author:** ![amruth](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@amruth](https://discuss.elastic.co/u/amruth)\
**Post date:** [October 14, 2017, 7:08pm UTC](https://discuss.elastic.co/t/what-are-the-default-data-types-when-logstash-reads-from-sql-db/103996/3 "2017-10-14T19:08:18Z")

</div>

> [@warkolm](#):
>
> No, Logstash has no concept of the types in the database.

If the field is float in SQL server, what would it be when it's pushed to Elasticsearch? float or string?

And also I am pushing to ES index on monthly index i.e index-%{+YYYY.MM} from SQL server using Logstash. For the first month field "ID" was of type float and for the next month it is integer due to which there is a conflict of fields in Kibana.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 15, 2017, 4:59am UTC](https://discuss.elastic.co/t/what-are-the-default-data-types-when-logstash-reads-from-sql-db/103996/4 "2017-10-15T04:59:27Z")

</div>

> [@amruth](#):
>
> If the field is float in SQL server, what would it be when it's pushed to Elasticsearch? float or string?

Logstash doesn't care, it's just data to it. Elasticsearch will try to detect what it is though.

---

<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:** [October 16, 2017, 3:43am UTC](https://discuss.elastic.co/t/what-are-the-default-data-types-when-logstash-reads-from-sql-db/103996/5 "2017-10-16T03:43:08Z")

</div>

> Logstash doesn't care, it's just data to it. Elasticsearch will try to detect what it is though.

Well, Logstash does have a data type concept, and that data type could affect how ES detects the type. I'd assume that the SQL type is translated to roughly the same data type in Logstash, i.e. float and bools in the database should become floats and bools in Logstash (but whether those values become float and bool fields in ES is another matter).

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 17, 2017, 4:04am UTC](https://discuss.elastic.co/t/what-are-the-default-data-types-when-logstash-reads-from-sql-db/103996/6 "2017-10-17T04:04:50Z")

</div>

> [@magnusbaeck](#):
>
> Well, Logstash does have a data type concept, and that data type could affect how ES detects the type.

Yeah, but unless you explicitly cast them then it just looks it as a value with no type.  
And yes, you can cast that value so it's set and it will influence Elasticsearch, but there is still room for these sorts of conflicts.

Best option is to always have a template/mapping in place.

(I know you know this, just wanting to clarify for the thread 🙂)

---

<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 14, 2017, 4:04am UTC](https://discuss.elastic.co/t/what-are-the-default-data-types-when-logstash-reads-from-sql-db/103996/7 "2017-11-14T04:04:52Z")

</div>

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