Splunk Search

timechart question

dbautist
Explorer

In the timechart docs, the following example was provided:

sourcetype=access_* | timechart count(eval(method="GET")) AS GET, count(eval(method="POST")) AS POST

What if I want to calculate the GetPercentage such that

eval GetPercentage=(GET/(GET+SUCCESS) * 100)

and have that displayed in the timechart? The result should be something like:

_time GetPercentage
1/6/2013 34.5
1/7/2013 22.5

Tags (2)
0 Karma

Ayn
Legend

You can do this by adding your eval after the timechart command.

sourcetype=access_* | timechart count(eval(method="GET")) AS GET, count(eval(method="POST")) AS POST | eval GetPercentage=(GET/(GET+SUCCESS) * 100)

dbautist
Explorer

Thanks! I also want to get a timechart of the GetPercentage by API. I don't want the GET or POST to show because I want to later create a line chart with just the GetPercentage by API. I started with the following but I can't insert the 'by API' in the eval clause:

sourcetype=access_* | timechart count(eval(method="GET")) AS GET, count(eval(method="POST")) AS POST | eval GetPercentage=(GET/(GET+SUCCESS) * 100) | fields - GET, POST

Expected output is something like:
_time getCustomerName(GetPercentage) getCustomerAge(GetPercentage)
1/6/2013 34.5 22.9
1/7/2013 22.5 33.7

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Introduction to Splunk AI

How are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. Lucky for ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Maximizing the Value of Splunk ES 8.x

Splunk Enterprise Security (ES) continues to be a leader in the Gartner Magic Quadrant, reflecting its pivotal ...