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
Get Updates on the Splunk Community!

The OpenTelemetry Certified Associate (OTCA) Exam

What’s this OTCA exam? The Linux Foundation offers the OpenTelemetry Certified Associate (OTCA) credential to ...

From Manual to Agentic: Level Up Your SOC at Cisco Live

Welcome to the Era of the Agentic SOC   Are you tired of being a manual alert responder? The security ...

Splunk Classroom Chronicles: Training Tales and Testimonials (Episode 4)

Welcome back to Splunk Classroom Chronicles, our ongoing series where we shine a light on what really happens ...