Splunk Search

Can you list every field an index contains?

learnyboi1
Observer

Greetings,

I have a search that list every index and what sourcetypes are contained within it.

|tstats values(sourcetype) where index=* by index

What I like about it is that I can see each index and a list of all of the sourcetypes specific tot that index. I'm trying to see this same data format by with a column of the indexes and a column of all of the fields that index contains.

I'm working on adding indexes to an app that already list what fields it needs but doesn't know what index they are associated to. So I have something like hash value fields md5 and MD5. They are different because of the source they come from but I need to find the index they live to add it.

I also think it would just be useful for audit purposes so if expected fields can be confirmed at a glance.

Please let me know if you have any questions. Thank you!

Best,

Brian

Labels (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Check out the walklex command.  It will tell you which fields are indexed, as opposed to all the fields in an index.  See https://docs.splunk.com/Documentation/Splunk/9.1.1/SearchReference/Walklex

| walklex type=field index=foo
---
If this reply helps you, Karma would be appreciated.

bowesmana
SplunkTrust
SplunkTrust

There's not really a good way to get fields for an index, but you can do it like this using the output from fieldsummary as a subsearch

index=*
[ search index=*
  | fieldsummary maxvals=1
  | fields field 
  | eval {field}=if(match(field, "_time"), null(), "*")
  | fields - field  
  ]
  | foreach * [ eval fields=mvappend(fields, if(isnotnull('<<FIELD>>'), "<<FIELD>>", null())) ]
  | stats values(fields) as fields by index

It's not particularly efficient, but will give you a idea - the _time check is because search won't like earliest_time="*" in the subsearch output.

 

0 Karma
Get Updates on the Splunk Community!

Earn a $35 Gift Card for Answering our Splunk Admins & App Developer Survey

Survey for Splunk Admins and App Developers is open now! | Earn a $35 gift card!      Hello there,  Splunk ...

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...