Getting Data In

How to create a field of stats to string for search in eval?

m0rt1f4g0
Explorer

Hi splunkers 

Why when I do the following query if it gives me the correct data

 

Query

| inputlookup append=t mitre_lookup
| foreach TA00*
[
| lookup mitre_tt_lookup technique_id as <<FIELD>> OUTPUT technique_name as <<FIELD>>_technique_name
| eval <<FIELD>>_technique_name=mvindex(<<FIELD>>_technique_name, 0)
]

| eval codes_tech = "T1548, T1134,T1547"
| makemv delim=", " codes_tech
| eval TA0004 = if(mvfind(codes_tech, TA0004) > -1, TA0004." Es aqui", TA0004)

Result:

m0rt1f4g0_0-1691883912014.png

 

But when the data comes from a stats result it doesn't search for the values:

 

Query:

index=notable search_name="Endpoint - KTH*"
|fields technique_mitre
|stats count by technique_mitre
|eval tech_id=technique_mitre
|rex field=tech_id "^(?<codes_tech>[^\.]+)"
|stats count by codes_tech
|makemv delim=", " codes_tech
|mvexpand codes_tech
|stats count by codes_tech
| inputlookup append=t mitre_lookup
| foreach TA00*
[
| lookup mitre_tt_lookup technique_id as <<FIELD>> OUTPUT technique_name as <<FIELD>>_technique_name
| eval <<FIELD>>_technique_name=mvindex(<<FIELD>>_technique_name, 0)
]
| eval codes_tech = codes_tech
| eval TA0004 = if(mvfind(codes_tech, TA0004) > -1, TA0004." Es aqui", TA0004)

Result:

m0rt1f4g0_1-1691884132579.png

I would really appreciate your support

Labels (1)
Tags (2)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

What is it you are trying to do?

Does this help?

|fields technique_mitre
|stats count by technique_mitre
|eval tech_id=technique_mitre
|rex field=tech_id "^(?<codes_tech>[^\.]+)"
|stats count by codes_tech
|makemv delim=", " codes_tech
|mvexpand codes_tech
|stats count by codes_tech
| lookup mitre_tt_lookup technique_id as codes_tech
0 Karma

m0rt1f4g0
Explorer

Hi.

What I am trying to do is the following...

m0rt1f4g0_0-1692251019589.png


I need what I bring in codes_tech to look for it in columns A,B,C, etc and if it finds something that says "Es aqui"

My query is:

index=notable search_name="Endpoint - KTH*"
|fields technique_mitre
|stats count by technique_mitre
|eval tech_id=technique_mitre
|rex field=tech_id "^(?<codes_tech>[^\.]+)"
|stats count by codes_tech
|makemv delim=", " codes_tech
|mvexpand codes_tech
|fields codes_tech

| inputlookup append=t mitre_lookup
| foreach TA00*
[
| lookup mitre_tt_lookup technique_id as <<FIELD>> OUTPUT technique_name as <<FIELD>>_technique_name
| eval <<FIELD>>_technique_name=mvindex(<<FIELD>>_technique_name, 0)
| eval <<FIELD>>=<<FIELD>>_technique_name . " " . <<FIELD>>
|eval <<FIELD>>=split(replace(<<FIELD>>,"\.",".|"),"|")
]

| eval TA0004 = if(mvfind(codes_tech, TA0004) > -1, TA0001." Es aqui", TA0004)

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

So, what do you get when you try my suggestion?

0 Karma

m0rt1f4g0
Explorer

With your suggestion I get the following result:

m0rt1f4g0_0-1692265457960.png


Can I explain my query in parts? Maybe that's how I understand it better

I have two queries if I execute them separately it gives me the following result

Query 1:
index=notable search_name="Endpoint - KTH*"
|fields technique_mitre
|stats count by technique_mitre
|eval tech_id=technique_mitre
|makemv delim=", " tech_id
|mvexpand tech_id
|rex field=tech_id "^(?<codes_tech>[^\.]+)"
|stats count by codes_tech
|table codes_tech

m0rt1f4g0_1-1692265745729.png

 

Query 2:

|inputlookup append=t mitre_lookup
|foreach TA00*
[
| lookup mitre_tt_lookup technique_id as <<FIELD>> OUTPUT technique_name as <<FIELD>>_technique_name
| eval <<FIELD>>_technique_name=mvindex(<<FIELD>>_technique_name, 0)

]

m0rt1f4g0_2-1692265884983.png

What I did was join the two queries and look for each value that codes_tech brings in the columns TA0001, TA0002, TA0003, etc. For that I thought of using an eval, but it doesn't do anything 😞

m0rt1f4g0_3-1692266351271.png

However, something curious happens or I don't know why the following happens...

If I put the values directly in an eval and then separate it by commas if it looks for the values in the lookup, let me show you...

m0rt1f4g0_4-1692266553763.png

I really don't know how to approach the issue 😞

 

 

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

I am still not entirely sure what your expected output should look like

Please can you provide a mock up of what you are trying to achieve.

In the meantime, does this give you what you need?

|fields technique_mitre
|stats count by technique_mitre
|eval tech_id=technique_mitre
|rex field=tech_id "^(?<codes_tech>[^\.]+)"
|stats count by codes_tech
|makemv delim=", " codes_tech
|mvexpand codes_tech
|stats count by codes_tech
| lookup mitre_tt_lookup technique_id as codes_tech
| foreach tactic_id tactic_name technique_name
    [| eval <<FIELD>>=mvindex(<<FIELD>>,part)]
| eval {tactic_id}_tactic_name=tactic_name
| eval {tactic_id}_technique_name=technique_name
| fields - tactic_id tactic_name technique_name
| stats values(*) as * by codes_tech
0 Karma

m0rt1f4g0
Explorer

Hi

I need to do a dashboard in dashboard studio. I already configured some rules and if it triggers any I need to paint it on the dashboard, like this...

m0rt1f4g0_0-1693271697149.png

 




0 Karma
Get Updates on the Splunk Community!

Aligning Observability Costs with Business Value: Practical Strategies

 Join us for an engaging Tech Talk on Aligning Observability Costs with Business Value: Practical ...

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...

Splunk Up Your Game: Why It's Time to Embrace Python 3.9+ and OpenSSL 3.0

Did you know that for Splunk Enterprise 9.4, Python 3.9 is the default interpreter? This shift is not just a ...