<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Can I add constant field/value conditionally? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-I-add-constant-field-value-conditionally/m-p/642170#M222453</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232673"&gt;@yk010123&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;You may use the following eval case to map the description with your status code,&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval description=case(status=="404","NOT FOUND",status==500,"INTERNAL ERROR",status=="400","INVALID Request",1=1,"NULL")&lt;/LI-CODE&gt;&lt;P&gt;Kindly support the answer if found helpful.&lt;/P&gt;</description>
    <pubDate>Wed, 03 May 2023 18:47:13 GMT</pubDate>
    <dc:creator>seemanshu</dc:creator>
    <dc:date>2023-05-03T18:47:13Z</dc:date>
    <item>
      <title>Can I add constant field/value conditionally?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-add-constant-field-value-conditionally/m-p/642163#M222449</link>
      <description>&lt;P&gt;I have the following query:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;"MyToken" status &amp;gt;= 400
| stats count by status,action&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That produces a table like :&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;status&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;action&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;count&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;404&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;action1&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;20&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;500&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;action2&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;30&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;400&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;action3&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;50&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to add a constant "description" depending on the status so that for example the output looks like :&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="318.00000000000006px"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="83.0312px" height="25px"&gt;status&lt;/TD&gt;
&lt;TD width="87.6719px" height="25px"&gt;action&lt;/TD&gt;
&lt;TD width="52.9375px" height="25px"&gt;count&lt;/TD&gt;
&lt;TD width="93.3594px" height="25px"&gt;description&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="83.0312px" height="47px"&gt;404&lt;/TD&gt;
&lt;TD width="87.6719px" height="47px"&gt;action1&lt;/TD&gt;
&lt;TD width="52.9375px" height="47px"&gt;20&lt;/TD&gt;
&lt;TD width="93.3594px" height="47px"&gt;NOT FOUND&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="83.0312px" height="47px"&gt;500&lt;/TD&gt;
&lt;TD width="87.6719px" height="47px"&gt;action2&lt;/TD&gt;
&lt;TD width="52.9375px" height="47px"&gt;30&lt;/TD&gt;
&lt;TD width="93.3594px" height="47px"&gt;INTERNAL ERROR&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="83.0312px" height="25px"&gt;400&lt;/TD&gt;
&lt;TD width="87.6719px" height="25px"&gt;action3&lt;/TD&gt;
&lt;TD width="52.9375px" height="25px"&gt;50&lt;/TD&gt;
&lt;TD width="93.3594px" height="25px"&gt;INVALID Request&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The description should map from the status&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2023 18:21:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-add-constant-field-value-conditionally/m-p/642163#M222449</guid>
      <dc:creator>yk010123</dc:creator>
      <dc:date>2023-05-03T18:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Can I add constant field/value conditionally?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-add-constant-field-value-conditionally/m-p/642168#M222451</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232673"&gt;@yk010123&lt;/a&gt;, you can map a lookup file to the status codes using the following command:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| lookup http_status_codes_lookup.csv status OUTPUT description&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This assumes you have a lookup file containing the fields status and description. If you don't yet have a lookup, you can add one through settings, lookups. You could start by getting a prefilled csv file at iana:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml" target="_blank"&gt;https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml&lt;/A&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.iana.org/assignments/http-status-codes/http-status-codes-1.csv" target="_blank"&gt;https://www.iana.org/assignments/http-status-codes/http-status-codes-1.csv&lt;/A&gt;&lt;/P&gt;&lt;P&gt;You can read more about adding lookups over here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.0.4/Knowledge/Usefieldlookupstoaddinformationtoyourevents" target="_blank" rel="noopener"&gt;https://docs.splunk.com/Documentation/Splunk/9.0.4/Knowledge/Usefieldlookupstoaddinformationtoyourevents&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2023 18:39:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-add-constant-field-value-conditionally/m-p/642168#M222451</guid>
      <dc:creator>rut</dc:creator>
      <dc:date>2023-05-03T18:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: Can I add constant field/value conditionally?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-add-constant-field-value-conditionally/m-p/642170#M222453</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232673"&gt;@yk010123&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;You may use the following eval case to map the description with your status code,&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval description=case(status=="404","NOT FOUND",status==500,"INTERNAL ERROR",status=="400","INVALID Request",1=1,"NULL")&lt;/LI-CODE&gt;&lt;P&gt;Kindly support the answer if found helpful.&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2023 18:47:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-add-constant-field-value-conditionally/m-p/642170#M222453</guid>
      <dc:creator>seemanshu</dc:creator>
      <dc:date>2023-05-03T18:47:13Z</dc:date>
    </item>
  </channel>
</rss>

