Reporting

Adding Column to charts based on lookup table

aquinojason
Path Finder

Hi,

How am I able to add the BusinessUnit Column on my splunk query below?  The output 

index=xxxxxxx sourcetype=xxxxxxx | multikv forceheader=1 | dedup ACCOUNT_CODE DATE MVS_SYSTEM_ID CALCMIPS | eval DATE=strftime(strptime(DATE,"%d%b%y"),"%Y-%m-%d") | lookup Account_file.csv ACCOUNT_CODE OUTPUT Application BusinessUnit ApplicationRTO | eval _time=strptime(DATE." "."00:00:00","%Y-%m-%d %H:%M:%S") | table _time Application BusinessUnit MVS_SYSTEM_ID CALCMIPS | chart avg(CALCMIPS) by Application DATE limit=0

Output should look like something below with BusinessUnit after Application.

aquinojason_0-1618399858153.png

Thanks and Regards,

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

 

Chart doesn't pass the column, in fact, it creates a table with two dimensions (Application and DATE in your instance), and one value (your average) for each cell. If you want the BusinessUnit passed through, you need to add it to the x dimension (Application) before the chart command

index=xxxxxxx sourcetype=xxxxxxx | multikv forceheader=1 | dedup ACCOUNT_CODE DATE MVS_SYSTEM_ID CALCMIPS | eval DATE=strftime(strptime(DATE,"%d%b%y"),"%Y-%m-%d") | lookup Account_file.csv ACCOUNT_CODE OUTPUT Application BusinessUnit ApplicationRTO | eval _time=strptime(DATE." "."00:00:00","%Y-%m-%d %H:%M:%S") | table _time Application BusinessUnit MVS_SYSTEM_ID CALCMIPS 
| eval Application=Application." - ".BusinessUnit
| chart avg(CALCMIPS) by Application DATE limit=0

 

0 Karma

aquinojason
Path Finder

Hi,

Thank you for the quick response. Can I use a different function to achieve it? I was hoping I can sort it by Application or by Business Unit.

Thanks and Regards,

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You could split the field after the chart so long as you are not going to then try to visualise it

 

index=xxxxxxx sourcetype=xxxxxxx | multikv forceheader=1 | dedup ACCOUNT_CODE DATE MVS_SYSTEM_ID CALCMIPS | eval DATE=strftime(strptime(DATE,"%d%b%y"),"%Y-%m-%d") | lookup Account_file.csv ACCOUNT_CODE OUTPUT Application BusinessUnit ApplicationRTO | eval _time=strptime(DATE." "."00:00:00","%Y-%m-%d %H:%M:%S") | table _time Application BusinessUnit MVS_SYSTEM_ID CALCMIPS 
| eval Application=Application."|".BusinessUnit
| chart avg(CALCMIPS) by Application DATE limit=0
| eval BusinessUnit=mvindex(split(Application,"|"),1)
| eval Application=mvindex(split(Application,"|"),0)
| fields Application BusinessUnit *

 

aquinojason
Path Finder

Thank you very much!

0 Karma
Get Updates on the Splunk Community!

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...

Announcing the Migration of the Splunk Add-on for Microsoft Azure Inputs to ...

Announcing the Migration of the Splunk Add-on for Microsoft Azure Inputs to Officially Supported Splunk ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI! Discover how Splunk’s agentic AI ...