I am trying to extract a value and add it to every events of that sourcetype.
source="c:\\splunk monitors\\log(2).txt" | eval ServiceTag = [search source="c:\\splunk monitors\\log(2).txt" | head 1 | rex field=_raw "^[^\[\n]*\[(?P<SvcTag>[^\]]+)" | eval tag = SvcTag | return $tag ]
Here $tag returns 5Q4RZH2 which is a string and thus, it is not able to get stored in ServiceTag variable of eval.
If the tag would have returned some number such as "123" then it is able to store the same.
E.g.
source="c:\\splunk monitors\\log(2).txt" | eval ServiceTag = [search source="c:\\splunk monitors\\log(2).txt" | head 1 | rex field=_raw "^[^\[\n]*\[(?P<SvcTag>[^\]]+)" | eval tag = "123"| return $tag ]
In this scenario, ServiceTag has the value 123
Hence, it is getting difficult to store a string.
Can someone please solve?
... View more