Getting Data In

How come our regular expression is working in search but not configs?

clintrajaniemi
Explorer

I have a local administrator cataloging script running on local machines (just mine while testing). The message output in Splunk is:

ObjectClass=Group
Name=DOMAIN\AD-SecurityGroup

Now I want to break the Name field down into domain and object name. The following works properly:

index=windows_test sourcetype="Powershell:LocalAdmins" | rex field=Name "(?<domain>[^\\\\]+)\\\\(?<object_name>[^\"]+)"

I now get in addition to the above:

domain=DOMAIN
object_name=AD-SecurityGroup

This is exactly what I want, but when I add it to a field extraction on the search head via a transform, (the only way I could find to parse the specific field) as an unquoted string, it doesn't work. I've removed the 2 extra backslashes from the domain match as well as between the capture groups in case it was only needed in the search box. Still doesn't work.

In between changes, I've done the debug/refresh as well as restarting the splunkd service on the search head.

In case it helps, here is the input where the script is running:

[powershell://LocalAdmins]
script = Get-LocalGroupMember -Group "Administrators" | Select-Object ObjectClass,Name
schedule = 60
sourcetype = PowerShell:LocalAdmins
source = PowerShell
index = windows_test
disabled = false

On the search head here is the transforms.conf and props.conf:

transforms.conf

[PowershellLocalAdmin]
CLEAN_KEYS = 0
REGEX = (?<domain>[^\\\\]+)\\\\(?<object_name>[^\"]+)
SOURCE_KEY = Name

props.conf

[Powershell:LocalAdmins]
REPORT-PowershellLocalAdmins = PowershellLocalAdmin

I'm at a loss right now. I need help in determining if there's something wrong with my regex, or the way I'm using it, in the configurations.

Thank you

Edit:
Thanks to chrisyoungerjds and woodcock who each provided a piece of the puzzle I was missing/misunderstanding. Here's what I ended up doing to fix the issue:

props.conf

[PowerShell:LocalAdmins]
REPORT-PowerShellLocalAdmins = PowerShellLocalAdmins

transforms.conf

[PowerShellLocalAdmins]
CLEAN_KEYS = 0
REGEX = Name=\"(?<domain>[^\\]+)\\(?<object_name>[^\"]+)

It appears that I can select only one answer as accepted even though each provided a missing piece for me which helped me get to the resolution.

0 Karma
1 Solution

chrisyounger
SplunkTrust
SplunkTrust

Hi @clintrajaniemi

If you replace this exact string in the transforms.conf it should work: REGEX = Name=(?<domain>[^\\]+)\\(?<object_name>[^\"]+)

Everything else looks totally correct to me.

All the best

View solution in original post

woodcock
Esteemed Legend

The problem is that your sourcetype values do not match so you have to change one to match the other. Look at the s/S character after Power in these 2 lines:

In your inputs.conf:

sourcetype = PowerShell:LocalAdmins

In your props.conf:

[Powershell:LocalAdmins]

clintrajaniemi
Explorer

That's great. Thank you.

0 Karma

chrisyounger
SplunkTrust
SplunkTrust

Hi @clintrajaniemi

If you replace this exact string in the transforms.conf it should work: REGEX = Name=(?<domain>[^\\]+)\\(?<object_name>[^\"]+)

Everything else looks totally correct to me.

All the best

clintrajaniemi
Explorer

I was able to get this resolved from yours and woodcock's pieces I was missing. Thank you for the help.

0 Karma

clintrajaniemi
Explorer

Thanks for the help, but I'm still not getting the parsed results.

To be clear, in case I've done this incorrectly, I put this in the props/transforms for the search app on the search head. Also, do I need to be doing a full restart of the splunk service after the changes are made or is the /debug/refresh sufficient?

Thank you

0 Karma
Get Updates on the Splunk Community!

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...