Splunk Search

Create a Time Table with multiple 'by' fields

dreeck
Path Finder

I need a table that looks like a chart containing multiple 'by' values.

sample output:

time_bin, farmName, errorCount
12:05      , farmOne   , 7
12:05      , farmTwo   , 6
12:10      ,farmOne    ,8

So far I'm doing this:

index=prod-* sourcetype=fruits msg="ripened*" | 
bin _time span=5m | 
eval error = if(like(sev,"ERROR"),1,null) |
eval warn = if(like(sev,"WARN"),1,null) |
eval info = if(like(sev,"INFO"),1,null) |
eval farm = case(
like(index,"%farm1"),"farmOne",
like(index,"%farm2"),"farmTwo",") |
stats values(farm), count(errors) by _time

This mostly gets me what I want, except I get a multi-value field for farm. So I get

12:05 , farmOne FarmTwo, 13 instead of what I want.

what am I missing?

0 Karma
1 Solution

493669
Super Champion

You can try stats by _time and farm to separate it by _time and with farm name like:

...|stats values(farm), count(errors) by _time farm

if this wont work then try below:

...|makemv farm|mvexpand farm

View solution in original post

493669
Super Champion

You can try stats by _time and farm to separate it by _time and with farm name like:

...|stats values(farm), count(errors) by _time farm

if this wont work then try below:

...|makemv farm|mvexpand farm

dreeck
Path Finder

who knew by would accept two terms separated by a space. Thanks!

0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...