# Logstash JDBC and Firebird

**URL:** <https://discuss.elastic.co/t/logstash-jdbc-and-firebird/213393>\
**Category:** Logstash\
**Created:** [December 30, 2019, 11:43pm UTC](https://discuss.elastic.co/t/logstash-jdbc-and-firebird/213393 "2019-12-30T23:43:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Osiel](https://avatars.discourse-cdn.com/v4/letter/o/a587f6/32.png) [@Osiel](https://discuss.elastic.co/u/Osiel)\
**Post date:** [December 30, 2019, 11:43pm UTC](https://discuss.elastic.co/t/logstash-jdbc-and-firebird/213393/1 "2019-12-30T23:43:55Z")

</div>

I need some help setting up logstash with jdbc and firebird 2.5 database, I'm using version 7.5 of elastic and logstash.  
What happens is that I always need to overwrite the information in my indexes, ie will always have the same amount of record but always updated because my filter is by date, I'm doing this because I'm testing on a dashboard. The problem is that every time he enters the information he mixes the records already tried several configurations as the manual does not evolve below my test setup.  
In summary the result of each select is mixed with the subsequent one.  
\*\*\* I used google translator so I'm sorry anything in english

`
```
    input{
    	jdbc {
	    jdbc_driver_library => "C:\Users\Siamaco\Downloads\Jaybird-3.0.8-JDK_1.8\jaybird-full-3.0.8.jar"
	    jdbc_driver_class => "org.firebirdsql.jdbc.FBDriver"
	    jdbc_connection_string => "jdbc:firebirdsql:127.0.0.1/3050:C:\_Developer\_SVN\Siamaco\ATIVOS\Hypar\hotFix-4000\Projetos\exec\BASEDADOS.FDB"
	    jdbc_user => "SYSDBA"
	    jdbc_password => "masterkey"        	    
	    statement_filepath => "C:\_Developer\Elastic\SQL\ContasReceber\cheques_devolvidos.sql"
	    jdbc_paging_enabled => false
	    jdbc_page_size => 0
		use_column_value => false
# tracking_column => "total_cheque_devolvido"		 
# last_run_metadata_path => "C:\_Developer\Elastic\logstash-7.5.0\bin\last_run_cheques_devolvidos.txt"    
		record_last_run => false
	}
}

output{
	elasticsearch{
	  hosts => ["localhost:9200"]	  
	  index => "cheques_devolvidos"
	  document_id => "%{total_cheque_devolvido}"
	}
}	

input{
	jdbc {
    jdbc_driver_library => "C:\Users\Siamaco\Downloads\Jaybird-3.0.8-JDK_1.8\jaybird-full-3.0.8.jar"
    jdbc_driver_class => "org.firebirdsql.jdbc.FBDriver"
    jdbc_connection_string => "jdbc:firebirdsql:127.0.0.1/3050:C:\_Developer\_SVN\Siamaco\ATIVOS\Hypar\hotFix-4000\Projetos\exec\BASEDADOS.FDB"
    jdbc_user => "SYSDBA"
    jdbc_password => "masterkey"            
    statement_filepath => "C:\_Developer\Elastic\SQL\ContasReceber\ranking_clientes.sql"
    jdbc_paging_enabled => false
    jdbc_page_size => 0      
 	use_column_value => false 	 
# tracking_column => "nr_cliente"
# last_run_metadata_path => "C:\_Developer\Elastic\logstash-7.5.0\bin\last_run_ranking_clientes.txt"   
    record_last_run => false
  }

}

output{
	elasticsearch{
	  hosts => ["localhost:9200"]	  
	  index => "ranking_clientes"
	  document_id => "%{nr_cliente}"
	}
}

input{
	jdbc {
	    jdbc_driver_library => "C:\Users\Siamaco\Downloads\Jaybird-3.0.8-JDK_1.8\jaybird-full-3.0.8.jar"
	    jdbc_driver_class => "org.firebirdsql.jdbc.FBDriver"
	    jdbc_connection_string => "jdbc:firebirdsql:127.0.0.1/3050:C:\_Developer\_SVN\Siamaco\ATIVOS\Hypar\hotFix-4000\Projetos\exec\BASEDADOS.FDB"
	    jdbc_user => "SYSDBA"
	    jdbc_password => "masterkey"        	    
	    statement_filepath => "C:\_Developer\Elastic\SQL\ContasReceber\valor_todos_titulos_abertos.sql"
	    jdbc_paging_enabled => false
	    jdbc_page_size => 0
		use_column_value => false	
# tracking_column => "total_titulos_abertos"		 
# last_run_metadata_path => "C:\_Developer\Elastic\logstash-7.5.0\bin\last_run_valor_todos_titulos_abertos.txt" 
		record_last_run => false   
	}
}

output{
	elasticsearch{
	  hosts => ["localhost:9200"]	  
	  index => "valor_todos_titulos_abertos"
	  document_id => "%{total_titulos_abertos}"	  	  
	}
}

```
`

---

<div class="post-metadata">

**Author:** ![Osiel](https://avatars.discourse-cdn.com/v4/letter/o/a587f6/32.png) [@Osiel](https://discuss.elastic.co/u/Osiel)\
**Post date:** [January 6, 2020, 6:09pm UTC](https://discuss.elastic.co/t/logstash-jdbc-and-firebird/213393/2 "2020-01-06T18:09:59Z")

</div>

Any idea?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [January 6, 2020, 6:36pm UTC](https://discuss.elastic.co/t/logstash-jdbc-and-firebird/213393/3 "2020-01-06T18:36:35Z")

</div>

> [@Osiel](#):
>
> In summary the result of each select is mixed with the subsequent one.

That is expected. When a pipeline is started, events are read all of the inputs, put through the filters, then written to all of the outputs.

Either, split your configuration into 3 files, and run each one in a different pipeline, or use conditionals. For example

```
input{
	jdbc {
    jdbc_driver_library => "C:\Users\Siamaco\Downloads\Jaybird-3.0.8-JDK_1.8\jaybird-full-3.0.8.jar"
    [...]
    statement_filepath => "C:\_Developer\Elastic\SQL\ContasReceber\cheques_devolvidos.sql"
[....]
        add_tag => ["cheques_devolvidos"]
}
}

output{
    if "cheques_devolvidos" in [tags] {
        elasticsearch{
            hosts => ["localhost:9200"]	  
            index => "cheques_devolvidos"
            document_id => "%{total_cheque_devolvido}"
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![Osiel](https://avatars.discourse-cdn.com/v4/letter/o/a587f6/32.png) [@Osiel](https://discuss.elastic.co/u/Osiel)\
**Post date:** [January 7, 2020, 2:54am UTC](https://discuss.elastic.co/t/logstash-jdbc-and-firebird/213393/4 "2020-01-07T02:54:44Z")

</div>

Thanks a lot for the tip my updated code looked like this:

```
input{
	jdbc {
	    jdbc_driver_library => "C:\Users\Siamaco\Downloads\Jaybird-3.0.8-JDK_1.8\jaybird-full-3.0.8.jar"
	    jdbc_driver_class => "org.firebirdsql.jdbc.FBDriver"
	    jdbc_connection_string => "jdbc:firebirdsql:127.0.0.1/3050:C:\_Developer\_SVN\Siamaco\ATIVOS\Hypar\hotFix-4000\Projetos\exec\BASEDADOS.FDB"
	    jdbc_user => "SYSDBA"
	    jdbc_password => "masterkey"        	    
	    statement_filepath => "C:\_Developer\Elastic\SQL\ContasReceber\valor_todos_titulos_abertos.sql"
	    use_column_value => true
	    tracking_column => "total_titulos_abertos"
	    jdbc_paging_enabled => "true"
	    jdbc_page_size => "50000"
	    tracking_column_type => "numeric"
		last_run_metadata_path => "C:\_Developer\Elastic\logstash-7.5.0\bin\last_run_valor_todos_titulos_abertos.txt" 
		tags => ["valor_todos_titulos_abertos"] 			
	}
}

output{
	if "valor_todos_titulos_abertos" in [tags] {      
		elasticsearch{
	  		hosts => ["localhost:9200"]	  
	  		index => "valor_todos_titulos_abertos"
	  		document_id => "%{total_titulos_abertos}"	  	  
		}
	}	
}

```

A curiosity when you said running in three different files is not complex runs it as a service?

---

<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:** [February 4, 2020, 2:54am UTC](https://discuss.elastic.co/t/logstash-jdbc-and-firebird/213393/5 "2020-02-04T02:54:51Z")

</div>

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