<?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: How do you get a description field with the output result fields? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-get-a-description-field-with-the-output-result-fields/m-p/388583#M113319</link>
    <description>&lt;P&gt;No, no, no.  Do not use &lt;CODE&gt;+&lt;/CODE&gt; for concatenation because its primary function is addition and if any of your variables ever has a number in it, you will generate a &lt;CODE&gt;NaN&lt;/CODE&gt; error.  switch back to using &lt;CODE&gt;.&lt;/CODE&gt; but make sure that you have spaces on each side of each period.&lt;/P&gt;</description>
    <pubDate>Mon, 18 Feb 2019 22:54:43 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-02-18T22:54:43Z</dc:date>
    <item>
      <title>How do you get a description field with the output result fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-get-a-description-field-with-the-output-result-fields/m-p/388577#M113313</link>
      <description>&lt;P&gt;I have the below query &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main AND sourcetype="abc" AND id=* AND ((state="terminated" AND image.attributes.name!="emr*") OR private_ip_address!=null) 
| eval time=strftime(_time,"%d/%m/%Y %H:%M:%S") 
| eval state = if(state=="terminated", state, null()) 
| eval node=aws_account_id 
| eval resource="Instance Termination" 
| eval type="Instance Terminated" 
| eval severity=1 
| stats values(private_ip_address) AS private_ip_address values(state) AS state BY id image.attributes.name 
| mvexpand private_ip_address 
| search state=terminated 
| search private_ip_address!=null
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This gives the correct output with  id image.attributes.name  private_ip_address state. Now I want to have a description field that will change according to the results, but it's not populating because of the stats command running before this. How can we modify the search to result this output?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval description="The instance : ". image.attributes.name . " with id:" .id. " has status " .state . "with ip" .private_ip_address. " at ". time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:16:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-get-a-description-field-with-the-output-result-fields/m-p/388577#M113313</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2020-09-29T23:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do you get a description field with the output result fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-get-a-description-field-with-the-output-result-fields/m-p/388578#M113314</link>
      <description>&lt;P&gt;did you try to add your |eval description before  stats?. Also you would need to add 'description' in your stats by clause &lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 17:16:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-get-a-description-field-with-the-output-result-fields/m-p/388578#M113314</guid>
      <dc:creator>lakshman239</dc:creator>
      <dc:date>2019-02-14T17:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do you get a description field with the output result fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-get-a-description-field-with-the-output-result-fields/m-p/388579#M113315</link>
      <description>&lt;P&gt;Yes I did but no luck&lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 17:23:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-get-a-description-field-with-the-output-result-fields/m-p/388579#M113315</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2019-02-14T17:23:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do you get a description field with the output result fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-get-a-description-field-with-the-output-result-fields/m-p/388580#M113316</link>
      <description>&lt;P&gt;Hi @vrmandadi&lt;/P&gt;

&lt;P&gt;Try like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query.. | stats values(private_ip_address) AS private_ip_address values(state) AS state BY id image.attributes.name 
| eval temp= mvzip(private_ip_address, state) 
| mvexpand temp
| rex field=temp "(?&amp;lt;private_ip_address&amp;gt;[^\,]+)\,(?&amp;lt;state&amp;gt;[^\,]+)"
| eval description="The instance : ". image.attributes.name . " with id:" .id. " has status " .state . "with ip" .private_ip_address. " at ". time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Feb 2019 17:55:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-get-a-description-field-with-the-output-result-fields/m-p/388580#M113316</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-02-14T17:55:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do you get a description field with the output result fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-get-a-description-field-with-the-output-result-fields/m-p/388581#M113317</link>
      <description>&lt;P&gt;I got it using + between each field worked&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main AND sourcetype="aws:description" AND id=* AND ((state="terminated" AND image.attributes.name!="emr*") OR private_ip_address!=null) 
 | eval time=strftime(_time,"%d/%m/%Y %H:%M:%S")
| eval state = if(state=="terminated", state, null()) 
|stats latest(state) as state  , values(private_ip_address) as private_ip_address , latest(time) as time  by id image.attributes.name aws_account_id |rename image.attributes.name as name | mvexpand private_ip_address 
| search state=terminated 
| search private_ip_address!=null
| eval node=aws_account_id 
| eval resource="Instance Termination" 
| eval type="Instance Terminated" 
| eval severity=1
| eval description="The instance:" + name + " with id:" + id + " has status: " + state + " with ip: " + private_ip_address + " at time: " + time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Feb 2019 18:32:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-get-a-description-field-with-the-output-result-fields/m-p/388581#M113317</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2019-02-14T18:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do you get a description field with the output result fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-get-a-description-field-with-the-output-result-fields/m-p/388582#M113318</link>
      <description>&lt;P&gt;I tried this but it did not work&lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 18:33:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-get-a-description-field-with-the-output-result-fields/m-p/388582#M113318</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2019-02-14T18:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: How do you get a description field with the output result fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-get-a-description-field-with-the-output-result-fields/m-p/388583#M113319</link>
      <description>&lt;P&gt;No, no, no.  Do not use &lt;CODE&gt;+&lt;/CODE&gt; for concatenation because its primary function is addition and if any of your variables ever has a number in it, you will generate a &lt;CODE&gt;NaN&lt;/CODE&gt; error.  switch back to using &lt;CODE&gt;.&lt;/CODE&gt; but make sure that you have spaces on each side of each period.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 22:54:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-get-a-description-field-with-the-output-result-fields/m-p/388583#M113319</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-02-18T22:54:43Z</dc:date>
    </item>
  </channel>
</rss>

