<?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: correlate 2 events with uid in a table in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320792#M4486</link>
    <description>&lt;P&gt;hello @elliotproebstel,&lt;/P&gt;

&lt;P&gt;I have a table with uid and user which are correlate but i don't have the name of the USB key in the field usb_key.&lt;/P&gt;

&lt;P&gt;amir &lt;/P&gt;</description>
    <pubDate>Wed, 07 Mar 2018 10:50:54 GMT</pubDate>
    <dc:creator>amir_thales</dc:creator>
    <dc:date>2018-03-07T10:50:54Z</dc:date>
    <item>
      <title>correlate 2 events with uid in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320790#M4484</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I want information about the usb keys mounted on the system but the / var / log / messages or the /var/log/audit/audit.log do not give enough interesting information about the USB sticks.&lt;/P&gt;

&lt;P&gt;So I want to use the data contained in the / etc / passwd and the / etc / mtab to correlate the information and thus deduce in a table the login of the current session and the name of the usb key mounted on it.&lt;/P&gt;

&lt;P&gt;I used the add-on unix to generate the information contained in the / etc / passwd but this add-on does not propose me to generate the information of / etc / mtab, so I configured splunk for it to monitor this file and since this file is dynamic, when a line is added at the end of the file when we insert a usb key, this line is automatically generated on splunk.&lt;/P&gt;

&lt;P&gt;Now I want to find a way to correlate message 1 with message 2.&lt;/P&gt;

&lt;P&gt;I want to correlate the uid ie in the message 1 we see that there is the uid 500, so I will use the message 2 to deduce that 500 = local_splunk. After correlating the uids I want to make a table that will show me the uid, user, usb key name mounted.&lt;/P&gt;

&lt;P&gt;Thank you&lt;BR /&gt;
Amir&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/4472iBFD2195A3B6AC3B1/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Mar 2018 16:48:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320790#M4484</guid>
      <dc:creator>amir_thales</dc:creator>
      <dc:date>2018-03-06T16:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: correlate 2 events with uid in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320791#M4485</link>
      <description>&lt;P&gt;If you already have the usb key name extracted into a field called &lt;CODE&gt;usb_key&lt;/CODE&gt;, then this should work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your current search
| eval user_id=coalesce(user_id, uid)
| stats list(user) AS user, list(usb_key) AS usb_key BY user_id
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Mar 2018 17:19:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320791#M4485</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-03-06T17:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: correlate 2 events with uid in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320792#M4486</link>
      <description>&lt;P&gt;hello @elliotproebstel,&lt;/P&gt;

&lt;P&gt;I have a table with uid and user which are correlate but i don't have the name of the USB key in the field usb_key.&lt;/P&gt;

&lt;P&gt;amir &lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 10:50:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320792#M4486</guid>
      <dc:creator>amir_thales</dc:creator>
      <dc:date>2018-03-07T10:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: correlate 2 events with uid in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320793#M4487</link>
      <description>&lt;P&gt;excuse me I did not read what was written above.&lt;/P&gt;

&lt;P&gt;I will extract this data and test.&lt;/P&gt;

&lt;P&gt;thank you &lt;BR /&gt;
Amir&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 10:53:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320793#M4487</guid>
      <dc:creator>amir_thales</dc:creator>
      <dc:date>2018-03-07T10:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: correlate 2 events with uid in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320794#M4488</link>
      <description>&lt;P&gt;Would you like help writing the &lt;CODE&gt;rex&lt;/CODE&gt; command to extract it? If so, can you show the source event and highlight which part you're extracting? I'm guessing you'd be looking at the first event for &lt;CODE&gt;/media/Transcend&lt;/CODE&gt;, but I'm not certain. Can you also show if the usb_key value that you want to extract is currently in another field or just a part of the _raw event data?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 13:28:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320794#M4488</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-03-07T13:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: correlate 2 events with uid in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320795#M4489</link>
      <description>&lt;P&gt;@elliotproebstel,&lt;/P&gt;

&lt;P&gt;yes, please.&lt;/P&gt;

