Splunk Search

Sorting Question for joins

jgillman
Explorer

I have been trying to sort this and I can not seem to be able to get it.

index=uberagent* sourcetype=uberAgent:System:MachineInventory host=*
| join type=inner host 
   [
      | pivot `uA_DM_System_NetworkConfigInformation` System_NetworkConfigInformation
            values(NetworkConfigIPv4) as "IPv4 address(es)"
             values(SiteName) as SiteName
             splitrow
             _time
             period day
            splitrow
            host
      | fields + host "IPv4 address(es)" City _time SiteName
   ]
| dedup host 
| chart count(HwManufacturer) as total by SiteName HwManufacturer
| sort limit=10 - total

Not sure what I am doing wrong,

Tags (1)
0 Karma

woodcock
Esteemed Legend

It should work if you use | sort 10 -total but if for some reason it does not, you can use | sort 0 -total | head 10.

0 Karma

to4kawa
Ultra Champion

Hi, I have some questions.

1 Are the results of this subsearch correct?

[
       | pivot \`uA_DM_System_NetworkConfigInformation` System_NetworkConfigInformation
             values(NetworkConfigIPv4) as "IPv4 address(es)"
              values(SiteName) as SiteName
              splitrow
              _time
              period day
             splitrow
             host
       | fields + host "IPv4 address(es)" City _time SiteName
    ]

expected result example:

host "IPv4 address(es)" City _time SiteName
host1 10.10.10.10 City1 20191025 12:00:00 Site1
...etc

2 Is there HwManufacturer in this result?

index=uberagent* sourcetype=uberAgent:System:MachineInventory host=*

3 What are the expected results of this query?

| chart count(HwManufacturer) as total by SiteName HwManufacturer

expected result example:

SiteName HwManufacturer1 HwManufacturer2 .....
Site1 10 20 ....
Site2 30 40 ....

is that right?

regards.

0 Karma

aberkow
Builder

If you try it without the limit, i.e. | sort 10 - total, does that work? Taking a quick peek at the docs I don't see any references to the limit parameter https://docs.splunk.com/Documentation/SplunkCloud/7.2.7/SearchReference/Sort#Description

0 Karma

jgillman
Explorer

I tried that and the sort still doesn't work. If I get rid of the limit= it still does only give me 10 but not sorted by the total

0 Karma

aberkow
Builder

I wonder if you can't use sort with chart. If you change chart to stats, does it work then? I don't know if you need chart for some reason, but you're not using the OVER parameter so I'm guessing not.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...