# How to create if conditional statement in logstash config file

**URL:** <https://discuss.elastic.co/t/how-to-create-if-conditional-statement-in-logstash-config-file/153118>\
**Category:** Elasticsearch\
**Created:** [October 19, 2018, 6:43am UTC](https://discuss.elastic.co/t/how-to-create-if-conditional-statement-in-logstash-config-file/153118 "2018-10-19T06:43:54Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nethaji](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nethaji/32/72803_2.png) [@Nethaji](https://discuss.elastic.co/u/Nethaji)\
**Post date:** [October 19, 2018, 6:43am UTC](https://discuss.elastic.co/t/how-to-create-if-conditional-statement-in-logstash-config-file/153118/1 "2018-10-19T06:43:54Z")

</div>

Hi,

how to select the mysql query in elasticsearch config file based on if condition statement?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [October 19, 2018, 6:52am UTC](https://discuss.elastic.co/t/how-to-create-if-conditional-statement-in-logstash-config-file/153118/2 "2018-10-19T06:52:46Z")

</div>

There is no MySQL query in the elasticsearch.yml file and no conditionals. What are you trying to do?

---

<div class="post-metadata">

**Author:** ![Nethaji](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nethaji/32/72803_2.png) [@Nethaji](https://discuss.elastic.co/u/Nethaji)\
**Post date:** [October 19, 2018, 7:07am UTC](https://discuss.elastic.co/t/how-to-create-if-conditional-statement-in-logstash-config-file/153118/3 "2018-10-19T07:07:15Z")

</div>

Actually i fetch the data from mysql.

is there any alter option available?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [October 19, 2018, 7:09am UTC](https://discuss.elastic.co/t/how-to-create-if-conditional-statement-in-logstash-config-file/153118/4 "2018-10-19T07:09:53Z")

</div>

One way to move data from MySQL to Elasticsearch is using Logstash. Elasticsearch has no built in way to do this.

---

<div class="post-metadata">

**Author:** ![Nethaji](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nethaji/32/72803_2.png) [@Nethaji](https://discuss.elastic.co/u/Nethaji)\
**Post date:** [October 19, 2018, 7:19am UTC](https://discuss.elastic.co/t/how-to-create-if-conditional-statement-in-logstash-config-file/153118/5 "2018-10-19T07:19:25Z")

</div>

Absolutely i tried in this way only.

---

<div class="post-metadata">

**Author:** ![Nethaji](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nethaji/32/72803_2.png) [@Nethaji](https://discuss.elastic.co/u/Nethaji)\
**Post date:** [October 19, 2018, 7:20am UTC](https://discuss.elastic.co/t/how-to-create-if-conditional-statement-in-logstash-config-file/153118/6 "2018-10-19T07:20:47Z")

</div>

now i can able to make conditional statement?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [October 19, 2018, 7:28am UTC](https://discuss.elastic.co/t/how-to-create-if-conditional-statement-in-logstash-config-file/153118/7 "2018-10-19T07:28:04Z")

</div>

What type of conditional statement?

---

<div class="post-metadata">

**Author:** ![Nethaji](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nethaji/32/72803_2.png) [@Nethaji](https://discuss.elastic.co/u/Nethaji)\
**Post date:** [October 19, 2018, 7:32am UTC](https://discuss.elastic.co/t/how-to-create-if-conditional-statement-in-logstash-config-file/153118/8 "2018-10-19T07:32:21Z")

</div>

If conditional statement

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [October 19, 2018, 7:40am UTC](https://discuss.elastic.co/t/how-to-create-if-conditional-statement-in-logstash-config-file/153118/9 "2018-10-19T07:40:05Z")

</div>

As I said earlier, you most likely need to use Logstash to move data from MySQL to Elasticsearch. Have a look at the [Logstash documentation](https://www.elastic.co/guide/en/logstash/6.4/getting-started-with-logstash.html) and this [blog post](https://www.elastic.co/blog/logstash-jdbc-input-plugin) and the [official documentation](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html) on how to use the jdbc input plugin. If you have any further questions on this, create a thread in the Logstash category.

---

<div class="post-metadata">

**Author:** ![Nethaji](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nethaji/32/72803_2.png) [@Nethaji](https://discuss.elastic.co/u/Nethaji)\
**Post date:** [October 19, 2018, 7:42am UTC](https://discuss.elastic.co/t/how-to-create-if-conditional-statement-in-logstash-config-file/153118/10 "2018-10-19T07:42:18Z")

</div>

Eg:  
if [status\_id] == 1 means i need to change this name to "lowest version"

can u explain how to do this?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [October 19, 2018, 7:50am UTC](https://discuss.elastic.co/t/how-to-create-if-conditional-statement-in-logstash-config-file/153118/11 "2018-10-19T07:50:26Z")

</div>

If this is a Logstash question, please create a new thread under the Logstash category where you describe what you want to do and what you have got so far in terms of configuration. The more specific questions you have the more likely you are to get a response, so make sure you have gone through the documentation and understand how Logstash works. [This blog post](https://www.elastic.co/blog/a-practical-introduction-to-logstash) may also be a good resource even though it does not use the jdbc input plugin.

---

<div class="post-metadata">

**Author:** ![Nethaji](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nethaji/32/72803_2.png) [@Nethaji](https://discuss.elastic.co/u/Nethaji)\
**Post date:** [October 19, 2018, 7:53am UTC](https://discuss.elastic.co/t/how-to-create-if-conditional-statement-in-logstash-config-file/153118/12 "2018-10-19T07:53:56Z")

</div>

thank you

---

<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 16, 2018, 8:07am UTC](https://discuss.elastic.co/t/how-to-create-if-conditional-statement-in-logstash-config-file/153118/13 "2018-11-16T08:07:36Z")

</div>

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