Splunk Search

Why am I unable to remove rows from csv lookup?

userx10j2004
Explorer

Hi Splunk Gurus, 

I am new to lookups and this community has been a great help. I have a few cases where I can't seem to remove rows from a lookup correctly and I can't find a solution for it.

I have a lookup table that is used to list maintenance windows on servers. My CSV lookup has 3 columns CI,  chgreq, mStart, and mstop.

Example: serverA     CHG0001     2023-02-16 00:00     2023-02-17 13:00

I am pulling in emails from an O365 mailbox that allows the adding and clearing of these maintenance windows. Adding new rows to my lookup is working fine but when I try to remove rows I get a blank lookup.

Here is the search I am using:

index="maintenance_emails" Clear Maintenance

| rex field="subject" "Clear Maintenance for (?<server_name>.+)"

| inputlookup append=t maintenance_windows.csv

| where CI!=server_name

| eval CI=server_name, chgreq=chgreq, mStart=mStart, mStop=mStop

| outputlookup maintenance_windows.csv

 

The server_name field has the correct server name in it and it matches with a CI entry in my lookup. When I run the search I get a blank lookup table. I have done some testing and it looks like my where statement is not working.

I appear to also be having the same issue when trying to remove old maintenance window entries from the same table but using values in the mStop column and comparing them to the current date and time. But this may be a separate issue (i.e. with the date/time format or operation).

| eval cur_time=strftime(now(), "%Y-%m-%d %H:%M")

| inputlookup append=t maintenance_windows.csv

| where mStop<=cur_time

| eval CI=server_name, chgreq=chgreq, mStart=mStart, mStop=mStop

| outputlookup maintenance_windows.csv

 

Any help would be very appreciated 🙂

 

Labels (1)
0 Karma
1 Solution

userx10j2004
Explorer

Hi all,

I was not able to get this working so I changed my lookup so that I could use actual values instead of fields 😞

 

View solution in original post

0 Karma

userx10j2004
Explorer

I ran the following test:

| inputlookup maintenance_windows.csv

| where CI!="serverA" 

 

And I get the results from the lookup table. If I try:

| eval server_name="serverA"

| inputlookup maintenance_windows.csv

| where CI!=server_name

 

I don't get any results. Am I missing something?

 

Thanks.

- Jason

 

0 Karma

userx10j2004
Explorer

Hi all,

I was not able to get this working so I changed my lookup so that I could use actual values instead of fields 😞

 

0 Karma
Get Updates on the Splunk Community!

Splunk Observability for AI

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

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk on November 6 at 11AM PT, and empower your SOC to reach new heights! Duration: ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...