Splunk Search

not able to get app specific sourcetypes using tags.

ssujin
Explorer

I have created tags in tags.conf inside my splunk app as below.

[index=index1]
app_index = enabled

[index=index2]
app_index = enabled

then i am using search query to get all the sourcetypes from my apps with tags as below

| metadata type=sourcetypes index=* | tags | search tag::index=app_index 

But this query not working.
My understanding is since the value “index1” and “index2” was not there in type field, query got failed.

Is there need any change or alternative in my search query, Kindly help me on this,
Thanks

1 Solution

alacercogitatus
SplunkTrust
SplunkTrust

A very fast way to achieve this is to use tstats. Try this search below:

 |tstats count  by sourcetype index| tags index outputfield=index_tag | where index_tag="app_index"

This will give you a table of sourcetypes within indexes. To further reduce to only sourcetypes, do this complete search:

|tstats count  by sourcetype index | tags index outputfield=index_tag | where index_tag="app_index" | stats sum(count) as total_count by sourcetype

View solution in original post

alacercogitatus
SplunkTrust
SplunkTrust

A very fast way to achieve this is to use tstats. Try this search below:

 |tstats count  by sourcetype index| tags index outputfield=index_tag | where index_tag="app_index"

This will give you a table of sourcetypes within indexes. To further reduce to only sourcetypes, do this complete search:

|tstats count  by sourcetype index | tags index outputfield=index_tag | where index_tag="app_index" | stats sum(count) as total_count by sourcetype

gcusello
SplunkTrust
SplunkTrust

Hi ssujin,
I don't think that it's possible to use tags with | metadata because with this command you haven't all the fields of your events, but only total events, first event, last event and more recent event for each object you choose with your type (sourcetypes, hosts, sources), it's the same thing to run a search with |metasearch.

To show all your tags, you have to run a search

index=* | dedup tag | table tag

Bye.
Giuseppe

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...