Splunk Search

How to edit my search to count the number of servers?

lbonnes
Observer

We have Multiple servers that all end with the same few letters like this.

Office1Server
Office2Server
Remot1Server
Remot2Server
Remot3Server

I want to return results that look like this

OfficeServer 10
RemotServer 23

index=stuff* host=*SERVER "Deployed successfully" | cluster t=0.35 field=host

Is that possible and if so, what do I change my search to?

0 Karma

cmerriman
Super Champion

if they all end with "Server", you could adding something like:

|rex field=host mode=sed "/s/\d+Server/Server/" 
0 Karma

rjthibod
Champion

Using cluster is likely going to give you an indeterminate result. Instead, you can create a new field by ripping out the numbers and then get the counts.

Try this.

index=stuff* host=*SERVER "Deployed successfully" 
| eval newhost = replace(host, "(\D+)(\d+)(\D+)","\1\3") 
| stats count by newhost
0 Karma
Get Updates on the Splunk Community!

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

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

🔐 Trust at Every Hop: How mTLS in Splunk Enterprise 10.0 Makes Security Simpler

From Idea to Implementation: Why Splunk Built mTLS into Splunk Enterprise 10.0  mTLS wasn’t just a checkbox ...