# How to run postgres in Ruby filter?

**URL:** <https://discuss.elastic.co/t/how-to-run-postgres-in-ruby-filter/133796>\
**Category:** Logstash\
**Created:** [May 30, 2018, 6:05am UTC](https://discuss.elastic.co/t/how-to-run-postgres-in-ruby-filter/133796 "2018-05-30T06:05:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![veerendranath\_lukkan](https://avatars.discourse-cdn.com/v4/letter/v/ea5d25/32.png) [@veerendranath\_lukkan](https://discuss.elastic.co/u/veerendranath_lukkan)\
**Post date:** [May 30, 2018, 6:05am UTC](https://discuss.elastic.co/t/how-to-run-postgres-in-ruby-filter/133796/1 "2018-05-30T06:05:45Z")

</div>

hi ,  
i am trying to check jdbc connection is available or not in ruby filter it is possible or not.

---

<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:** [May 30, 2018, 6:07am UTC](https://discuss.elastic.co/t/how-to-run-postgres-in-ruby-filter/133796/2 "2018-05-30T06:07:22Z")

</div>

I'm sure it's possible, but why do you want to do that? What's the purpose?

---

<div class="post-metadata">

**Author:** ![veerendranath\_lukkan](https://avatars.discourse-cdn.com/v4/letter/v/ea5d25/32.png) [@veerendranath\_lukkan](https://discuss.elastic.co/u/veerendranath_lukkan)\
**Post date:** [May 30, 2018, 8:12am UTC](https://discuss.elastic.co/t/how-to-run-postgres-in-ruby-filter/133796/3 "2018-05-30T08:12:29Z")

</div>

if database is stopped when data inserting into table then we can find database is not running  
and how to run any reference example to do ?

---

<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:** [May 30, 2018, 8:34am UTC](https://discuss.elastic.co/t/how-to-run-postgres-in-ruby-filter/133796/4 "2018-05-30T08:34:07Z")

</div>

> if database is stopped when data inserting into table then we can find database is not running

I don't understand what you mean. Please elaborate.

---

<div class="post-metadata">

**Author:** ![veerendranath\_lukkan](https://avatars.discourse-cdn.com/v4/letter/v/ea5d25/32.png) [@veerendranath\_lukkan](https://discuss.elastic.co/u/veerendranath_lukkan)\
**Post date:** [May 30, 2018, 9:43am UTC](https://discuss.elastic.co/t/how-to-run-postgres-in-ruby-filter/133796/5 "2018-05-30T09:43:06Z")

</div>

input{  
-- filebeat logfiles  
}  
filter{  
In this filter i am calling ruby code and i want to check database is available or not,if l database not available i will stop logstash is it possible

}  
output{  
jdbc{

}

}  
myError:  
no such file to load -- dbi loading require "dbi"

---

<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:** [May 30, 2018, 11:55am UTC](https://discuss.elastic.co/t/how-to-run-postgres-in-ruby-filter/133796/6 "2018-05-30T11:55:35Z")

</div>

Why do you need to stop Logstash if the database is unavailable?

---

<div class="post-metadata">

**Author:** ![veerendranath\_lukkan](https://avatars.discourse-cdn.com/v4/letter/v/ea5d25/32.png) [@veerendranath\_lukkan](https://discuss.elastic.co/u/veerendranath_lukkan)\
**Post date:** [May 31, 2018, 5:45am UTC](https://discuss.elastic.co/t/how-to-run-postgres-in-ruby-filter/133796/7 "2018-05-31T05:45:04Z")

</div>

Controlling purpose it is possible to connect DB in Ruby filter any reference

---

<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:** [May 31, 2018, 6:06am UTC](https://discuss.elastic.co/t/how-to-run-postgres-in-ruby-filter/133796/8 "2018-05-31T06:06:41Z")

</div>

As far as I can tell that sentence doesn't answer my question.

---

<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:** [June 28, 2018, 6:06am UTC](https://discuss.elastic.co/t/how-to-run-postgres-in-ruby-filter/133796/9 "2018-06-28T06:06:44Z")

</div>

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