<?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 to append field value to events based on its category in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-append-field-value-to-events-based-on-its-category/m-p/336475#M7203</link>
    <description>&lt;P&gt;if you want to search a word in _raw, you don't need to insert_raw=&lt;EM&gt;sql&lt;/EM&gt; you can insert sql in your search (if you run a search) or "like" or "match" functions if you're using an eval.&lt;BR /&gt;
Something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main host="prod*" earliest=1504915200 latest=1510358400 
 | eval layer=case(host="web" AND like(_raw,"%sql%") AND exception!="db2","Application",like(_raw,"%ERROR%"),"Queue",like(_raw,"%sql%") AND like(_raw,"%ERROR%") AND exception="db2","Dataservice"]
 |stats count by layer
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 15:49:16 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2020-09-29T15:49:16Z</dc:date>
    <item>
      <title>How to append field value to events based on its category</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-append-field-value-to-events-based-on-its-category/m-p/336468#M7196</link>
      <description>&lt;P&gt;I have all events logged under one index. The events arent categorzied. Below is the query&lt;/P&gt;

&lt;P&gt;index=main host="prod*" AND host= "*web*" AND _raw!="*sql*" AND exception!="*db2*"  error   earliest=1504915200  latest=1510358400  | eval layer="Application"| append [search index=main host="prod*" MQ _raw="&lt;EM&gt;ERROR&lt;/EM&gt;" earliest=1504915200  latest=1510358400   | eval layer="Queue"]| append [search index=main host="prod*" dataservice _raw="&lt;EM&gt;ERROR&lt;/EM&gt;" earliest=1504915200  latest=1510358400   | eval layer="Dataservice"]|stats count by layer&lt;/P&gt;

&lt;P&gt;Is it possible to combine both to single query somehting like below so that same index need not be queried twice&lt;/P&gt;

&lt;P&gt;index=app host="prod*" _raw!="&lt;EM&gt;INFO&lt;/EM&gt;" error  earliest=1504915200  latest=1510358400   |eval layer=case(host=="&lt;EM&gt;web&lt;/EM&gt;" OR host=="&lt;EM&gt;wap&lt;/EM&gt;" AND _raw!="" AND _raw!="&lt;EM&gt;sql&lt;/EM&gt;" AND _raw!="&lt;EM&gt;MQ&lt;/EM&gt;" AND exception!="&lt;EM&gt;db2&lt;/EM&gt;" AND exception !="&lt;EM&gt;solr&lt;/EM&gt;", "Application", raw=="&lt;EM&gt;MQ&lt;/EM&gt;", "Queue") |stats count by layer&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:45:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-append-field-value-to-events-based-on-its-category/m-p/336468#M7196</guid>
      <dc:creator>sangs8788</dc:creator>
      <dc:date>2020-09-29T15:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to append field value to events based on its category</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-append-field-value-to-events-based-on-its-category/m-p/336469#M7197</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;
it could be possible but in your search there's something I don't understand: _raw is the full event, how you can have in it "" or only "sql" or only "MQ"?&lt;BR /&gt;
do you want to filter events for this words?&lt;BR /&gt;
if this is your situation, you could perform something like this (eventually, modify filters in the main search)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=app host="prod*" _raw!="INFO" error earliest=1504915200 latest=1510358400 
| rex "(?&amp;lt;layer&amp;gt;MQ) 
| eval layer=if(layer="MQ","MQ","Application")
| stats count by layer
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 10:45:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-append-field-value-to-events-based-on-its-category/m-p/336469#M7197</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-09-15T10:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to append field value to events based on its category</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-append-field-value-to-events-based-on-its-category/m-p/336470#M7198</link>
      <description>&lt;P&gt;Edited the query. Somehow splunk didnt display the wildcard character.  The above solution would only work if there is only two categories.  What if i have more categorize based on different words present in the event ?&lt;BR /&gt;