&lt;P&gt;I did this for now but I can only get the first 2 usb key not the 3:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;my search |  rex "(\n)(?&amp;lt;usb_key&amp;gt;/\w+/\w+\s+/\w+/\w+[-\w+])"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;In the picture after, there is my event which i want use:&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/4468i68E68B9F781BD146/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;And what i extract with my rex:&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/4469i84EB79550B89FC12/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Thank you &lt;BR /&gt;
Amir&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 13:43:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320795#M4489</guid>
      <dc:creator>amir_thales</dc:creator>
      <dc:date>2018-03-07T13:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: correlate 2 events with uid in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320796#M4490</link>
      <description>&lt;P&gt;Does this work? &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "^(?&amp;lt;usb_key&amp;gt;\/\S+\s\/\S+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Mar 2018 14:28:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320796#M4490</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-03-07T14:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: correlate 2 events with uid in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320797#M4491</link>
      <description>&lt;P&gt;yes, it works for the first line &lt;CODE&gt;/dev/sdb1 /media/Transcend&lt;/CODE&gt; but not for the 2 others.&lt;/P&gt;

&lt;P&gt;it's well extracted to &lt;CODE&gt;/dev/sdb1 /media/Transcend&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 14:35:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320797#M4491</guid>
      <dc:creator>amir_thales</dc:creator>
      <dc:date>2018-03-07T14:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: correlate 2 events with uid in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320798#M4492</link>
      <description>&lt;P&gt;but my main problem is to extract the 2 from below.&lt;/P&gt;

&lt;P&gt;Sorry for the double post.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 14:36:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320798#M4492</guid>
      <dc:creator>amir_thales</dc:creator>
      <dc:date>2018-03-07T14:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: correlate 2 events with uid in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320799#M4493</link>
      <description>&lt;P&gt;Got it. Does this work for you?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "(^|\n)(?&amp;lt;usb_key&amp;gt;\/\S+\s\/\S+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Mar 2018 14:50:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320799#M4493</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-03-07T14:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: correlate 2 events with uid in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320800#M4494</link>
      <description>&lt;P&gt;it is the same problem it works but with the first line.&lt;/P&gt;

&lt;P&gt;it extract me &lt;CODE&gt;/dev/sdb1 /media/Transcend&lt;/CODE&gt; but not the 2 others.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 15:00:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320800#M4494</guid>
      <dc:creator>amir_thales</dc:creator>
      <dc:date>2018-03-07T15:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: correlate 2 events with uid in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320801#M4495</link>
      <description>&lt;P&gt;Ahh, I was forgetting the &lt;CODE&gt;max_match&lt;/CODE&gt; option, which may be biting us. Sorry for shooting in the dark a bit here, but I don't have access to a Splunk instance at the moment, so I can't test things before posting. I'm going to shotgun several options here, and you can test any/all of them:&lt;/P&gt;

