Splunk Search

Display time chart grouping by 2 fields

RemyaT
Explorer

I have a Splunk query that helps me to visualize different APIs vs Time as below. Using this query I could see each line graph for each APIs in the given time.

index=sample_index 
|timechart span=1m count by API

  My actual requirement is to get the count by 2 fields (API and Consumer). ie I need a time graph for each API and Consumer combination.

One graph for API1_Consumer1, one for API1_Consumer2, and one for API2_Consumer3 like that. How can I achieve that?

Labels (3)
0 Karma
1 Solution

danspav
SplunkTrust
SplunkTrust

Hi @RemyaT,

If you would like a single line graph with a line for each API/Consumer combo you could do the following:

| fillnull API, Consumer value="(blank)"
| eval API_Consumer = API . " - " . Consumer
| timechart span=1m count by API_Consumer

 
Here we're creating a new field called "API_Consumer" that will simply have the values for the API and Consumer separated by a hyphen: " - "

When the graph is created, you will have 1 line for each unique combo of API and Consumer fields. 

If any API or Consumer are blank, we change them to the value "(blank)" - you can change this or remove it if it's not needed in your case. 

 

If you want a separate graph per API-Consumer pair, you can choose a line graph and use Trellis mode:

danspav_0-1690525521969.png

When you split by API_Consumer, it will create one graph per API-Consumer pair (up to a max of 20 pairs)

 

 

Hope that helps,
Cheers,
Daniel

 

View solution in original post

0 Karma

RemyaT
Explorer

Exactly what I wanted. Thanks bunch Daniel.

0 Karma

danspav
SplunkTrust
SplunkTrust

Hi @RemyaT,

If you would like a single line graph with a line for each API/Consumer combo you could do the following:

| fillnull API, Consumer value="(blank)"
| eval API_Consumer = API . " - " . Consumer
| timechart span=1m count by API_Consumer

 
Here we're creating a new field called "API_Consumer" that will simply have the values for the API and Consumer separated by a hyphen: " - "

When the graph is created, you will have 1 line for each unique combo of API and Consumer fields. 

If any API or Consumer are blank, we change them to the value "(blank)" - you can change this or remove it if it's not needed in your case. 

 

If you want a separate graph per API-Consumer pair, you can choose a line graph and use Trellis mode:

danspav_0-1690525521969.png

When you split by API_Consumer, it will create one graph per API-Consumer pair (up to a max of 20 pairs)

 

 

Hope that helps,
Cheers,
Daniel

 

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

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Enhance Security Operations with Automated Threat Analysis in the Splunk EcosystemAre you leveraging ...

What Is Splunk? Here’s What You Can Do with Splunk

Hey Splunk Community, we know you know Splunk. You likely leverage its unparalleled ability to ingest, index, ...

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...