# How to identify JDBC pipeline

**URL:** https://discuss.elastic.co/t/how-to-identify-jdbc-pipeline/102281
**Category:** Logstash
**Created:** [September 29, 2017, 4:15pm UTC](https://discuss.elastic.co/t/how-to-identify-jdbc-pipeline/102281 "2017-09-29T16:15:59Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![feijiangnan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/feijiangnan/32/20893_2.png) [@feijiangnan](https://discuss.elastic.co/u/feijiangnan)
#### Post date: [September 29, 2017, 4:15pm UTC](https://discuss.elastic.co/t/how-to-identify-jdbc-pipeline/102281/1 "2017-09-29T16:15:59Z")

</div>

Hello,

I have pipelines of Filebeat which are identified by [fields][document\_type] in logstash, and the indices are named with [fields][document\_type] . Now, I am adding JDBC pipeline, how can I set [fields][document\_type] in JDBC pipeline?

> input {  
> jdbc {  
> jdbc\_validate\_connection =\> true  
> jdbc\_connection\_string =\> "jdbc:oracle:thin:@oradb:1521/orcl"  
> jdbc\_user =\> "system"  
> jdbc\_password =\> "Admin123"  
> jdbc\_driver\_library =\> "/opt/ojdbc7.jar"  
> jdbc\_driver\_class =\> "Java::oracle.jdbc.driver.OracleDriver"  
> statement =\> "SELECT \* FROM V$ACTIVE\_SESSION\_HISTORY WHERE SAMPLE\_TIME \> :sql\_last\_value"  
> last\_run\_metadata\_path =\> "/tmp/logstash-oradb.lastrun"  
> record\_last\_run =\> true  
> schedule =\> "\*/2 \* \* \* \*"  
> }  
> }  
> filter {  
> # Set the timestamp to that of the ASH sample, not current time.  
> mutate { convert =\> ["sample\_time" , "string"]}  
> date { match =\> ["sample\_time", "ISO8601"]}  
> }  
> output {  
> elasticsearch {  
> hosts =\> ["localhost:9200"]  
> manage\_template =\> false  
> index =\> "%{[fields][document\_type]}-%{+YYYY.MM.dd}"  
> }  
> }

Thanks

Fei

---

<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 1, 2017, 10:00pm UTC](https://discuss.elastic.co/t/how-to-identify-jdbc-pipeline/102281/2 "2017-10-01T22:00:57Z")

</div>

Do you mean how can you extract `[fields][document_type]` from the JDBC input?

---

<div class="post-metadata">

### Author: ![feijiangnan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/feijiangnan/32/20893_2.png) [@feijiangnan](https://discuss.elastic.co/u/feijiangnan)
#### Post date: [October 2, 2017, 2:17pm UTC](https://discuss.elastic.co/t/how-to-identify-jdbc-pipeline/102281/3 "2017-10-02T14:17:42Z")

</div>

Hello Mark,

I tried to use same variable/array [fields][document\_type] to identify different pipeline so that I can create according Index name. For instance:  
in filebeat.yml, it is defined as below

> fields:  
> document\_type: appserver-systemout-server1

in logstash configuration file, it is used as below

> ```
> elasticsearch {
> hosts => ["localhost:9200"]
> manage_template => false
> index => "%{[fields][document_type]}-%{+YYYY.MM.dd}"
> }
> 
> ```

I would like to know if I can define something in jdbc pipeline similar to the entries in filebeat.

Thanks and Regards,  
Fei

---

<div class="post-metadata">

### Author: ![Rory](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@Rory](https://discuss.elastic.co/u/Rory)
#### Post date: [October 2, 2017, 3:51pm UTC](https://discuss.elastic.co/t/how-to-identify-jdbc-pipeline/102281/4 "2017-10-02T15:51:34Z")

</div>

You can add a couple of columns in the your select query that have the values you want to index in the fields and document\_type column.

OR

You can use mutate filter in logstash config to add the fields you want....coming from the jdbc input.

---

<div class="post-metadata">

### Author: ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)
#### Post date: [October 3, 2017, 9:39am UTC](https://discuss.elastic.co/t/how-to-identify-jdbc-pipeline/102281/5 "2017-10-03T09:39:36Z")

</div>

No need to add the mutate filter. The JDBC input supports `add_field` and other [common config options](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html#plugins-inputs-jdbc-common-options).

---

<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: [October 31, 2017, 9:40am UTC](https://discuss.elastic.co/t/how-to-identify-jdbc-pipeline/102281/6 "2017-10-31T09:40:06Z")

</div>

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