Splunk Search

Can DB Connect Run Multiple Queries At Once?

proitllc
New Member

I'm trying to run a few complex queries in order to render a single output using DB Connect.

I cannot seem to get them all to run together on one line as if I were at the mysql console.

Query Example (won't go into detail, just the basic structure):

DROP....DROP....DROP....SELECT ... FROM ... WHERE... GROUP...;
CREATE TEMPORARY TABLE.....;
INSERT INTO... SELECT... INNER JOIN... LEFT JOIN...;
INSERT INTO... SELECT... INNER JOIN... LEFT JOIN...;
INSERT INTO... SELECT... INNER JOIN... LEFT JOIN...;
CREATE TEMPORARY TABLE.....;
DROP TABLE...;
DROP TABLE...;
SELECT....;

So we have 9 statements here, the total number and the structure of each doesn't really matter because they work just fine individually, just not together as one big query. They produce the desired output in the mysql console and through several other methods.

Can Splunk DB Connect execute multiple queries as one?

Tags (1)
0 Karma

dwaddle
SplunkTrust
SplunkTrust

This looks like a good job for a stored procedure to me. That is, of course, if DB connect can call a stored procedure. Let the procedure encapsulate the logic above.

0 Karma

jcoates_splunk
Splunk Employee
Splunk Employee

it can run stored procedures if you can call them from SQL. IOW, dbquery my_database "execute my_stored_procedure" works.

0 Karma

BP9906
Builder

Im going to try it with the map command. You can probably use an inputlookup with map command to accomplish what you want.

0 Karma

lukejadamec
Super Champion

Have you tried creating the query at the database and naming it, and then querying the name from DB Connect?

I know it is an extra step, but that is how we worked around it.

jcoates_splunk
Splunk Employee
Splunk Employee

that's my advice as well -- something really long and complex should be written with native syntax highlighting and without worrying about escaping special characters.

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...