# Jdbc streaming renaming fields

**URL:** <https://discuss.elastic.co/t/jdbc-streaming-renaming-fields/186263>\
**Category:** Logstash\
**Created:** [June 18, 2019, 1:35pm UTC](https://discuss.elastic.co/t/jdbc-streaming-renaming-fields/186263 "2019-06-18T13:35:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonathan01](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@jonathan01](https://discuss.elastic.co/u/jonathan01)\
**Post date:** [June 18, 2019, 1:35pm UTC](https://discuss.elastic.co/t/jdbc-streaming-renaming-fields/186263/1 "2019-06-18T13:35:24Z")

</div>

I am using the jdbc streaming plugin and want to take the results and put them into new fields.  
Below is the code that I am using

jdbc\_streaming {  
jdbc\_driver\_library =\> "C:\logstash-7.0.0\bin\sqljdbc42.jar"  
jdbc\_driver\_class =\> "com.microsoft.sqlserver.jdbc.SQLServerDriver"  
jdbc\_connection\_string =\> "jdbc:sqlserver://ltgsql.database.windows.net;databaseName=RHA;user=jgillman;password=%qkafn12=123;"  
jdbc\_user =\> "jgillman"  
jdbc\_password =\> "%qkafn12=123"  
parameters =\> { "code" =\> "[agent][hostname]"}  
statement =\> "select SiteName,Latitude,Longitude,HostedMachineName FROM Session\_Key WHERE HostedMachineName like lower(:code)"  
target =\> "site\_data"  
add\_field =\> { "SiteName" =\> "[sitename]" }  
}

I have also used  
add\_field =\> { "SiteName" =\> "[site\_data][sitename]" }  
add\_field =\> { "SiteName" =\> "%{[site\_data][sitename]}" }  
mutate =\> {add\_field =\> { "SiteName" =\> "%{[site\_data][sitename]}" }}

and none of them work the output is

"site\_data" : [  
{  
"latitude" : "this",  
"hostedmachinename" : "rha-mgr-srv01",  
"longitude" : "this",  
"sitename" : "this"  
}  
],  
"SiteName" : "[sitename]",

Not sure what I am doing wrong. Can anyone please help  
thanks

---

<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:** [June 18, 2019, 1:40pm UTC](https://discuss.elastic.co/t/jdbc-streaming-renaming-fields/186263/2 "2019-06-18T13:40:05Z")

</div>

site\_data is an array. Does %{[site\_data][0][sitename]} work?

---

<div class="post-metadata">

**Author:** ![jonathan01](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@jonathan01](https://discuss.elastic.co/u/jonathan01)\
**Post date:** [June 18, 2019, 2:04pm UTC](https://discuss.elastic.co/t/jdbc-streaming-renaming-fields/186263/3 "2019-06-18T14:04:40Z")

</div>

Thank you so much that worked. I am still new to this so thanks for the quick response and help

---

<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 16, 2019, 2:04pm UTC](https://discuss.elastic.co/t/jdbc-streaming-renaming-fields/186263/4 "2019-07-16T14:04:56Z")

</div>

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