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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...