<?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 How to extract and compute fields from a MongoDB log? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-and-compute-fields-from-a-MongoDB-log/m-p/236125#M70131</link>
    <description>&lt;P&gt;Hello, &lt;/P&gt;

&lt;P&gt;I am new to Splunk, can you help me figure out to extract and fields from logs that look like the below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2016-10-06T21:22:15.285+0000 I COMMAND  [conn337418] command PersoTestServiceDB.$cmd command: update { update: "Test_Stage", updates: 1000, ordered: false, shardVersion: [ Timestamp 0|0, ObjectId('000000000000000000000000') ] } keyUpdates:0 writeConflicts:0 numYields:0 reslen:232 locks:{ Global: { acquireCount: { r: 2000, w: 2000 } }, Database: { acquireCount: { w: 2000 } }, Collection: { acquireCount: { w: 1000 } }, Metadata: { acquireCount: { w: 1000 } }, oplog: { acquireCount: { w: 1000 } } } protocol:op_command 175ms
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The above block is from a MongoDB log file, I am mostly interested in extracting the last field and then sort by the field with the largest value in "ms". I am trying to see how long queries take to complete on average as well as identify the long running queries from the logs. I would also like to list the long running query next to the query time when sorted.&lt;/P&gt;

&lt;P&gt;Your assistance is appreciated. Thanks.&lt;/P&gt;</description>
    <pubDate>Thu, 06 Oct 2016 21:39:36 GMT</pubDate>
    <dc:creator>kchongo</dc:creator>
    <dc:date>2016-10-06T21:39:36Z</dc:date>
    <item>
      <title>How to extract and compute fields from a MongoDB log?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-and-compute-fields-from-a-MongoDB-log/m-p/236125#M70131</link>
      <description>&lt;P&gt;Hello, &lt;/P&gt;

&lt;P&gt;I am new to Splunk, can you help me figure out to extract and fields from logs that look like the below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2016-10-06T21:22:15.285+0000 I COMMAND  [conn337418] command PersoTestServiceDB.$cmd command: update { update: "Test_Stage", updates: 1000, ordered: false, shardVersion: [ Timestamp 0|0, ObjectId('000000000000000000000000') ] } keyUpdates:0 writeConflicts:0 numYields:0 reslen:232 locks:{ Global: { acquireCount: { r: 2000, w: 2000 } }, Database: { acquireCount: { w: 2000 } }, Collection: { acquireCount: { w: 1000 } }, Metadata: { acquireCount: { w: 1000 } }, oplog: { acquireCount: { w: 1000 } } } protocol:op_command 175ms
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The above block is from a MongoDB log file, I am mostly interested in extracting the last field and then sort by the field with the largest value in "ms". I am trying to see how long queries take to complete on average as well as identify the long running queries from the logs. I would also like to list the long running query next to the query time when sorted.&lt;/P&gt;

&lt;P&gt;Your assistance is appreciated. Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2016 21:39:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-and-compute-fields-from-a-MongoDB-log/m-p/236125#M70131</guid>
      <dc:creator>kchongo</dc:creator>
      <dc:date>2016-10-06T21:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract and compute fields from a MongoDB log?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-and-compute-fields-from-a-MongoDB-log/m-p/236126#M70132</link>
      <description>&lt;P&gt;If your data is already in Splunk, you could try this in your search&lt;BR /&gt;
*&lt;STRONG&gt;&lt;EM&gt;UPDATED&lt;/EM&gt;&lt;/STRONG&gt;*&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search  NOT "sleeping" | rex "(?&amp;lt;dur&amp;gt;\d+)ms" | eventstats avg(dur) as avg_dur | sort - dur | table _time _raw dur avg_dur
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Oct 2016 22:42:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-and-compute-fields-from-a-MongoDB-log/m-p/236126#M70132</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-10-06T22:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract and compute fields from a MongoDB log?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-and-compute-fields-from-a-MongoDB-log/m-p/236127#M70133</link>
      <description>&lt;P&gt;Thanks this looks good, now one more thing; how can I strip out a log entry below that is counting sleep time; its adding to the average calculation and when sorted appears at the top of the results.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2016-10-07T00:11:56.366+0000 I SHARDING [LockPinger] cluster mongodbhost1a:27019,mongodbhost1b:27019,mongodbhost1c:27022 pinged successfully at 2016-10-07T00:11:55.615+0000 by distributed lock pinger 'mongodbhost1a:27019,mongodbhost1b:27019,mongodbhost1c:27022/mongodbhost4a:27018:1469673136:466927433', sleeping for 30000ms
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Oct 2016 00:22:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-and-compute-fields-from-a-MongoDB-log/m-p/236127#M70133</guid>
      <dc:creator>kchongo</dc:creator>
      <dc:date>2016-10-07T00:22:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract and compute fields from a MongoDB log?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-and-compute-fields-from-a-MongoDB-log/m-p/236128#M70134</link>
      <description>&lt;P&gt;Try the updated search&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2016 02:18:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-and-compute-fields-from-a-MongoDB-log/m-p/236128#M70134</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-10-07T02:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract and compute fields from a MongoDB log?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-and-compute-fields-from-a-MongoDB-log/m-p/236129#M70135</link>
      <description>&lt;P&gt;Thanks, this gives me what I am looking for. I can build more around this starting point. &lt;/P&gt;

&lt;P&gt;I noticed that the time seems to be shown on the graph on reverse, the latest times are the one closest to the x and y intersection; should this be the other way round? How can I fix this&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2016 14:44:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-and-compute-fields-from-a-MongoDB-log/m-p/236129#M70135</guid>
      <dc:creator>kchongo</dc:creator>
      <dc:date>2016-10-07T14:44:06Z</dc:date>
    </item>
  </channel>
</rss>

