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.
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
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]
That's great. Thank you.
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
I was able to get this resolved from yours and woodcock's pieces I was missing. Thank you for the help.
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