Splunk Search

Is there a way to search and list all attributes from a data model?

spammenot66
Contributor

Is there a way to search and list all attributes from a data model in a search? For example if my data model consists of three attributes (host, uri_stem,referrer), is there a way to search the data model and list these three attributes into a search? Ideally, I would like to list these attributes and dynamically display values into a drop-down.

0 Karma
1 Solution

sundareshr
Legend

Try this

| datamodel mydatamodel | spath | rename "objects{}.fields{}.displayName" AS fields | table fields | mvexpand fields

View solution in original post

sundareshr
Legend

Try this

| datamodel mydatamodel | spath | rename "objects{}.fields{}.displayName" AS fields | table fields | mvexpand fields

xoriantkbisht
Explorer

Hi Sundareshr,
When i am running this query, it is not listing the auto extracted fields which i have added. But if i am using pivot, it is showing results in pivot for my added fields. Can you tell me what actions should i take for this ? so that these fields will get added and i can run search query for those 2 fields

0 Karma

spammenot66
Contributor

you rule! this |datamodel command worked wonders for me.

0 Karma

jkat54
SplunkTrust
SplunkTrust

Or this one 😉

0 Karma

jkat54
SplunkTrust
SplunkTrust

The command you're looking for is called pivot:

http://docs.splunk.com/Documentation/Splunk/6.0/SearchReference/Pivot

It's a little difficult to get used to so I recommend reading the documentation but here's a search using an out of the box datamodel

| pivot internal_audit_logs Audit count(Audit) AS "Count of Audit"

And here is another example with split rows (to list the values of each):

| pivot internal_server server count(server) AS "count(server)" SPLITROW host AS host SPLITROW source AS source SPLITROW sourcetype AS sourcetype

0 Karma
Get Updates on the Splunk Community!

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...

Splunk App Dev Community Updates – What’s New and What’s Next

Welcome to your go-to roundup of everything happening in the Splunk App Dev Community! Whether you're building ...

The Latest Cisco Integrations With Splunk Platform!

Join us for an exciting tech talk where we’ll explore the latest integrations in Cisco + Splunk! We’ve ...