Splunk Search

Is it possible to use a field containing a year and another value to create a time chart?

satpaldegun
New Member

Hi

I am not a Splunk expert and wanted to know if I can use a field as my timeline. For example, if I have a year field in my XML extracted together with some value - can I show this on the timechart with the value as my y-axis and year as my x-axis?

0 Karma
1 Solution

gokadroid
Motivator

Let's say you have the year value in field myYear and value you want to timechart in field myValue then you can try to do something like below and see if it works for your case:

your query to return myYear and myValue
| chart count(myValue) over myYear

You can use count, avg, min, max etc. whatever functions are of interest and apply to chart command. You can also | sort myYear OR | sort -myYear as the last line of the above command to achieve desired result of timechart, the way you like.

View solution in original post

0 Karma

gokadroid
Motivator

Let's say you have the year value in field myYear and value you want to timechart in field myValue then you can try to do something like below and see if it works for your case:

your query to return myYear and myValue
| chart count(myValue) over myYear

You can use count, avg, min, max etc. whatever functions are of interest and apply to chart command. You can also | sort myYear OR | sort -myYear as the last line of the above command to achieve desired result of timechart, the way you like.

0 Karma

satpaldegun
New Member

Hi

Thanks for the prompt response.

Can this be used to display multiple fields? So if there 3 data items like Country, Value & Year - can I display the Value for multiple countries over Year using Chart?

Thanks.

0 Karma

gokadroid
Motivator

How do you expect a value of "Country" and "Value" to come in visualization? However if the question is "can one plot multiple series over year", yes you can do as follows:

your query to return myYear and myValue
 | chart count(myValue), min(yourValue), max(everyOnesValue) over myYear
0 Karma

satpaldegun
New Member

Thanks for your suggestions - much appreciated and have now managed to use the following:-
... | chart sum(myValue) over myYear by myCountry

This seems to be working and thanks again.

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...