Splunk Search

Max of Distinct Count

pontorito
Explorer

I am trying to get a distinct count of two concatenated numbers and then get the max of that distinct count over a time period. My current search works up until the last pipe. I can get the distinct count but not the max of the distinct count. Any help is appreciated!

index=x heartbeat AssetType=Linear
|bucket span=1m _time | eval DistinctSession=XDI.AssetID
| timechart span=1m dc(DistinctSession) as ConcurrentSession by DeviceType
| timechart span=1d max(ConcurrentSession) by DeviceType

0 Karma

somesoni2
Revered Legend

Give this a try

index=x heartbeat AssetType=Linear |bucket span=1m _time | eval DistinctSession=XDI.AssetID | timechart span=1m dc(DistinctSession) as ConcurrentSession by DeviceType | timechart span=1d max(*) by *
0 Karma

Ledion_Bitincka
Splunk Employee
Splunk Employee

Can you describe what you want the timechart to look like? I'd guess there will be two series: one showing the distinct count, hourly and another showing the max at the daily granularity?

0 Karma

pontorito
Explorer

I'm trying to distinct count per minute, and then I want the max of those distinct counts per day. Basically I want one number per day - the max value of those per minute counts. A little confusing, I know. 🙂

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

I'd guess the first timechart assigns one column for each value of DeviceType, so the second timechart doesn't find any column named DeviceType. Try this instead:

index=x heartbeat AssetType=Linear | rename XDI.AssetID as  DistinctSession
| bucket span=1m _time | stats dc(DistinctSession) as ConcurrentSession by _time DeviceType
| timechart span=1d max(ConcurrentSession) by DeviceType
0 Karma

martin_mueller
SplunkTrust
SplunkTrust

Do the values look right when you leave off the timechart?

index=x heartbeat AssetType=Linear | rename XDI.AssetID as  DistinctSession
| bucket span=1m _time | stats dc(DistinctSession) as ConcurrentSession by _time DeviceType
0 Karma

pontorito
Explorer

this is close...the DeviceType field is now showing up but I still can't get a max number. For some reason the dc isn't being pulled into the timechart function to compute a max

0 Karma
Get Updates on the Splunk Community!

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...