Splunk Search

How to search the count of a field with multiple values by day?

jjc42
Explorer

Hi,

I'm new to Splunk, so please bear with me. I'm trying to get a count of a field with multiple values by day. As an example, the field is Product_Name. Product_Name can have values such as "iPhone", "iPad", "MacBook" and so on. The number of values is in the hundreds (possibly thousands). I'd like a count of Product_Name by day (for the last 30 days) that I can then export to Excel. The following seemed to get me the closest:

Product_Name="*" | timechart count by Product_Name

This doesn't group the results by day (I tried bucket _time span=1d, but it didn't seem to work). It also doesn't include the full list of values (only about a dozen) and the export option is not available.

The following provides the full list with count, but is not by day:

Product_Name="*" | top limit=10000 Product_Name

Thanks very much for the help!

1 Solution

sideview
SplunkTrust
SplunkTrust

You were really close.

Product_Name="*" | timechart span=1d count by Product_Name

If you have more than 10 product names, after those 10 it'll roll the rest up in an "OTHER" column which you might not want. To remove that "OTHER" column you want this.

Product_Name="*" | timechart span=1d count by Product_Name limit=100

Which technically doesn't remove the possibility of OTHER, it just raises the threshold from 10 to 100.

If you can make the time, it may be worth spending some time with the search manual
http://docs.splunk.com/Documentation/Splunk/6.2.2/Search/Whatsinthismanual

or if it's more your style, the Search Tutorial. http://docs.splunk.com/Documentation/Splunk/6.2.2/SearchTutorial/WelcometotheSearchTutorial

View solution in original post

ngatchasandra
Builder

Hi jjc42,

If i understand your problem, try with this:

 Product_Name="*"| timechart span=1d  count by Product_Name  |mvexpand  Product_Name
0 Karma

jjc42
Explorer

Thanks for your reply. I gave it a try, but I'm not quite sure what "mvexpand" is supposed to do. The results look similar to what I had originally.

0 Karma

sideview
SplunkTrust
SplunkTrust

You were really close.

Product_Name="*" | timechart span=1d count by Product_Name

If you have more than 10 product names, after those 10 it'll roll the rest up in an "OTHER" column which you might not want. To remove that "OTHER" column you want this.

Product_Name="*" | timechart span=1d count by Product_Name limit=100

Which technically doesn't remove the possibility of OTHER, it just raises the threshold from 10 to 100.

If you can make the time, it may be worth spending some time with the search manual
http://docs.splunk.com/Documentation/Splunk/6.2.2/Search/Whatsinthismanual

or if it's more your style, the Search Tutorial. http://docs.splunk.com/Documentation/Splunk/6.2.2/SearchTutorial/WelcometotheSearchTutorial

jjc42
Explorer

That works. Thanks! And thanks for the links. I'll take a look.

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...