Splunk Search

splunk dbconnect query issue

bhavye20
New Member

Hi

I m working on monitoring some mysql and mssql databases. All I need is a list of tables with number of rows in each one of them. I fired a database query in the database itself for the same purpose and it worked fine. When I fire the same query in splunk it shows syntactical errors.

show table status where name like 'smpp_queue%' or name like 'smppmessagedetailstemp%' and rows > 10

The above query doesnt work.

Please help.

Tags (3)
0 Karma

aelliott
Motivator

Try this:
SELECT table_name as name, table_rows as rows FROM information_schema.tables
where table_name like 'smpp_queue%' or table_name like 'smppmessagedetailstemp%' and table_rows > 10

0 Karma

richgalloway
SplunkTrust
SplunkTrust

That works for me except I had to use table_name and table_rows in the where clause.

---
If this reply helps you, Karma would be appreciated.
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Is there anything in your dbx.log file?

---
If this reply helps you, Karma would be appreciated.
0 Karma

MuS
Legend

Hi bhavye20,

did you enter this directly in the Splunk search field? If so, this will not work this way.
If you want to query a DB with sql you need to do it like this:

| dbquery "YourSQLDataBaseConnectionNameYouHaveConfiguredInDBConnect" "show table status where name like 'smpp_queue%' or name like 'smppmessagedetailstemp%' and rows > 10" 

For more information please take a look at the docs of DBX commands

hope this helps ...

cheers, MuS

Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...