Splunk Search

dbquery show database name in results

Lazarix
Communicator

When using the DB connector, is it possible to show either the hostname or a fixed string alongside the query results?
The reason is, I have a dbquery which uses |append that talks to multiple databases to show the results in one table.
It queries 7 hosts and pulls out some information from the same database name in each host, but when it finds a result, I am not sure which host it has found the information in.

Example:

| dbquery "NPS-01"  "select * from _v_dslice where DS_STATUS='Healthy' order by ds_id" | append [| dbquery "NPS-03"  "select * from _v_dslice where DS_STATUS='Healthy' order by ds_id"]

It will show both results in one table, which is great but I would be happy with an additional column that shows the hostname alongside each query result.
I would be fine with reporting a hard coded string along with each query if that would solve it.

ilink_splunk
Splunk Employee
Splunk Employee

Depending upon what database you're using, you could use SQL to fetch the database name. Then you could use the union SQL command to append it in a column. I don't think this would be possible using the splunk search language, unless you wanted to hardcode it.

linu1988
Champion

does your dbquery return any records? eval should be placed after your parent query.

0 Karma

Lazarix
Communicator

Unfortunately that doesn't return any results 😕

0 Karma

linu1988
Champion

...|eval dbconnector=xxx|fields + dbconnector
|stats count by dbconnector

0 Karma

Lazarix
Communicator

Unknown search command 'field'

0 Karma

linu1988
Champion

yes you can, |eval dbconnector=xxx|field + dbconnector

|stats count by dbconnector

0 Karma

Lazarix
Communicator

Well, it isn't necessarily the database name that I'd want to show per-se, I'd either show the name of the connector that I'm calling (I.E. NPS-01) or hard code a string to show "server-01" or whatever.

For example, in splunk graphing, it's possible to add a dummy static value to appear on a chart by doing an eval.

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...