Hello,I have this type of data, and I'd like to extract the following fields with a rex command: Two words: Don't. The data you show is clearly a fragment from a JSON object. Do not treat structured data such as JSON as text because the developer can change format at any time without changing syntax and render your rex useless. Splunk has robust, QA-tested commands like spath. Follow @ITWhisperer's advice to share valid, raw JSON data. (Anonymize as needed.) If your raw data is a mix of free text and JSON, show examples of how they are mixed so we can extract the valid JSON, then handle JSON in spath or fromjson (9.0+) Specific questions: I have a strong suspicion that your data illustration is not a faithful representation of raw data. Because it contains lots of parentheses "(", ")", instead of curly brackets "{" and "}" as in compliant JSON. It is almost impossible for a developer to make this kind of mistake to mix parentheses and curly brackets randomly. Can you verify and clarify? If your raw event is pure JSON, your highlighted snippets should have already been extracted by Splunk as multivalued data{}.from, data{}.to, data{}.intensity.forecast. Do you not get those? Alternatively, is that illustrated data from a field that is already extracted (but misrepresented with mixed parentheses and curly brackets)? Lastly, in a common logging practice is to append JSON data at the end, following some other informational strings that do not contain opening curly bracket. If this is the case, you can easily extract that JSON part with the following and handle it robustly with spath: | rex "^[^{]*(?<json_data>.+)"
| spath input=json_data path=data{}
| mvexpand data{}
| spath input=data{} After this, your highlighted values would be in fields from, to, and intensity.forecast, respectively.
... View more