Splunk Search

Handling spaces in field values

Badger
New Member

Description

How can I produce a URL in an alert email that uses field values, either by in-line results or in the body of the email. When an alert is triggered an email is sent with field dashboard_url. For projects with no spaces in the name, the URL is clickable. If there is a space, the URL contains only up to the space and is broken.

Sample query

 

| makeresults format=json data="[{\"project\":\"projectA - Team A\"},{\"project\":\"projectB\"}]"
| eval dashboard_url="https://internal.com:8000/en-US/app/search/dash?form.q_project=".project.""

 

Result: https://internal.com:8000/en-US/app/search/dash?form.q_project=projectA - Team A

Workarounds attempted

I tried building the dashboard_url in the email body using results.project. The same condition occurs, projects with spaces get a broken link.

Labels (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

URLs with spaces in them must be encoded.  Use the urlencode command available with the Webtools Add-on (https://splunkbase.splunk.com/app/4146).

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

What’s New in Splunk Enterprise 9.4: Tools for Digital Resilience

PLATFORM TECH TALKS What’s New in Splunk Enterprise 9.4: Tools for Digital Resilience Thursday, February 27, ...

Leverage Cisco Talos Threat Intelligence Across Splunk Security Products

Leverage Cisco Talos Threat Intelligence Across Splunk Security Products Wednesday, February 26, ...

Splunk Enterprise Security 8.0.2 Availability: On cloud and On-premise!

A few months ago, we released Splunk Enterprise Security 8.0 for our cloud customers. Today, we are excited to ...