<?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: Extract particular field value and assign to a variable to be used for further searches in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-particular-field-value-and-assign-to-a-variable-to-be/m-p/14707#M1624</link>
    <description>&lt;P&gt;Thank you so much Lowell for your tips and help.&lt;/P&gt;

&lt;P&gt;I tried something like this and i got the output i needed.&lt;/P&gt;

&lt;HR /&gt;

&lt;H2&gt;[ search "my_error_message" | fields + TransactionId | fields - _* | format ] | search my_other_operation | sort _time | xmlkv | fields + TransactionId, FieldB, FieldC | stats values(*) by TransactionId&lt;/H2&gt;

&lt;P&gt;i got the fields "TransactionId, FieldB, FieldC" grouped by TransactionId.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;but also i request to let me know if there is any other way and more tips. &lt;/P&gt;

&lt;P&gt;Once again thanks&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 09:13:23 GMT</pubDate>
    <dc:creator>jeni</dc:creator>
    <dc:date>2020-09-28T09:13:23Z</dc:date>
    <item>
      <title>Extract particular field value and assign to a variable to be used for further searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-particular-field-value-and-assign-to-a-variable-to-be/m-p/14703#M1620</link>
      <description>&lt;P&gt;Hi &lt;/P&gt;

&lt;P&gt;I am trying to do the following.&lt;/P&gt;

&lt;P&gt;I have to prepare a report which contains the TransactionId, servername, some other fields values for a transaction with encoutered a particular error.&lt;/P&gt;

&lt;P&gt;i am able to get the part of transaction which has the error message, but not able to get teh complete trace of that transaction from which i have to get some other values for my report.&lt;/P&gt;

&lt;P&gt;Could anyone help me in this regard. Thanks&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;for example: to capture all transactions and comeplete details of the transactions that has errored with error message "xyz"&lt;/P&gt;

&lt;P&gt;i tried to search on error message "xyz" and for example in 5th step if it has errored - when i tried to search on the error message it will give me only the 5th part - but from that i can get the transaction id (thread id ) as it remains the same for the complete transaction (all teh steps). using rex command i got the transaction.&lt;/P&gt;

&lt;P&gt;Now how i need use this transactionid to get the complete trace of that particular transaction from the beginning instead of getting the error message part alone.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2010 21:59:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-particular-field-value-and-assign-to-a-variable-to-be/m-p/14703#M1620</guid>
      <dc:creator>jeni</dc:creator>
      <dc:date>2010-06-02T21:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: Extract particular field value and assign to a variable to be used for further searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-particular-field-value-and-assign-to-a-variable-to-be/m-p/14704#M1621</link>
      <description>&lt;P&gt;Could you include a small data sample?&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2010 22:05:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-particular-field-value-and-assign-to-a-variable-to-be/m-p/14704#M1621</guid>
      <dc:creator>Stephen_Sorkin</dc:creator>
      <dc:date>2010-06-02T22:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: Extract particular field value and assign to a variable to be used for further searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-particular-field-value-and-assign-to-a-variable-to-be/m-p/14705#M1622</link>
      <description>&lt;P&gt;Also an example of the search that you are using would be helpful.  (Please use the "edit" link to add that info to your question.)&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2010 22:11:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-particular-field-value-and-assign-to-a-variable-to-be/m-p/14705#M1622</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-06-02T22:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: Extract particular field value and assign to a variable to be used for further searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-particular-field-value-and-assign-to-a-variable-to-be/m-p/14706#M1623</link>
      <description>&lt;P&gt;There are two approaches that you could take.  These have a very different performance implication if you have lots of events, but if you don't then either one should be pretty fast.&lt;/P&gt;

&lt;H3&gt;Transaction search:&lt;/H3&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=my_source_type ... | transaction fields="host,TransactionId" | search "my-xyz-error-message"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This approach will first group all of your events into individual transaction events based on unique combinations of host and TranscationId.  You may also want to look into the other &lt;CODE&gt;transaction&lt;/CODE&gt; options as well, such as  &lt;CODE&gt;maxspan&lt;/CODE&gt; which is helpful to limit the overall time range of your transactions, which is especially important if &lt;CODE&gt;TransactionId&lt;/CODE&gt; repeats.&lt;/P&gt;

&lt;P&gt;You can make this approach work better if you can filter out unwanted messages in your base search.  For example, if you have many known-unhelpful messages (such as debug messages or startup messages that can be ignored) you can save resources (and process a larger number of transactions) if you can filtering out a large number of unwanted messages.&lt;/P&gt;

