Splunk Search

SearchTemplate Query Error

rkanalyst
Explorer

I am facing the problem when i am adding "\" inside the searchTemplate query for conditional checks.The same query is working fine when used for the search but not inside searchTemplate .

Query inside SearchTemplate:

searchTemplate> tag="$tagname$" sourcetype="SrcFile" | eval series1=if(searchmatch("\"first String \" AND \"Second String\""),_time,null()) | timechart span="$splitinterval$" count(series1) as Request

   </searchTemplate>

ERROR ::

PARSER: Applying intentions failed Error in 'eval' command: The expression is malformed. Expected ).

Please provide any help if possible.I had tried the option for CData inside the tag.

Thanks in Advance!

Tags (1)
0 Karma

rkanalyst
Explorer

Got this error Resolved by using the macro. Putting this content in : sourcetype="SrcFile" | eval series1=if(searchmatch(""first String " AND "Second String""),_time,null()) a newly defined Macro.

I found other informations like 1)Backslah problem in splunk http://answers.splunk.com/questions/6563/backslash-escape-problem 2) Use search macro

http://www.splunk.com/base/Documentation/latest/User/CreateAndUseSearchMacros

0 Karma

Paolo_Prigione
Builder

Have you tried to use ascii-html for troublesome characters? Try the following:

  • replace " (quote) with &quot;
  • replace \ (backslash) with &#92;
0 Karma

Paolo_Prigione
Builder

Thanks for the update!

0 Karma

rkanalyst
Explorer

Thanks.
But I tried by changing the " and \ with the string you mentioned.But Still I am facing the same problem.

0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...