<?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 correlate Dense Sensor Data with a Sparse Data Set? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-Dense-Sensor-Data-with-a-Sparse-Data-Set/m-p/229386#M67925</link>
    <description>&lt;P&gt;This is a job for streamstats ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=densedata OR source=sparsedata 

| rename COMMENT as "optionally, if there is no SensorName on the sparsedata, then do this"
| eval SensorName=coalesce(SensorName,"sensor1 sensor2 sensor3 sensoretc")
| makemv SensorName    
| mvexpand SensorName

| rename COMMENT as "Now we keep a running average of the last ten minutes Data on all sensors"
| sort 0 SensorName _time
| streamstats avg(Data) as avgData time_window=10m by SensorName

| rename COMMENT as "And keep only the sparse events, which now have the running average for Data"
| where source="sparsedata"
| fillnull value="((none))" avgData
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 17 Jul 2017 18:57:52 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2017-07-17T18:57:52Z</dc:date>
    <item>
      <title>How to correlate Dense Sensor Data with a Sparse Data Set?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-Dense-Sensor-Data-with-a-Sparse-Data-Set/m-p/229382#M67921</link>
      <description>&lt;P&gt;I have dense sensor data (~75k events in a 3 week period) from multiple sensors that I would like to correlate to a sparse set of data (~100 events in the same time period).  The data span several different sensors. &lt;/P&gt;

&lt;P&gt;Sensor data events have these fields: &lt;BR /&gt;
_time, SensorName=SensorA, Data=394  &lt;/P&gt;

&lt;P&gt;Sparse data events have these fields: &lt;BR /&gt;
_time, ImportantProperty=583 &lt;/P&gt;

&lt;P&gt;Sensor data logs at a specific interval when nothing interesting is happening, or records a value if there is a significant change in the Data value. &lt;/P&gt;

&lt;P&gt;What I would like to do is have Splunk tell me what the Data value was for each &lt;STRONG&gt;SensorName&lt;/STRONG&gt; at the time that an &lt;STRONG&gt;ImportantProperty&lt;/STRONG&gt; event occurred. &lt;/P&gt;

&lt;P&gt;In the past, when I was looking at only one sensor, I have used transaction: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(source=densedata AND SensorName=SensorA) OR source=sparsedata | transaction maxspan=10m maxevents=-1 | search ImportantProperty=* | stats avg(Data) avg(ImportantProperty) by _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, this doesn't work when multiple SensorNames are involved. &lt;/P&gt;

&lt;P&gt;It seems like what I would want to do is subsearch for the sensor data around the time the ImportantProperty events occur, but I can't find any documentation on how I would do that for multiple time ranges (i.e. each of the 100 sparse events) and find all the sensor data events at those times. &lt;/P&gt;

&lt;P&gt;Help! &lt;/P&gt;

&lt;P&gt;I am constrained by my position and can't show my actual data, only generalized searches like the above. &lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2015 17:34:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-Dense-Sensor-Data-with-a-Sparse-Data-Set/m-p/229382#M67921</guid>
      <dc:creator>ErikaE</dc:creator>
      <dc:date>2015-11-17T17:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to correlate Dense Sensor Data with a Sparse Data Set?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-Dense-Sensor-Data-with-a-Sparse-Data-Set/m-p/229383#M67922</link>
      <description>&lt;P&gt;You need the &lt;CODE&gt;map&lt;/CODE&gt; command; it allows you to run an inner subsearch once for every event contained in the outer search and allows you to pass fields from each outer search event into the inner search:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.1/SearchReference/map"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.1/SearchReference/map&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2015 18:22:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-Dense-Sensor-Data-with-a-Sparse-Data-Set/m-p/229383#M67922</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-11-17T18:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to correlate Dense Sensor Data with a Sparse Data Set?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-Dense-Sensor-Data-with-a-Sparse-Data-Set/m-p/229384#M67923</link>
      <description>&lt;P&gt;Thanks for the help! The doc is pretty sparse on examples of map. Is it possible to return matching events or more than one row of a table? &lt;/P&gt;

&lt;P&gt;My inner search is:  &lt;/P&gt;

&lt;P&gt;search="search earliest=early_t latest=late_t Sensor=Sensor* | stats avg(Data) by Sensor"&lt;/P&gt;

&lt;P&gt;which returns a table like: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Sensor      Data 
SensorA   39
SensorB   393
SensorC   392
SensorD  494 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The doc says that the search is a literal search. Where can I find more info on what that means and any restrictions that might come with it?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:53:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-Dense-Sensor-Data-with-a-Sparse-Data-Set/m-p/229384#M67923</guid>
      <dc:creator>ErikaE</dc:creator>
      <dc:date>2020-09-29T07:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to correlate Dense Sensor Data with a Sparse Data Set?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-Dense-Sensor-Data-with-a-Sparse-Data-Set/m-p/229385#M67924</link>
      <description>&lt;P&gt;Here is how got the output I was looking for: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=sparsedata | eval earliest_t=_time-300 | eval latest_t=_time+300 | eval midtime=_time+0 | map maxsearches=999 search="search source=densedata earliest=$earliest_t$ latest=$latest_t$ | eval mid_t=$midtime$ | eval ImportantProperty=$ImportantProperty$ | stats avg(Data), values(ImportantProperty), values(mid_t) by Sensor" | table Sensor avg(Data) values(ImportantProperty) values(mid_t) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The important bit I was missing when I posted my first reply was the final table command to get the output in the format I wanted. &lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2015 01:18:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-Dense-Sensor-Data-with-a-Sparse-Data-Set/m-p/229385#M67924</guid>
      <dc:creator>ErikaE</dc:creator>
      <dc:date>2015-11-18T01:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to correlate Dense Sensor Data with a Sparse Data Set?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-Dense-Sensor-Data-with-a-Sparse-Data-Set/m-p/229386#M67925</link>
      <description>&lt;P&gt;This is a job for streamstats ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=densedata OR source=sparsedata 

| rename COMMENT as "optionally, if there is no SensorName on the sparsedata, then do this"
| eval SensorName=coalesce(SensorName,"sensor1 sensor2 sensor3 sensoretc")
| makemv SensorName    
| mvexpand SensorName

| rename COMMENT as "Now we keep a running average of the last ten minutes Data on all sensors"
| sort 0 SensorName _time
| streamstats avg(Data) as avgData time_window=10m by SensorName

| rename COMMENT as "And keep only the sparse events, which now have the running average for Data"
| where source="sparsedata"
| fillnull value="((none))" avgData
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Jul 2017 18:57:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-Dense-Sensor-Data-with-a-Sparse-Data-Set/m-p/229386#M67925</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-07-17T18:57:52Z</dc:date>
    </item>
  </channel>
</rss>

