# Logstash: Calling WebService or a program from filters

**URL:** <https://discuss.elastic.co/t/logstash-calling-webservice-or-a-program-from-filters/37760>\
**Category:** Logstash\
**Created:** [December 22, 2015, 2:00pm UTC](https://discuss.elastic.co/t/logstash-calling-webservice-or-a-program-from-filters/37760 "2015-12-22T14:00:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![krushnat\_khawale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krushnat_khawale/32/6652_2.png) [@krushnat\_khawale](https://discuss.elastic.co/u/krushnat_khawale)\
**Post date:** [December 22, 2015, 2:00pm UTC](https://discuss.elastic.co/t/logstash-calling-webservice-or-a-program-from-filters/37760/1 "2015-12-22T14:00:58Z")

</div>

I am working on logstash to extract data from mysql,  
as existing filters/plugins lack in doing required operations/transformations  
I think I need to create a program of my own to do this.

**My question is, Is it possible to call a java program/function or a webservice from filter?**

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![CraigFoote](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/craigfoote/32/4571_2.png) [@CraigFoote](https://discuss.elastic.co/u/CraigFoote)\
**Post date:** [December 22, 2015, 3:34pm UTC](https://discuss.elastic.co/t/logstash-calling-webservice-or-a-program-from-filters/37760/2 "2015-12-22T15:34:36Z")

</div>

I'm using the JDBC input with a mysql connector. The plugin creates fields for each column I specify in the select statement. Would this not work for you?  
As to your question though I don't know if you can call such from a filter but I've used the exec input to make a curl call.

---

<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:** [December 22, 2015, 8:50pm UTC](https://discuss.elastic.co/t/logstash-calling-webservice-or-a-program-from-filters/37760/3 "2015-12-22T20:50:18Z")

</div>

There's also [https://www.elastic.co/guide/en/logstash/current/plugins-inputs-http.html](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-http.html) and [https://www.elastic.co/guide/en/logstash/current/plugins-inputs-http\_poller.html](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-http_poller.html)

---

<div class="post-metadata">

**Author:** ![krushnat\_khawale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krushnat_khawale/32/6652_2.png) [@krushnat\_khawale](https://discuss.elastic.co/u/krushnat_khawale)\
**Post date:** [December 23, 2015, 6:34am UTC](https://discuss.elastic.co/t/logstash-calling-webservice-or-a-program-from-filters/37760/4 "2015-12-23T06:34:52Z")

</div>

Thanks @CraigFoote and @warkolm for giving your time.

@warkolm I've gone through both the URL's you've mentioned and was really helpful.

I would also like to know if there is another way of calling external program/function (could be in any language) so that I can see which is efficient and will use.

@CraigFoote Can you please share a sample for using exec input for making url call and getting data from that?

Thanks once again for your help.

---

<div class="post-metadata">

**Author:** ![krushnat\_khawale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krushnat_khawale/32/6652_2.png) [@krushnat\_khawale](https://discuss.elastic.co/u/krushnat_khawale)\
**Post date:** [December 23, 2015, 10:03am UTC](https://discuss.elastic.co/t/logstash-calling-webservice-or-a-program-from-filters/37760/5 "2015-12-23T10:03:54Z")

</div>

Thanks @warkolm for giving your time.

@warkolm I've gone through both the URL's you've mentioned and was really helpful.

I would also like to know if there is another way of calling external program/function (could be in any language) so that I can see which is efficient and will use.

Thanks once again for your help.

---

<div class="post-metadata">

**Author:** ![CraigFoote](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/craigfoote/32/4571_2.png) [@CraigFoote](https://discuss.elastic.co/u/CraigFoote)\
**Post date:** [December 23, 2015, 6:47pm UTC](https://discuss.elastic.co/t/logstash-calling-webservice-or-a-program-from-filters/37760/6 "2015-12-23T18:47:04Z")

</div>

In my case we had a REST service that returned the JSON I needed so my logstash config was quite simple:

```
input{
    exec{
        command => "curl 'http://restservice.com'"
        codec => json
        interval => 60
    }
}
filter{
}
output{
    elasticsearch{
        ...
    }
}

```

But I imagine you could call a script or even a java program that sysouts json. Haven't tried it though.

---

<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:** [July 6, 2017, 5:17am UTC](https://discuss.elastic.co/t/logstash-calling-webservice-or-a-program-from-filters/37760/7 "2017-07-06T05:17:26Z")

</div>


