Splunk Search

metadata vs stats count

sloshburch
Splunk Employee
Splunk Employee

When running | metadata index=myindex type=sources, I see 301785788 for my totalCount for one of my sources (let's call it source1).

When running index=myindex source=source1 | stats count, I see 219717265 for my count.

Both searches are run for April 1st, 2014 (not today).

Why does metadata provide a different totalCount than stats count of the same sourcetype and index over the same historical time period on the same search head?

Running splunk 6.0.3.

Tags (2)
0 Karma
1 Solution

somesoni2
Revered Legend

The metadata search command is not time bound. As per documentation for metadata search command:-

The metadata command returns data about a specified index or distributed search peer. It returns information such as a list of the hosts, sources, or source types accumulated over time and when the first, last, and most recent event was seen for each value of the specified metadata type. ****It does not provide a snapshot of an index over a specific timeframe (such as last 7 days).****

So what | metadata index=myindex type=sources is showing, is for all time (always) and what index=myindex source=source1 | stats count is showing is just for your time period (April 1st, 2014), hence the difference.

View solution in original post

somesoni2
Revered Legend

The metadata search command is not time bound. As per documentation for metadata search command:-

The metadata command returns data about a specified index or distributed search peer. It returns information such as a list of the hosts, sources, or source types accumulated over time and when the first, last, and most recent event was seen for each value of the specified metadata type. ****It does not provide a snapshot of an index over a specific timeframe (such as last 7 days).****

So what | metadata index=myindex type=sources is showing, is for all time (always) and what index=myindex source=source1 | stats count is showing is just for your time period (April 1st, 2014), hence the difference.

sloshburch
Splunk Employee
Splunk Employee

Oh interesting. I clearly misunderstood the use of the time bounds on the search. Thanks for clarifying!

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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

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