Knowledge Management

How to combine an xyseries output with other aggregate function fields and columns for a certain identifier key

pavanml
Explorer

This is an extension to my other question in https://answers.splunk.com/answers/812982/summary-of-stats-from-multiple-events-for-each-ide.html?mi...

The input and output that I need are in the screenshot below:
alt text

I was able to use xyseries with below command to generate output with identifier and all the Solution and Applied columns for each status. However now I want additional 2 columns for each identifier which is:
* StartDateMin - minimum value of StartDate for all events with a specific identifier
* EndDateMax - maximum value of EndDate for all events with a specific identifier

index = |
| stats count by Identifier, TransactionType, Status
| eval TransactionType = TransactionType." (".Status.")"
| xyseries Identifier, TransactionType, count
| fillnull value=0

How do I embed the new columns StartDateMin and EndDateMax with query modification of above query ?
One option I can think of is to separately generate identifier with startdatemin, end datemin and then again identifier with other columns and then perform a join based on identifier but would involve repetition of lot of conditions two times.

Is there an easy way out while using the above query to do the same ?

Labels (1)
Tags (1)
0 Karma
1 Solution

manjunathmeti
Champion

Hi @pavanml,

Try this:

| makeresults 
| eval _raw="Identifier, TransactionType, Status, StartDate, EndDate
  1234, Solution, Success, 2020-03-14, 2020-03-15
  1234, Solution, Success, 2020-03-16, 2020-03-17
  1234, Applied, Fail, 2020-03-17, 2020-030-18
  4567, Solution, Fail, 2020-03-14, 2020-03-15
  4567, Solution, Excepetion, 2020-03-18, 2020-03-19" 
| multikv forceheader=1 
| eventstats count, min(StartDate) as StartDateMin, max(EndDate) as EndDateMax by Identifier 
| stats count, min(StartDateMin) as StartDateMin, max(EndDateMax) as EndDateMax by Identifier, TransactionType, Status 
| eval TransactionType = TransactionType." (".Status.")", Identifier=mvzip(Identifier, mvzip(StartDateMin, EndDateMax, ","), ",") 
| xyseries Identifier, TransactionType, count 
| fillnull value=0 
| eval split=split(Identifier, ", "), Identifier=mvindex(split, 0), StartDateMin=mvindex(split, 1), EndDateMax=mvindex(split, 2)

View solution in original post

0 Karma

manjunathmeti
Champion

Hi @pavanml,

Try this:

| makeresults 
| eval _raw="Identifier, TransactionType, Status, StartDate, EndDate
  1234, Solution, Success, 2020-03-14, 2020-03-15
  1234, Solution, Success, 2020-03-16, 2020-03-17
  1234, Applied, Fail, 2020-03-17, 2020-030-18
  4567, Solution, Fail, 2020-03-14, 2020-03-15
  4567, Solution, Excepetion, 2020-03-18, 2020-03-19" 
| multikv forceheader=1 
| eventstats count, min(StartDate) as StartDateMin, max(EndDate) as EndDateMax by Identifier 
| stats count, min(StartDateMin) as StartDateMin, max(EndDateMax) as EndDateMax by Identifier, TransactionType, Status 
| eval TransactionType = TransactionType." (".Status.")", Identifier=mvzip(Identifier, mvzip(StartDateMin, EndDateMax, ","), ",") 
| xyseries Identifier, TransactionType, count 
| fillnull value=0 
| eval split=split(Identifier, ", "), Identifier=mvindex(split, 0), StartDateMin=mvindex(split, 1), EndDateMax=mvindex(split, 2)
0 Karma

pavanml
Explorer

That worked perfectly !! Thanks a lot.

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!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...