All Apps and Add-ons

How to update database table rows with Splunk data?

matstap
Communicator

I want to update a database table with data from Splunk. I need to join on an ID field. So if my data has a row with ID = A and the database table has a row with ID = A, that row should be updated with my new data. If my row has an ID that isn't already in the database table, add the new row.

I've tried dbxoutput, but that seems to only append all the new data without joining on any field. How have others achieved this?

0 Karma
1 Solution

kheo_splunk
Splunk Employee
Splunk Employee

If you want to upsert functionality in a database, "Enable Upsert" should be checked with a proper column name(in your case - ID column) under "Upsert Configuration" section in the 3rd step(Fields Mapping) when creating an database output.

Please check the following Splunk doc.
http://docs.splunk.com/Documentation/DBX/3.1.3/DeployDBX/Createandmanagedatabaseoutputs#Fields_mappi...

I have tested this funtionality using EMPLOYEES table on Oracle database and it worked for me. After configuring the database output using DB Connect UI, $SPLUNK_HOME/etc/apps/splunk_app_db_connect/local/db_outputs.conf shows the following. Please note that EMPLOYEE_ID is configured for unique_key and using_upsert as 1 below:

db_outputs.conf
[EMP]
connection = oracle
customized_mappings = COMMISSION_PCT:COMMISSION_PCT:3,DEPARTMENT_ID:DEPARTMENT_ID:3,EMAIL:EMAIL:12,EMPLOYEE_ID:EMPLOYEE_ID:3,FIRST_NAME:FIRST_NAME:12,JOB_ID:JOB_ID:12,LAST_NAME:LAST_NAME:12,HIRE_DATE:HIRE_DATE:93,PHONE_NUMBER:PHONE_NUMBER:12,SALARY:SALARY:3,MANAGER_ID:MANAGER_ID:3
disabled = 0
is_saved_search = 0
scheduled = 0
search = index=main sourcetype=dbx | search EMPLOYEE_ID=173
table_name = "SPLUNK"."EMPLOYEES"
ui_query_schema = SPLUNK
ui_query_table = EMPLOYEES
unique_key = EMPLOYEE_ID
using_upsert = 1

View solution in original post

0 Karma

kheo_splunk
Splunk Employee
Splunk Employee

If you want to upsert functionality in a database, "Enable Upsert" should be checked with a proper column name(in your case - ID column) under "Upsert Configuration" section in the 3rd step(Fields Mapping) when creating an database output.

Please check the following Splunk doc.
http://docs.splunk.com/Documentation/DBX/3.1.3/DeployDBX/Createandmanagedatabaseoutputs#Fields_mappi...

I have tested this funtionality using EMPLOYEES table on Oracle database and it worked for me. After configuring the database output using DB Connect UI, $SPLUNK_HOME/etc/apps/splunk_app_db_connect/local/db_outputs.conf shows the following. Please note that EMPLOYEE_ID is configured for unique_key and using_upsert as 1 below:

db_outputs.conf
[EMP]
connection = oracle
customized_mappings = COMMISSION_PCT:COMMISSION_PCT:3,DEPARTMENT_ID:DEPARTMENT_ID:3,EMAIL:EMAIL:12,EMPLOYEE_ID:EMPLOYEE_ID:3,FIRST_NAME:FIRST_NAME:12,JOB_ID:JOB_ID:12,LAST_NAME:LAST_NAME:12,HIRE_DATE:HIRE_DATE:93,PHONE_NUMBER:PHONE_NUMBER:12,SALARY:SALARY:3,MANAGER_ID:MANAGER_ID:3
disabled = 0
is_saved_search = 0
scheduled = 0
search = index=main sourcetype=dbx | search EMPLOYEE_ID=173
table_name = "SPLUNK"."EMPLOYEES"
ui_query_schema = SPLUNK
ui_query_table = EMPLOYEES
unique_key = EMPLOYEE_ID
using_upsert = 1

0 Karma

mchang_splunk
Splunk Employee
Splunk Employee

You can have dbxquery to call store procedure to achieve.

http://docs.splunk.com/Documentation/DBX/3.1.3/DeployDBX/Commands#Required_Arguments

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...