<?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 I use only part of Source as legend? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67938#M96990</link>
    <description>&lt;P&gt;It is hard to do without a sample event, but I think this is what you need now the legend should be the regex'd out portion of the source.  Let me know if it works. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 22 Sep 2012 01:06:48 GMT</pubDate>
    <dc:creator>davecroto</dc:creator>
    <dc:date>2012-09-22T01:06:48Z</dc:date>
    <item>
      <title>How do I use only part of Source as legend?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67931#M96983</link>
      <description>&lt;P&gt;I have the following search:&lt;BR /&gt;
"avg tx =" | timechart max(tx) by source&lt;/P&gt;

&lt;P&gt;Where Source is the filenames, for example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\\server1\vdi\LOGS\PCoIPLogFiles\V30040016\pcoip_server_2012_09_14_0000045c.txt
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The search works perfectly however the legends (same as the source) are too long.&lt;/P&gt;

&lt;P&gt;I'd like to only take part of the "source" as legends, remove "&lt;CODE&gt;\\server1\vdi\LOGS\PCoIPLogFiles\&lt;/CODE&gt;" and "\pcoip_server_2012_09_14_0000045c.txt", only leave the folder name "V300400xx" (I have many folders so I'm using xx to replace the actual number)&lt;/P&gt;

&lt;P&gt;OR, I was thinking if I can create sourcetype using part of the source, meaning "V300400xx", and do the following search, it should also work.&lt;BR /&gt;
"avg tx =" | timechart max(tx) by sourcetype&lt;/P&gt;

&lt;P&gt;Is this possible? Thanks in advance.&lt;/P&gt;

&lt;P&gt;Barry&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:29:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67931#M96983</guid>
      <dc:creator>yuanqi</dc:creator>
      <dc:date>2020-09-28T12:29:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use only part of Source as legend?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67932#M96984</link>
      <description>&lt;P&gt;Use rex to create another field: rex field=source "/opt/log/(?&lt;BLAHBLAH&gt;[^/]+)$" and then use that field as the the "by"&lt;/BLAHBLAH&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2012 23:22:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67932#M96984</guid>
      <dc:creator>davecroto</dc:creator>
      <dc:date>2012-09-21T23:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use only part of Source as legend?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67933#M96985</link>
      <description>&lt;P&gt;I'm not familiar with rex, I tried the following and didn't work. Any suggestion?&lt;/P&gt;

&lt;P&gt;"avg tx =" rex field=source "\server1\vdi\LOGS\PCoIPLogFiles(?&lt;HOSTNAME&gt;[^]+)$" | timechart max(tx) by hostname&lt;/HOSTNAME&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2012 23:37:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67933#M96985</guid>
      <dc:creator>yuanqi</dc:creator>
      <dc:date>2012-09-21T23:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use only part of Source as legend?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67934#M96986</link>
      <description>&lt;P&gt;Tried the following and didn't work. Any suggestion?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"avg tx =" rex field=source "\\server1\vdi\LOGS\PCoIPLogFiles\(?&amp;lt;hostname&amp;gt;[^\]+)$" | timechart max(tx) by hostname
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Sep 2012 23:39:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67934#M96986</guid>
      <dc:creator>yuanqi</dc:creator>
      <dc:date>2012-09-21T23:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use only part of Source as legend?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67935#M96987</link>
      <description>&lt;P&gt;Q:  you are searching for "avg tx ="&lt;/P&gt;

&lt;P&gt;if so&lt;/P&gt;

