Getting Data In

i need to index the source field value into new fields during index time

DataOrg
Builder

please help me in indexing source field value into new fields value during index time.
please help with transform/props.conf
i need to extract the source field only the script name with the new field.

source field value will be /splunk_home/etc/apps/bin/python.py

0 Karma
1 Solution

harsmarvania57
Ultra Champion

Hi,

Please try below config on Indexer/Heavy Forwarder whichever comes first from UF.

props.conf

[yoursourcetype]
TRANSFORMS-sourceextract = get_script_from_source

transforms.conf

[get_script_from_source]
SOURCE_KEY = MetaData:Source
REGEX = ([^\/]+$)
FORMAT = script_name::$1
WRITE_META=true

On Search Head

fields.conf

[script_name]
INDEXED = true

View solution in original post

harsmarvania57
Ultra Champion

Hi,

Please try below config on Indexer/Heavy Forwarder whichever comes first from UF.

props.conf

[yoursourcetype]
TRANSFORMS-sourceextract = get_script_from_source

transforms.conf

[get_script_from_source]
SOURCE_KEY = MetaData:Source
REGEX = ([^\/]+$)
FORMAT = script_name::$1
WRITE_META=true

On Search Head

fields.conf

[script_name]
INDEXED = true

DataOrg
Builder

@harsmarvania57 not working.
error captured at splunkd.log

04-22-2020 10:18:56.823 +0000 ERROR regexExtractionProcessor - REGEX field must be specified tranform_name=route_script_pg_thingworx

0 Karma

harsmarvania57
Ultra Champion

There was typo in transforms.conf configuration, it should be SOURCE_KEY = MetaData:Source , not Metadata:Source. I have updated my answer with correct configuration.

0 Karma

DataOrg
Builder

@harsmarvania57 thanks its worked but it not picking a metadata value.
i want to create a new field with static value(hardcoded value). how to create it ?
script_name = abc.py

0 Karma

harsmarvania57
Ultra Champion

What do you mean by "metadata value" ? You mentioned in your question that you want to create new indexed time field based on source and now you are saying that you want to hardcode the value at index time, I am confused now. Please clarify what you want to achieve.

0 Karma

DataOrg
Builder

i want to create a field with hard-corded script name value during index time itself since i cant use source field it was pointing something,

0 Karma

harsmarvania57
Ultra Champion

Remove above props & transforms config and try below configuration on UF

inputs.conf

[script://path/your_script.py]
_meta = script_name::abc.py
0 Karma

DataOrg
Builder

@harsmarvania57 thanks , it worked

0 Karma

harsmarvania57
Ultra Champion

Welcome ..

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...