Splunk Search

Create a sourcetype to index map

Log_wrangler
Builder

I am exploring an unfamiliar Splunk Enterprise deployment.

Normally I use:

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

to get a quick reference map of sourcetype to index, but it only shows a few indexes.... (4 total)

When I run;

index=* |stats values(sourcetype) by index

I get more (24 total).

When I run:

|metadata type=sourcetypes index=*

I get sourcetypes but not index values in a column

Please advise what I might use to get a comprehensive list of indexes and sourcetypes.
Any explanation for the different results is much appreciated too.

Thank you

Tags (2)
1 Solution

micahkemp
Champion

It's possible you have sourcetypes being changed at search time, which would result in different sourcetypes being indexed than shown at search time. Look in your props.conf for any mention of the rename configuration:

rename = <string>
* Renames [<sourcetype>] as <string> at search time
* With renaming, you can search for the [<sourcetype>] with
  sourcetype=<string>
* To search for the original source type without renaming it, use the
  field _sourcetype.
* Data from a a renamed sourcetype will only use the search-time
  configuration for the target sourcetype. Field extractions
  (REPORTS/EXTRACT) for this stanza sourcetype will be ignored.
* Defaults to empty.

You may try bin/splunk btool props list --debug | grep rename to get a quick "do I see this anywhere" answer.

View solution in original post

0 Karma

micahkemp
Champion

It's possible you have sourcetypes being changed at search time, which would result in different sourcetypes being indexed than shown at search time. Look in your props.conf for any mention of the rename configuration:

rename = <string>
* Renames [<sourcetype>] as <string> at search time
* With renaming, you can search for the [<sourcetype>] with
  sourcetype=<string>
* To search for the original source type without renaming it, use the
  field _sourcetype.
* Data from a a renamed sourcetype will only use the search-time
  configuration for the target sourcetype. Field extractions
  (REPORTS/EXTRACT) for this stanza sourcetype will be ignored.
* Defaults to empty.

You may try bin/splunk btool props list --debug | grep rename to get a quick "do I see this anywhere" answer.

0 Karma

Log_wrangler
Builder

Thank you for the reply. I will check the props.conf when I am granted access.

I can get by with

index=* |stats values(sourcetype) by index

but I forgot how to write the code to count the number sourcetypes per index, (not the events per sourcetype)... any advice is greatly appreciated. I have multiple sourcetypes per index and at least 24 so far.

Thank you

Thank you

0 Karma

Log_wrangler
Builder

I came up with this
index=* |stats values(sourcetype) dc(sourcetype) by index

Please let me know if there is a better way...

to clarify I want to see a count unique sourcetypes per index, for example main has sourcetype A B C D E, so the count would be 5.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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