&lt;P&gt;"avg tx="|rex field=source "\\server1\vdi\LOGS\PCoIPLogFiles\\\\(?&lt;HOSTNAME&gt;\w+)" |timechart....&lt;/HOSTNAME&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2012 00:41:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67935#M96987</guid>
      <dc:creator>davecroto</dc:creator>
      <dc:date>2012-09-22T00:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use only part of Source as legend?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67936#M96988</link>
      <description>&lt;P&gt;edited this alot because I have to escape the \'s but I think you are just missing the "|" "pipe" between what you are searching for and the rex statement&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2012 00:49:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67936#M96988</guid>
      <dc:creator>davecroto</dc:creator>
      <dc:date>2012-09-22T00:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use only part of Source as legend?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67937#M96989</link>
      <description>&lt;P&gt;source="little.log" |search "avg tx=" |eval tx=6 |rex field=source "little(?&lt;HOSTNAME&gt;\.\w+)" |timechart max(tx) by hostname&lt;/HOSTNAME&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2012 01:05:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67937#M96989</guid>
      <dc:creator>davecroto</dc:creator>
      <dc:date>2012-09-22T01:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use only part of Source as legend?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67938#M96990</link>
      <description>&lt;P&gt;It is hard to do without a sample event, but I think this is what you need now the legend should be the regex'd out portion of the source.  Let me know if it works. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2012 01:06:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67938#M96990</guid>
      <dc:creator>davecroto</dc:creator>
      <dc:date>2012-09-22T01:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use only part of Source as legend?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67939#M96991</link>
      <description>&lt;P&gt;Got error:&lt;BR /&gt;
Error in 'rex' command: Encountered the following error while compiling the regex '\server1\vdi\LOGS\PCoIPLogFiles(?&lt;HOSTNAME&gt;w+)': Regex: PCRE does not support \L, \l, \N{name}, \U, or \u&lt;/HOSTNAME&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2012 01:15:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67939#M96991</guid>
      <dc:creator>yuanqi</dc:creator>
      <dc:date>2012-09-22T01:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use only part of Source as legend?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67940#M96992</link>
      <description>&lt;P&gt;I'm assuming the slashes are not there in your response because you didn't escape them &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;  &lt;/P&gt;

&lt;P&gt;Just use a regex that works in the rex statement.  As a test, does it work when you just do:&lt;/P&gt;

&lt;P&gt;| rex field=source "\\server1\vdi\LOGS\PCoIPLogFiles\(?&lt;HOSTNAME&gt;V30040016)"&lt;/HOSTNAME&gt;&lt;/P&gt;

&lt;P&gt;Do you still get the error message?&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2012 01:25:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67940#M96992</guid>
      <dc:creator>davecroto</dc:creator>
      <dc:date>2012-09-22T01:25:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use only part of Source as legend?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67941#M96993</link>
      <description>&lt;P&gt;What you really want to do is a transforms with a SOURCE_KEY, but that would be a bit more complicated. &lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2012 01:41:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67941#M96993</guid>
      <dc:creator>davecroto</dc:creator>
      <dc:date>2012-09-22T01:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use only part of Source as legend?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67942#M96994</link>
      <description>&lt;P&gt;I would use rex or regex to create a new field for the segment you wish to use as your new source.  Below is a sample, but the regex statement is incorrect.  This would be the simplest if you don't to use a transform.  Keep in mind there is a higher search cost when using this method, the transform would be more efficient.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=source (?&amp;lt;scr&amp;gt;/[\w\d\s\.]+/[\w\d\s\.]+$)| ... | timechart max(tx) by scr
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/rex"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/rex&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Optionaly you could build a lookup table.  Though I would use rex or a transform.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2012 02:07:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67942#M96994</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2012-09-22T02:07:30Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use only part of Source as legend?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67943#M96995</link>
      <description>&lt;P&gt;I gave up trying the \'s and end up doing the following.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=source "V(?&amp;lt; hostname&amp;gt;\w+)" | timechart max(tx) by hostname
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm missing the first letter V of my hostnames but at least this works.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Sep 2012 03:14:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67943#M96995</guid>
      <dc:creator>yuanqi</dc:creator>
      <dc:date>2012-09-22T03:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use only part of Source as legend?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67944#M96996</link>
      <description>&lt;P&gt;try putting the "V" in the parens...&lt;/P&gt;

&lt;P&gt;rex field=source "(?&amp;lt; hostname&amp;gt;V\w+)" | timechart max(tx) by hostname&lt;/P&gt;</description>
      <pubDate>Sun, 23 Sep 2012 04:23:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-use-only-part-of-Source-as-legend/m-p/67944#M96996</guid>
      <dc:creator>melting</dc:creator>
      <dc:date>2012-09-23T04:23:28Z</dc:date>
    </item>
  </channel>
</rss>