How can i categorize and display&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 11:29:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-append-field-value-to-events-based-on-its-category/m-p/336470#M7198</guid>
      <dc:creator>sangs8788</dc:creator>
      <dc:date>2017-09-15T11:29:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to append field value to events based on its category</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-append-field-value-to-events-based-on-its-category/m-p/336471#M7199</link>
      <description>&lt;P&gt;Hi sangs8788,&lt;BR /&gt;
if you can, use other regexes to extract other fields and use case in eval condition.&lt;BR /&gt;
can you share other examples?&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 11:45:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-append-field-value-to-events-based-on-its-category/m-p/336471#M7199</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-09-15T11:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to append field value to events based on its category</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-append-field-value-to-events-based-on-its-category/m-p/336472#M7200</link>
      <description>&lt;P&gt;Here is an example with dataservice included.&lt;/P&gt;

&lt;P&gt;index=main host="prod*" AND host= "&lt;EM&gt;web&lt;/EM&gt;" AND _raw!="&lt;EM&gt;sql&lt;/EM&gt;" AND exception!="&lt;EM&gt;db2&lt;/EM&gt;" error earliest=1504915200 latest=1510358400 | eval layer="Application"| append [search index=main host="prod*" MQ _raw="ERROR" earliest=1504915200 latest=1510358400 | eval layer="Queue"]| append [search index=main host="prod*" _raw="&lt;EM&gt;sql&lt;/EM&gt;" _raw="ERROR" exception="&lt;EM&gt;db2&lt;/EM&gt;" earliest=1504915200 latest=1510358400 | eval layer="Dataservice"]|stats count by layer&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:45:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-append-field-value-to-events-based-on-its-category/m-p/336472#M7200</guid>
      <dc:creator>sangs8788</dc:creator>
      <dc:date>2020-09-29T15:45:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to append field value to events based on its category</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-append-field-value-to-events-based-on-its-category/m-p/336473#M7201</link>
      <description>&lt;P&gt;Try something like this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main host="prod*" earliest=1504915200 latest=1510358400 
| eval layer=case(host= "web" AND _raw!="sql" AND exception!="db2","Application",MQ _raw="ERROR","Queue",_raw="sql" AND _raw="ERROR" AND exception="db2","Dataservice"]
|stats count by layer
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Anyway, I continue to don't understand how you can have _raw equal to only one word (sql or ERROR)! &lt;BR /&gt;
or maybe when you say "_raw!=sql" you mean the in _raw there isn't "sql"?&lt;BR /&gt;
If this is your situation use like or match in each evaluation.&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:47:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-append-field-value-to-events-based-on-its-category/m-p/336473#M7201</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-09-29T15:47:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to append field value to events based on its category</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-append-field-value-to-events-based-on-its-category/m-p/336474#M7202</link>
      <description>&lt;P&gt;@cusello. It is not just sql or db2 in the query. It has * wildcard before and after. I guess splunk has removed the * and displayed&lt;BR /&gt;
and above query doesnt return any results for me. Not sure what is wrong in there&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2017 07:31:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-append-field-value-to-events-based-on-its-category/m-p/336474#M7202</guid>
      <dc:creator>sangs8788</dc:creator>
      <dc:date>2017-09-20T07:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to append field value to events based on its category</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-append-field-value-to-events-based-on-its-category/m-p/336475#M7203</link>
      <description>&lt;P&gt;if you want to search a word in _raw, you don't need to insert_raw=&lt;EM&gt;sql&lt;/EM&gt; you can insert sql in your search (if you run a search) or "like" or "match" functions if you're using an eval.&lt;BR /&gt;
Something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main host="prod*" earliest=1504915200 latest=1510358400 
 | eval layer=case(host="web" AND like(_raw,"%sql%") AND exception!="db2","Application",like(_raw,"%ERROR%"),"Queue",like(_raw,"%sql%") AND like(_raw,"%ERROR%") AND exception="db2","Dataservice"]
 |stats count by layer
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:49:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-append-field-value-to-events-based-on-its-category/m-p/336475#M7203</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-09-29T15:49:16Z</dc:date>
    </item>
  </channel>
</rss>