&lt;P&gt;First:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex max_match=0 "(?s)(?&amp;lt;usb_key&amp;gt;\/\S+\s\/\S+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Second:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex max_match=0 "(^|\n)(?&amp;lt;usb_key&amp;gt;\/\S+\s\/\S+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Third:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex max_match=0 "[\S\s](?&amp;lt;usb_key&amp;gt;\/\S+\s\/\S+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm hoping one of these works!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 15:11:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320801#M4495</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-03-07T15:11:26Z</dc:date>
    </item>
    <item>
      <title>Re: correlate 2 events with uid in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320802#M4496</link>
      <description>&lt;P&gt;It's not a problem that, you take your time to help me on the contrary I'm happy to learn.&lt;/P&gt;

&lt;P&gt;the first 2 are good, I have the 3 that are extracted.&lt;/P&gt;

&lt;P&gt;Is it possible that you explain:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;rex max_match = 0 "(^ | \ n) (? &amp;lt;usb_key&amp;gt; \ / \ S + \ s \ / \ S +)"&lt;/CODE&gt; and &lt;CODE&gt;[\ S \ s]&lt;/CODE&gt; which is in the 2nd expression.&lt;/P&gt;

&lt;P&gt;thank you &lt;BR /&gt;
Amir&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 15:20:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320802#M4496</guid>
      <dc:creator>amir_thales</dc:creator>
      <dc:date>2018-03-07T15:20:03Z</dc:date>
    </item>
    <item>
      <title>Re: correlate 2 events with uid in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320803#M4497</link>
      <description>&lt;P&gt;Great! And I'm happy to explain!&lt;/P&gt;

&lt;P&gt;The snippet &lt;CODE&gt;(^|\n)&lt;/CODE&gt; in the first is looking for &lt;CODE&gt;^&lt;/CODE&gt;, which means the start of the line OR &lt;CODE&gt;\n&lt;/CODE&gt;, which is a newline character. I was figuring that the first line wouldn't be preceded by a newline, so we'd need &lt;CODE&gt;^&lt;/CODE&gt; to grab the first one.&lt;/P&gt;

&lt;P&gt;The &lt;CODE&gt;[\S\s]&lt;/CODE&gt; was also a bit of a trick to look for any character at all (including a newline), because it matches on &lt;CODE&gt;\S&lt;/CODE&gt; (any non-whitespace character) or &lt;CODE&gt;\s&lt;/CODE&gt; (any whitespace character). But I expect it probably failed to grab the first line, since the first &lt;CODE&gt;usb_key&lt;/CODE&gt; value had nothing at all before it. It might work if revised like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex max_match=0 "[\S\s]?(?&amp;lt;usb_key&amp;gt;\/\S+\s\/\S+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;because that makes the &lt;CODE&gt;[\S\s]&lt;/CODE&gt; optional (zero or one matches will pass).&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 15:28:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320803#M4497</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-03-07T15:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: correlate 2 events with uid in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320804#M4498</link>
      <description>&lt;P&gt;ok thank you so much for your help @elliotproebstel .&lt;/P&gt;

&lt;P&gt;I learned a lot today &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Amir&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 15:33:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320804#M4498</guid>
      <dc:creator>amir_thales</dc:creator>
      <dc:date>2018-03-07T15:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: correlate 2 events with uid in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320805#M4499</link>
      <description>&lt;P&gt;My pleasure! &lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 15:41:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320805#M4499</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-03-07T15:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: correlate 2 events with uid in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320806#M4500</link>
      <description>&lt;P&gt;sorry but i want to add the time in the table but when i add it the user field becomes empty as if the correlation was no longer working.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 17:42:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320806#M4500</guid>
      <dc:creator>amir_thales</dc:creator>
      <dc:date>2018-03-07T17:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: correlate 2 events with uid in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320807#M4501</link>
      <description>&lt;P&gt;i want to know how  can i correlate uid of the message 1 with the uid in the message 2 and deduct the user and display the event when it appears with the names of the usb keys that I extracted. Because i have i problem which is, when event appear splunk only takes the usb key events alone and does not correlate the uid in the event with the uid of the message 2. is there not a function that basically allows to set up a dynamic array or when the 'event 1 appears it will directly dig into it and deduce that uid 500 = local_splunk.&lt;/P&gt;

&lt;P&gt;Still sorry for the double post&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 18:19:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320807#M4501</guid>
      <dc:creator>amir_thales</dc:creator>
      <dc:date>2018-03-07T18:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: correlate 2 events with uid in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320808#M4502</link>
      <description>&lt;P&gt;Sure. Given the events above, do you want to use the time from the event that contained the name of the USB key? If so, I'd do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search
| rex max_match=0 "(^|\n)(?&amp;lt;usb_key&amp;gt;\/\S+\s\/\S+)"
| eval user_id=coalesce(user_id, uid)
| eval usb_time=if(source="/etc/mtab", _time, NULL)
| stats latest(usb_time) AS _time, list(user) AS user, list(usb_key) AS usb_key BY user_id
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Mar 2018 18:21:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320808#M4502</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-03-07T18:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: correlate 2 events with uid in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320809#M4503</link>
      <description>&lt;P&gt;is it possible to display this by usb key with the number of times they appear each and uid and the user and the date ?&lt;/P&gt;

&lt;P&gt;thank you &lt;BR /&gt;
Amir&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 18:28:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/correlate-2-events-with-uid-in-a-table/m-p/320809#M4503</guid>
      <dc:creator>amir_thales</dc:creator>
      <dc:date>2018-03-07T18:28:50Z</dc:date>
    </item>
  </channel>
</rss>

