# \_source field in jdbc output

**URL:** https://discuss.elastic.co/t/source-field-in-jdbc-output/332583
**Category:** Logstash
**Created:** [May 4, 2023, 4:34pm UTC](https://discuss.elastic.co/t/source-field-in-jdbc-output/332583 "2023-05-04T16:34:26Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Valeriy\_Dzhura](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/valeriy_dzhura/32/118025_2.png) [@Valeriy\_Dzhura](https://discuss.elastic.co/u/Valeriy_Dzhura)
#### Post date: [May 4, 2023, 4:34pm UTC](https://discuss.elastic.co/t/source-field-in-jdbc-output/332583/1 "2023-05-04T16:34:26Z")

</div>

Hello guys,

I'm new in logstash. I have a question how I can return \_source field from elastic input to jdbc output. This is necessary for getting main fields and \_source should be stored like varchar(max)

For example: table looks like this:  
DataTable(id varchar(38), timestamp datetime, source nvarchar(max))

I read a lot of documents but still not have an a picture how I can do this. My pipeline:

```auto
input
{
      elasticsearch {
        hosts => "192.168.9.28:9200"
        index => "index*"
        query => '{"query":{"bool":{"filter":[{"bool":{"should":[{"match":{"API-Action":"APIRequest"}},{"match":{"API-Action":"APIResponse"}}],"minimum_number_should_match":1}},{"range":{"timestamp":{"gte":"now-1m/m","lt":"now/m"}}}]}},"size":10000}'
        docinfo => true
        size => 10000
        scroll => "1m"
	}
}
output {
	jdbc {
		driver_jar_path => '/opt/jdbc/sqljdbc41.jar'
		connection_string => "jdbc:sqlserver://<servername>;databaseName=<databasename>;user=<user>;password=<password>"
		statement => ["INSERT INTO log ([APIAction], [Timestamp], [source]) VALUES(?, ?, ?)", "%{[@metadata][_id]}", "timestamp", "%{[@metadata][_source]}"]
        codec => json
	}
}

```

Could some one please describe where I'm wrong? Or how ww can do this? Also I read about "target" option for elastic input plugin but there are says that I can't use it on output

---

<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 1, 2023, 4:35pm UTC](https://discuss.elastic.co/t/source-field-in-jdbc-output/332583/2 "2023-06-01T16:35:23Z")

</div>

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