Getting Data In

How do I use "cidrmatch" to pull a field from a csv using another field in the csv as the cidr?

Braagi
New Member

Yet another issue with "cidrmatch."
All I can get is DATA="Not working" to populate. I need it to populate with the data from the "extattrs" field. Any ideas?

| tstats count by host
| lookup dnslookup clienthost as host OUTPUT clientip as Source_IP
| lookup dnslookup clientip as Source_IP OUTPUT clienthost as SourceName

|append [|inputlookup ipam_report.csv |fields network, extattrs]
| eval DATA=if(cidrmatch(network, Source_IP), extattrs, "Not working")

| stats
values(host) as host
values(SourceName) as SourceName
values(count) as Counted
values(DATA) as DATA
by Source_IP
|sort - Counted
| table host, Source_IP, SourceName, DATA, Counted
Tags (2)
0 Karma

Braagi
New Member

Edit: This is NOT an answer, it is a work around.

I have since been able to get the data I needed, but only on our instance of Splunk ES...and only on active searches, not scheduled. I think there may be a setting in the background that I am not aware of.

The code that works is :

 | tstats count by host

    | lookup dnslookup clienthost as host OUTPUT clientip as Source_IP
    | lookup dnslookup clientip as Source_IP OUTPUT clienthost as SourceName

    |lookup ipam_report.csv network AS Source_IP OUTPUT network, location, owner, sitecode, vlan

    | stats
    values(host) as host
    values(SourceName) as SourceName
    sum(count) as Counted
    values(network) as network
    values(location) as location
    values(owner) as owner
    values(sitecode) as sitecode
    values(vlan) as vlan
    by Source_IP
    |sort - Counted
    | table host, Source_IP, network, vlan, SourceName, sitecode, location, owner, Counted
0 Karma

mstjohn_splunk
Splunk Employee
Splunk Employee

hi @braagi, I'm glad you figured out a solution to your problem. I converted your comment to an answer so that users could learn from your solution. Would you mind approving it for me? Thanks!

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...