Dashboards & Visualizations

How to pass values from search results into a pie chart?

jgbricker
Contributor

I want to show a pie chart with the percentage values. Here is my search -

index="rp" sourcetype="rp" *PartOfURL*  
| rex "\-\s+(?<Agent>\w{2}\d{4}\w\d{2})\s[^\"]+\"(?<request>GET\s[^\"]+)\"\s(?<status_code>\d{3})\s[^\"]+\"(?<referer>[^\"]+)"  
| lookup quoteLaunchBeta.csv betaAgent AS Agent OUTPUT betaAgent AS BetaAgent  
| where isnotnull(BetaAgent)  
| regex request!="GET\s\/PartOfURL\/[^\/]+\/[^\/]+\/[^\s]+\sHTTP[^\"]+"  
| search (request="GET /PartOfURL/ HTTP/1.1" AND referer="https://www.someplace.com/Pages/default.aspx") OR (request="GET /PartOfURL/g/*" AND referer="*Customer*") 
| stats  count(eval(request!="GET /PartOfURL/ HTTP/1.1")) as ConformCount, count(eval(request="GET /PartOfURL/ HTTP/1.1")) as NotConformCount

I see the output of the different numbers but the Visual isn't working - it is a solid blue circle and is evaluating NotConform%=100

Any help is much appreciated!

Tags (1)
1 Solution

jgbricker
Contributor

Thanks for the tip! Your answer was very close to what I wanted. One of the requests contains a session GUID so it was breaking it out funny when I tested your suggested method.

The search that found what I wanted was

index="my_index" sourcetype="my_index" *PartOfURL*  
| rex "\-\s+(?<Agent>\w{2}\d{4}\w\d{2})\s[^\"]+\"(?<request>GET\s[^\"]+)\"\s(?<status_code>\d{3})\s[^\"]+\"(?<referer>[^\"]+)"  
| lookup quoteLaunchBeta.csv betaAgent AS Agent OUTPUT betaAgent AS BetaAgent 
| where isnotnull(BetaAgent) 
| regex request!="GET\s\/PartOfURL\/[^\/]+\/[^\/]+\/[^\s]+\sHTTP[^\"]+" 
| search (request="GET /PartOfURL/ HTTP/1.1" AND referer="https://www.somewhere.com/Pages/default.aspx") OR (request="GET /PartOfURL/g/*" AND referer="*Customer*") 
| eval ConformValue = case(request!="GET /PartOfURL/ HTTP/1.1", "ConformRequest", request="GET /PartOfURL/ HTTP/1.1", "NotConformRequest") 
| stats count by ConformValue

View solution in original post

jgbricker
Contributor

Thanks for the tip! Your answer was very close to what I wanted. One of the requests contains a session GUID so it was breaking it out funny when I tested your suggested method.

The search that found what I wanted was

index="my_index" sourcetype="my_index" *PartOfURL*  
| rex "\-\s+(?<Agent>\w{2}\d{4}\w\d{2})\s[^\"]+\"(?<request>GET\s[^\"]+)\"\s(?<status_code>\d{3})\s[^\"]+\"(?<referer>[^\"]+)"  
| lookup quoteLaunchBeta.csv betaAgent AS Agent OUTPUT betaAgent AS BetaAgent 
| where isnotnull(BetaAgent) 
| regex request!="GET\s\/PartOfURL\/[^\/]+\/[^\/]+\/[^\s]+\sHTTP[^\"]+" 
| search (request="GET /PartOfURL/ HTTP/1.1" AND referer="https://www.somewhere.com/Pages/default.aspx") OR (request="GET /PartOfURL/g/*" AND referer="*Customer*") 
| eval ConformValue = case(request!="GET /PartOfURL/ HTTP/1.1", "ConformRequest", request="GET /PartOfURL/ HTTP/1.1", "NotConformRequest") 
| stats count by ConformValue

fdi01
Motivator

retried by adding "by request | top request" like the following
because you don t have to calculate the percentage and you veus show how?

index="rp" sourcetype="rp" PartOfURL | rex "-\s+(?\w{2}\d{4}\w\d{2})\s[^\"]+\"(?GET\s[^\"]+)\"\s(?\d{3})\s[^\"]+\"(?[^\"]+)" | lookup quoteLaunchBeta.csv betaAgent AS Agent OUTPUT betaAgent AS BetaAgent | where isnotnull(BetaAgent) | regex request!="GET\s\/PartOfURL\/[^\/]+\/[^\/]+\/[^\s]+\sHTTP[^\"]+" | search (request="GET /PartOfURL/ HTTP/1.1" AND referer="https://www.someplace.com/Pages/default.aspx") OR (request="GET /PartOfURL/g/" AND referer="*Customer") | stats count(eval(request!="GET /PartOfURL/ HTTP/1.1")) as ConformCount, count(eval(request="GET /PartOfURL/ HTTP/1.1")) as NotConformCount by request| top request

and your piechar to display only what you ask him you must calculate the percentage of what you veus Display High front of Display High using eval
see this exple:
index=_internal | head 5 | eval value=1 | eventstats sum(value) as total | streamstats window=0 sum(value) as sumvalue | eval percentage=(sumvalue*100/total) | table value,sumvalue,total,percentage
please forgive my english.

Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...