Splunk Search

Drilldown option is not working for Custom Search

Trex1
Explorer

Hi there, 

I am trying to enable drilldown on a dashboard view to use a custom search(see below search string snippet). Although the search with the aforementioned string works fine on its own but its complaining when I use it within the drilldown custom search saying "Unbalanced quotes". Any idea why ? Thanks.

Trex1_1-1651899998670.png

 

 

Trex1_0-1651899968118.png

 

Labels (2)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

You have some non-encoded parts of the query in that URL - not sure how they are there, but for example

<link target="_blank">search?q=$env$%20%22TechnicalWorkFlow.spkFormSubmissionGlobalOptIn%22%20AND%20%22Opt%20In%20Response%20%3Cresult%20success=%5C%22false%5C%22%22%0A%7Crex%20field=_raw%20%22%5E%5B%5E%5C%5D%5Cn%5D*%5C%5D%5Cs+%5Cw+%5Cs+%5Cw+%5Cs+%5Cd+%5Cs+%5Cw+%5Cs+(?P%3CUUID%3E%5Cw+)%22%0A%7Cdedup%20UUID%0A%7Ctable%20UUID%20_time&amp;earliest=$field1.earliest$&amp;latest=$field1.latest$</link>

Those contain the following characters that are not encoded (=+?)

The line should be

          <link target="_blank">search?q=$env$%20%22TechnicalWorkFlow.spkFormSubmissionGlobalOptIn%22%20AND%20%22Opt%20In%20Response%20%3Cresult%20success%3D%5C%22false%5C%22%22%0A%7Crex%20field%3D_raw%20%22%5E%5B%5E%5C%5D%5Cn%5D*%5C%5D%5Cs%2B%5Cw%2B%5Cs%2B%5Cw%2B%5Cs%2B%5Cd%2B%5Cs%2B%5Cw%2B%5Cs%2B(%3FP%3CUUID%3E%5Cw%2B)%22%0A%7Cdedup%20UUID%0A%7Ctable%20UUID%20_time&amp;earliest=$field1.earliest$&amp;latest=$field1.latest$</link>

Note the encoding of = (%3D), + (%2B) and ? (%3F)

View solution in original post

0 Karma

bowesmana
SplunkTrust
SplunkTrust

Edit your dashboard in Source mode, so you can see your XML.

Please post your link target string for the drilldown. It should be something like this (this is not exactly the same as yours

        <drilldown>
          <link target="_blank">search?q=index%3D_audit%20%0A%7C%20rex%20field%3D_raw%20%22%5E%5B%5E%5C%5C%5D%5C%5Cn%5D*%5C%5C%5D%5C%5Cs%2B%5C%5Cw%2B%5C%5Cs%2B%5C%5Cw%2B%5C%5Cs%2B%5C%5Cd%2B%5C%5Cs%2B%5C%5Cw%2B%5C%5Cs%2B(%3FP%3CUUID%3E%5C%5Cw%2B)%22&amp;earliest=-15m&amp;latest=now</link>
        </drilldown>

It is most likely that some encoding issue with editing the link in the UI or the source is causing the issue, as you can see that the search string is truncated before the end

 

0 Karma

Trex1
Explorer

@bowesmana here it is 🙂

<drilldown>
<link target="_blank">search?q=$env$%20%22TechnicalWorkFlow.spkFormSubmissionGlobalOptIn%22%20AND%20%22Opt%20In%20Response%20%3Cresult%20success=%5C%22false%5C%22%22%0A%7Crex%20field=_raw%20%22%5E%5B%5E%5C%5D%5Cn%5D*%5C%5D%5Cs+%5Cw+%5Cs+%5Cw+%5Cs+%5Cd+%5Cs+%5Cw+%5Cs+(?P%3CUUID%3E%5Cw+)%22%0A%7Cdedup%20UUID%0A%7Ctable%20UUID%20_time&amp;earliest=$field1.earliest$&amp;latest=$field1.latest$</link>
</drilldown>

0 Karma

bowesmana
SplunkTrust
SplunkTrust

You have some non-encoded parts of the query in that URL - not sure how they are there, but for example

<link target="_blank">search?q=$env$%20%22TechnicalWorkFlow.spkFormSubmissionGlobalOptIn%22%20AND%20%22Opt%20In%20Response%20%3Cresult%20success=%5C%22false%5C%22%22%0A%7Crex%20field=_raw%20%22%5E%5B%5E%5C%5D%5Cn%5D*%5C%5D%5Cs+%5Cw+%5Cs+%5Cw+%5Cs+%5Cd+%5Cs+%5Cw+%5Cs+(?P%3CUUID%3E%5Cw+)%22%0A%7Cdedup%20UUID%0A%7Ctable%20UUID%20_time&amp;earliest=$field1.earliest$&amp;latest=$field1.latest$</link>

Those contain the following characters that are not encoded (=+?)

The line should be

          <link target="_blank">search?q=$env$%20%22TechnicalWorkFlow.spkFormSubmissionGlobalOptIn%22%20AND%20%22Opt%20In%20Response%20%3Cresult%20success%3D%5C%22false%5C%22%22%0A%7Crex%20field%3D_raw%20%22%5E%5B%5E%5C%5D%5Cn%5D*%5C%5D%5Cs%2B%5Cw%2B%5Cs%2B%5Cw%2B%5Cs%2B%5Cd%2B%5Cs%2B%5Cw%2B%5Cs%2B(%3FP%3CUUID%3E%5Cw%2B)%22%0A%7Cdedup%20UUID%0A%7Ctable%20UUID%20_time&amp;earliest=$field1.earliest$&amp;latest=$field1.latest$</link>

Note the encoding of = (%3D), + (%2B) and ? (%3F)

0 Karma

Trex1
Explorer

@bowesmana Thanks heaps, that worked like a charm! However keen to know if you used a particular tool for the encoding as it appears each time I modify the custom search string in the drilldown option, it messes up the encoding ??

0 Karma

bowesmana
SplunkTrust
SplunkTrust

That's odd - I am using Splunk 8.2.6 for that example and I have edited the drilldown search in the UI and it correctly encodes the link - I checked the source view of the link.

I have added extra equals signs. extra rex statements with additional var extraction and can't make it fail.

 

0 Karma

VatsalJagani
SplunkTrust
SplunkTrust

I've personally experienced this in the past. Though don't remember any recent scenario of incorrectly encoded search string.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You could search for URL encoder/decoders on the internet, however, be warned that they may encode/decode $/%24 which would disrupt your token usage if not corrected.

VatsalJagani
SplunkTrust
SplunkTrust

Yeah, tokens are a bit of a hassle when using those online tools.

I generally use Splunk UI to write/update the query and remember which part Splunk is not encoding properly and do those changes only manually.

0 Karma

VatsalJagani
SplunkTrust
SplunkTrust

@Trex1 - I see you have used double backslashes \\w, \\n.

Use just single braces, like for new line \n, for space \s, etc.

Except for \\ which I'm guessing you need backslash as a character in your event.

 

Also, in the search string, you need to escape double quotes. So your search would look something like this:

AND "Opt in Response <result success=\"false\""

 

I hope this helps!!!

0 Karma

Trex1
Explorer

@VatsalJagani Unfortunately that didn't fix the issue. It still complains about unbalanced quotes in the search. Not sure if this is a search string problem or something else.

0 Karma
Get Updates on the Splunk Community!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...