&lt;H3&gt;Use a sub-search:&lt;/H3&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=my_source_type [ search sourcetype=my_source_type ... "my-xyz-error-message" | fields + host, TransactionId | fields - _* | format ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This approach will take the inner-search (This is a "subsearch" which is looking for any &lt;CODE&gt;TransactionId&lt;/CODE&gt; and &lt;CODE&gt;host&lt;/CODE&gt; combination that has your error message) and builds a dynamic search for the combinations that are known to have this error.  (Note there is a 100 event limit on the on sub-searches which may prevent this from being a valid option for you.)&lt;/P&gt;

&lt;P&gt;With this search, events will be show individually.  If you prefer the combined transaction look you can do that here too.  Simply stick ` | transaction fields="host,TransactionId" at the end of this search.&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;For other tips and tricks, I recommend the following:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;Browse around on this (answers.splunk.com)  site and the docs.&lt;/LI&gt;
&lt;LI&gt;Check out the commands shown on the &lt;A href="http://www.splunk.com/base/Documentation/latest/SearchReference/SearchCheatsheet" rel="nofollow"&gt;Search command cheat sheet&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Thu, 03 Jun 2010 00:53:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-particular-field-value-and-assign-to-a-variable-to-be/m-p/14706#M1623</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-06-03T00:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: Extract particular field value and assign to a variable to be used for further searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-particular-field-value-and-assign-to-a-variable-to-be/m-p/14707#M1624</link>
      <description>&lt;P&gt;Thank you so much Lowell for your tips and help.&lt;/P&gt;

&lt;P&gt;I tried something like this and i got the output i needed.&lt;/P&gt;

&lt;HR /&gt;

&lt;H2&gt;[ search "my_error_message" | fields + TransactionId | fields - _* | format ] | search my_other_operation | sort _time | xmlkv | fields + TransactionId, FieldB, FieldC | stats values(*) by TransactionId&lt;/H2&gt;

&lt;P&gt;i got the fields "TransactionId, FieldB, FieldC" grouped by TransactionId.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;but also i request to let me know if there is any other way and more tips. &lt;/P&gt;

&lt;P&gt;Once again thanks&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:13:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-particular-field-value-and-assign-to-a-variable-to-be/m-p/14707#M1624</guid>
      <dc:creator>jeni</dc:creator>
      <dc:date>2020-09-28T09:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: Extract particular field value and assign to a variable to be used for further searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-particular-field-value-and-assign-to-a-variable-to-be/m-p/14708#M1625</link>
      <description>&lt;P&gt;When i was doing my search and my search critera has 222 results.&lt;BR /&gt;
During search i got this error message...&lt;/P&gt;

&lt;P&gt;Any one please explain why the error message is thrown&lt;/P&gt;

&lt;P&gt;[subsearch]: The format command is using only the first 100 (of 130) results&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2010 20:18:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-particular-field-value-and-assign-to-a-variable-to-be/m-p/14708#M1625</guid>
      <dc:creator>jeni</dc:creator>
      <dc:date>2010-06-03T20:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: Extract particular field value and assign to a variable to be used for further searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-particular-field-value-and-assign-to-a-variable-to-be/m-p/14709#M1626</link>
      <description>&lt;P&gt;If you have more than 100 results in your sub-search (the one in square brackets) then the results will be truncated.  Therefore I suggest you use the first search approach or use a smaller time window.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2010 21:24:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-particular-field-value-and-assign-to-a-variable-to-be/m-p/14709#M1626</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-06-03T21:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: Extract particular field value and assign to a variable to be used for further searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-particular-field-value-and-assign-to-a-variable-to-be/m-p/14710#M1627</link>
      <description>&lt;P&gt;Yes, there are probably other ways to do this too; you could write your own custom search command if you really wanted to; however these are probably the two best approaches to use in this situation.  You may also be able to pull some stuff together grouping values together using &lt;CODE&gt;stats&lt;/CODE&gt;, but only if &lt;CODE&gt;TransactionId&lt;/CODE&gt; doesn't repeat.  As for other tips, I'll stick some more stuff in my answer; which is easier to read than putting it into comments.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2010 21:28:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-particular-field-value-and-assign-to-a-variable-to-be/m-p/14710#M1627</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-06-03T21:28:50Z</dc:date>
    </item>
  </channel>
</rss>

