Splunk Search

need to create separate field which will show rank based on event Count

shivareddysompa
Explorer

ComputerName Events Rank

    ABC     100        1
    BCD 200        2
    CDE     300        3

i need to create Rank by Events

Tags (1)
0 Karma

shivareddysompa
Explorer

my intention is highest number of event has to hold 1 rank then following and if events are same then rank should be same

0 Karma

shivareddysompa
Explorer

anyone is there to help on above request?

0 Karma

493669
Super Champion

@shivareddysompalle,
Use first sort then streamstats command to calculate rank-

...|sort Events| streamstats count AS Rank

Below is using sample data-

|makeresults|eval ComputerName ="abc", Events ="200"
|append[|makeresults|eval ComputerName ="bcd", Events ="100"]
|append[|makeresults|eval ComputerName ="def", Events ="300"]|sort Events| streamstats count AS Rank
0 Karma

493669
Super Champion

@shivareddysompalle,
Try below-

|makeresults|eval ComputerName ="abc", Events ="200"
  |append[|makeresults|eval ComputerName ="bcd", Events ="100"]
   |append[|makeresults|eval ComputerName ="fcd", Events ="200"]
  |append[|makeresults|eval ComputerName ="def", Events ="300"]|sort - Events | streamstats current=f window=1 values(Events) as prev | eval Rank_filled=if(prev=Events,0,1) | accum Rank_filled
0 Karma

shivareddysompa
Explorer

used same but not worked .
i can't share my query since it is organisational data .

0 Karma

493669
Super Champion

Can you share some sample data and your query by masking confidential data.
since as per your data from question it should work.

0 Karma

shivareddysompa
Explorer
    COmputerName  Countofissues
    ABC     10
    BCD     22
    DCE     32  

my query is like
eventstats dc(Computername) as Countofissues by Computername

i need to assign rank based on Countofisues . Countofissues will change dynamically by time

0 Karma

493669
Super Champion

Try below without using above eventstats command-

...|table ComputerName Countofissues|sort - Countofissues | streamstats current=f window=1 values(Countofissues) as prev | eval Rank=if(prev=Countofissues,0,1) | accum Rank|table ComputerName Countofissues Rank
0 Karma

shivareddysompa
Explorer

how i will get Count of issues without eventstats ?
if i use stats no issues are found

0 Karma

493669
Super Champion

use-

stats count as Countofissues by ComputerName
0 Karma

shivareddysompa
Explorer

even i have applied rank is same like 1 2 3

0 Karma

shivareddysompa
Explorer

my query is below:

index="abc" source="bcd"
|eval ComputerName=upper(ComputerName)
|join ComputerName
[|savedsearch Computers_By_Product productName="DELL"]
| eval title = replace(title,"{","")
| eval title = replace(title,"}","")
| rename title as signature
| join type=left signature
[search index="abc" source="dce" earliest=1 latest=now() | stats dc(id) as IDs by signature]
| eventstats dc(DateTime) as issueCount by ComputerName
| eventstats dc(ID) as fixCount by ComputerName
|sort issueCount |streamstats current=f window=1 values(issueCount) as Prev|eval Rank_filled=if(prev=Events,0,1) | accum Rank_filled|table ComputerName issueCount Rank_filled

0 Karma

493669
Super Champion

Try below-

index="abc" source="bcd"
|eval ComputerName=upper(ComputerName)
|join ComputerName
[|savedsearch Computers_By_Product productName="DELL"]
| eval title = replace(title,"{","")
| eval title = replace(title,"}","")
| rename title as signature
| join type=left signature
[search index="abc" source="dce" earliest=1 latest=now() | stats dc(id) as IDs by signature]
| eventstats dc(DateTime) as issueCount by ComputerName
| eventstats dc(ID) as fixCount by ComputerName
|sort 0 - issueCount |streamstats current=f window=1 values(issueCount) as Prev|eval Rank_filled=if(prev=issueCount,0,1) | accum Rank_filled|table ComputerName issueCount Rank_filled
0 Karma

shivareddysompa
Explorer

got results like

issueCount Rank
2 1
2 2
1 3
1 4

need the rank like
issueCount Rank
2 1
2 1
1 2
1 2

0 Karma

shivareddysompa
Explorer

@woodcock

please help on this

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 ...