Splunk Search

How can I display the count of host in the header?

lucien62
New Member

Hello,

First of all I'm a splunk noob, I just got started and i'm learning...
I have a simple search that returns a timestamp for each host:

host       _time
x          2018-03-22 21:50
y          2018-03-22 21:55
z          2018-03-22 22:00

I'd like to display the count of host in the header of table like this:

host(3)    _time
x          2018-03-22 21:50
y          2018-03-22 21:55
z          2018-03-22 22:00

How could I do that?
(Splunk 7)

0 Karma
1 Solution

maciep
Champion

I'm not sure that is very straight-forward in Splunk, so the search may be a bit convoluted. Do you want that count to be unique hosts in the lists? Or should it essentially be a count of rows in the results?

Maybe something like this?

<your search so far>
| eventstats dc(host) as num_hosts
| eval "host ({num_hosts})" = host
| table "host *" _time

View solution in original post

0 Karma

maciep
Champion

I'm not sure that is very straight-forward in Splunk, so the search may be a bit convoluted. Do you want that count to be unique hosts in the lists? Or should it essentially be a count of rows in the results?

Maybe something like this?

<your search so far>
| eventstats dc(host) as num_hosts
| eval "host ({num_hosts})" = host
| table "host *" _time
0 Karma

lucien62
New Member

Thx, it did it !

0 Karma
Get Updates on the Splunk Community!

Automatic Discovery Part 1: What is Automatic Discovery in Splunk Observability Cloud ...

If you’ve ever deployed a new database cluster, spun up a caching layer, or added a load balancer, you know it ...

Real-Time Fraud Detection: How Splunk Dashboards Protect Financial Institutions

Financial fraud isn't slowing down. If anything, it's getting more sophisticated. Account takeovers, credit ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...