Splunk Search

stacked bar chart with my data- is it possible?

mjm295
Path Finder

Hi

I have a search which gives data similar to:

Name,   X1,  X2,  Y1,   Y2,  Z1,  Z3
name1,  A,      ,  A ,   ,   A,
name2,  A,      ,    ,   ,   A,
name3,  A,      ,  A ,   ,    ,   A
name4,    ,    A,  A ,   ,   A,
name5,  A,      ,  A ,   ,    ,
name6,  A,      ,  A ,   ,   A,
name7,  A,      ,  A ,   ,    ,   A      

I am trying to create a stacked bar chart with 3 columns X,Y and Z
With:
column X made up from the total of X1 plus X2 (eg 6+1)
column Y made up from the total of Y1 plus Y2 (eg 6+0)
column Z made up from the total of Z1 plus Z2 (eg 4+2)

The end of my search currently has:
| table name X1 X2 Y1 Y2 Z1 Z2

Thanks
Mark

0 Karma

DMohn
Motivator

This is for sure not the prettiest solution, but it still serves the case, and it might lead to a suitable result 🙂

I have created an input using your fields in a CSV, so the fields names in the data are as per your example.

<your base search> 
| stats count(X*) as SumX*, count(Y*) as SumY*, count(Z*) as SumZ* 
| transpose 10 column_name=col 
| eval colName=case(match(col,"X"),"X",match(col,"Y"),"Y",match(col,"Z"),"Z") 
| chart sum("row 1") over colName by col

example

You need to adjust the value for transpose 10 to the maximum number of fields (X*,Y*,Z*) your data contains.

mjm295
Path Finder

Thanks, managed to make that work.

0 Karma
Get Updates on the Splunk Community!

New in Observability - Improvements to Custom Metrics SLOs, Log Observer Connect & ...

The latest enhancements to the Splunk observability portfolio deliver improved SLO management accuracy, better ...

Improve Data Pipelines Using Splunk Data Management

  Register Now   This Tech Talk will explore the pipeline management offerings Edge Processor and Ingest ...

3-2-1 Go! How Fast Can You Debug Microservices with Observability Cloud?

Register Join this Tech Talk to learn how unique features like Service Centric Views, Tag Spotlight, and ...