Splunk Search

Make sure Value from one specific event is not in any other events

splunk219783
Path Finder

I can't wrap my head around how to do this search.  It's like I need an array or variable.

Example Data:

HostnameStorage
BackupServerBackupStorage
Database1Storage1
Database2Storage2
Database3BackupStorage

 

How can I say, show me a list of all servers using BackupServer[Storage], I dont know the name of backup storage in advance. All I know is the hostname is like Backupserver.

 

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Do you mean something like this?

| eventstats values(Hostname) as hosts by Storage
| where isnotnull(mvfind(hosts,"BackupServer"))

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Do you mean something like this?

| eventstats values(Hostname) as hosts by Storage
| where isnotnull(mvfind(hosts,"BackupServer"))
0 Karma

splunk219783
Path Finder

When I try that I just get my BackupServer.  I shouldn't clarified, i'd like a search that only Shows me Database3 in the example dataset, but without knowing the Storage is "BackupStorage" to begin with.  I need to lookup the datastore of backupserver, then make sure none of the others are on there.

0 Karma

PickleRick
SplunkTrust
SplunkTrust
<your search>
| stats values(Hostname) as Hostname by Storage
| where Hostname="BackupServer"

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

I am not sure I understand your requirement - do you know the name of the BackupServer or not?

| eventstats values(Hostname) as hosts by Storage
| where isnotnull(mvfind(hosts,"BackupServer")) AND Hostname!="BackupServer"

If not, how do you identify which host is being used for backup storage?

0 Karma

splunk219783
Path Finder

I apologize if I'm being confusing. Let me try to explain it better.   This backup server backups databases.  I need to make sure none of the databases are on the same storage as the backup server.  Because if we lost that storage we would lose both our backups and the database.

Here's the steps i'm trying to do with SPL.

1. Lookup what storage BackupServer is using with a search.  Something like a 

index=servers server=backups | fields Storage

2. Make sure No Databases are using that Storage.  I do not know which storage the backup server will be on, it could move around.

index=servers server=*Database* storage!=[Storagestringfromabove]

 

This is the search i've thrown together so far.  The only way I can think of to accomplish 1 & 2, is to output my backup storage to a lookup table, then look for a match.

index=servers source=*vmdk* VM=*database*| fields Datastore VM
| search [inputlookup backup_server.csv | fields Datastore]
| table VM Datastore 
0 Karma

yuanliu
SplunkTrust
SplunkTrust

Based on your illustrations 1 and 2, I think ITWhisperer's method should work, like this:

index=servers (server=backups OR server=*Database*)
| eventstats values(server) as servergroup by Storage
| where isnull(mvfind(servergroup, backups))

Basically, eventstats groups servers based on Storage they use; mvfind() selects those servers that uses the same Storage as used by "backups".  Then, isnull() negates the find to pick out those that do not use that storage.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

This line creates a list of all the host which share the same storage by storage name

| eventstats values(Hostname) as hosts by Storage

This line picks out the hosts which share the same storage as BackupServer

| where isnotnull(mvfind(hosts,"BackupServer")) AND Hostname!="BackupServer"

 How is that not what you have asked for?

0 Karma

splunk219783
Path Finder

Apologies for the delayed response, I was out of the office for a few days.  Your example does work, thank you! I must've had a typo or something initially.

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...