<?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: Basic search help in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Basic-search-help/m-p/73895#M18554</link>
    <description>&lt;P&gt;Thanks jonuwz.&lt;BR /&gt;
I've you promote the comment to an answer I'll gladly accept it.&lt;/P&gt;</description>
    <pubDate>Tue, 26 Mar 2013 18:36:47 GMT</pubDate>
    <dc:creator>splunk_zen</dc:creator>
    <dc:date>2013-03-26T18:36:47Z</dc:date>
    <item>
      <title>Basic search help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Basic-search-help/m-p/73888#M18547</link>
      <description>&lt;P&gt;I've got a custom source A and B, which I need to compute a weighted average over,&lt;BR /&gt;
each source has only 2 collums: datetime and its own score (one per day, both sources times coincide).&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;EDIT&lt;/STRONG&gt;:&lt;BR /&gt;&lt;BR /&gt;
EtuServiceApdex.csv  headers:&lt;BR /&gt;&lt;BR /&gt;
_time,EtuServiceApdex    &lt;/P&gt;

&lt;P&gt;EtuOpApdex.csv  headers:&lt;BR /&gt;&lt;BR /&gt;
_time,EtuOpApdex&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=resources_reporting (source="*/output/ora_queries/client07/EtuOpApdex.csv" OR source="*/output/ora_queries/client07/EtuServiceApdex.csv")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;returns something like,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;28/02/2013 00:00:00.000     2013-02-28T00:00:00.000+00:00,64.583333 
host=vsplunk   sourcetype=csv-47   source=/opt/splunk/etc/apps/remote_scripts/output/ora_queries/client07/EtuServiceApdex.csv

28/02/2013 00:00:00.000     2013-02-28T00:00:00.000+00:00,50
host=vsplunk    sourcetype=csv-49   source=/opt/splunk/etc/apps/remote_scripts/output/ora_queries/client07/EtuOpApdex.csv

27/02/2013 00:00:00.000     2013-02-27T00:00:00.000+00:00,77.083333
host=vsplunk sourcetype=csv-47   source=/opt/splunk/etc/apps/remote_scripts/output/ora_queries/client07/EtuServiceApdex.csv

27/02/2013 00:00:00.000     2013-02-27T00:00:00.000+00:00,54.166667
host=vsplunk   sourcetype=csv-49   source=/opt/splunk/etc/apps/remote_scripts/output/ora_queries/client07/EtuOpApdex.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and both&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=resources_reporting (source="*/output/ora_queries/mt/MT_EtuOpApdex.csv" OR source="*/output/ora_queries/client07/EtuServiceApdex.csv")
| timechart avg(EtuOpApdex)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| timechart avg(EtuServiceApdex)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;return the expected graph over time,&lt;BR /&gt;
however, If I add the following I lose the _time properties &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval TotalApdexScore=(0.66*EtuServiceApdex + 0.33*EtuOpApdex)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| timechart avg(TotalApdexScore)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;returns a _time series with null values over TotalApdexScore.&lt;BR /&gt;
Eg:&lt;BR /&gt;
    _time   avg(TotalApdexScore)&lt;BR /&gt;
1   01/01/2013 00:00:00.000 &lt;BR /&gt;
2   02/01/2013 00:00:00.000 &lt;BR /&gt;
3   03/01/2013 00:00:00.000 &lt;/P&gt;

&lt;P&gt;How should I change the expression to get the intended weighted average over time ?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2013 19:19:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Basic-search-help/m-p/73888#M18547</guid>
      <dc:creator>splunk_zen</dc:creator>
      <dc:date>2013-03-25T19:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: Basic search help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Basic-search-help/m-p/73889#M18548</link>
      <description>&lt;P&gt;What exactly are you trying to do with this line?  | eval TotalApdexScore=(0.66*EtuServiceApdex + 0.33*EtuOpApdex).  I think I get it...maybe try changing the syntax to eval NewValue=(FirstValue*.60)+(SecondValue*.40)  or something like that&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:36:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Basic-search-help/m-p/73889#M18548</guid>
      <dc:creator>gnovak</dc:creator>
      <dc:date>2020-09-28T13:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: Basic search help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Basic-search-help/m-p/73890#M18549</link>
      <description>&lt;P&gt;Update:&lt;BR /&gt;
I've added &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats avg(EtuServiceApdex) as EtuServiceApdex avg(EtuOpApdex) as EtuOpApdex by _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;getting this total expression&lt;/P&gt;

&lt;P&gt;index=resources_reporting (source="&lt;EM&gt;/output/ora_queries/client07/MT_EtuOpApdex.csv" OR source="&lt;/EM&gt;/output&lt;BR /&gt;
| stats avg(EtuServiceApdex) as EtuServiceApdex avg(EtuOpApdex) as EtuOpApdex by _time&lt;BR /&gt;
| eval TotalApdexScore=(0.66*EtuServiceApdex + 0.33*EtuOpApdex)&lt;BR /&gt;
| timechart avg(TotalApdexScore)&lt;/P&gt;

&lt;P&gt;And I got the _time properties on both components,&lt;BR /&gt;
but I do not understand why I needed to add this | stats !&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:36:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Basic-search-help/m-p/73890#M18549</guid>
      <dc:creator>splunk_zen</dc:creator>
      <dc:date>2020-09-28T13:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: Basic search help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Basic-search-help/m-p/73891#M18550</link>
      <description>&lt;P&gt;gnovak, that line is a simplified expresion of my use case, I need a weighted score, in the mentioned expression EtuServiceApdex has a weight of 66% and EtuOpApdex a weight of 33% (both range from 0 to 100, yeah I know 33 + 66 is not 100)&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2013 19:32:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Basic-search-help/m-p/73891#M18550</guid>
      <dc:creator>splunk_zen</dc:creator>
      <dc:date>2013-03-25T19:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: Basic search help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Basic-search-help/m-p/73892#M18551</link>
      <description>&lt;P&gt;There are no fields in your raw data called EtuOpApdex or EtuServiceApdex, so&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| timechart avg(EtuOpApdex)&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;
or&lt;BR /&gt;&lt;BR /&gt;
&lt;CODE&gt;| timechart avg(EtuServiceApdex)&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;is never going to work.&lt;/P&gt;

&lt;P&gt;As a human I had to look at your raw data pretty closely to figure out where the value is ( the number after the "," after the XML-stantard datetime, and what the key was. The alphanumeric  characters preceeding the ".csv" in the source.&lt;/P&gt;

&lt;P&gt;Splunk isnt going to magically know this. You have to extract these fields up front.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=resources_reporting (source="*/output/ora_queries/client07/MT_EtuOpApdex.csv" OR source="*/output/ora_queries/client07/EtuServiceApdex.csv")
| rex ".*\d{4}-\d{2}-\d{2}T[^,]+,(?&amp;lt;value&amp;gt;[\d.]+)"
| rex field=source ".*?(?&amp;lt;field&amp;gt;[A-Za-z]+)\.csv"
| table _time field value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;make sure the fields are extracted properly&lt;/P&gt;

&lt;P&gt;now you can do&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| timechart span=1d avg(value) by field
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and now the eval to get the weighted average should work&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval TotalApdexScore=(0.66*EtuServiceApdex + 0.33*EtuOpApdex)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Update&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;The reason using stats 1st works is that it puts EtuServiceApdex and EtuOpApdex in the same event.&lt;/P&gt;

&lt;P&gt;Until you do that, only 1 of EtuServiceApdex or EtuOpApdex will exist and the other will be NULL&lt;/P&gt;

&lt;P&gt;Do this to prove it : &lt;CODE&gt;... | table _time EtuOpApdex EtuServiceApdex&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;If either is NULL, (0.66EtuServiceApdex) + (0.33EtuOpApdex) will evaluate to NULL&lt;/P&gt;

&lt;P&gt;An alternative is to this is to do the eval after the timechart.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| timechart avg(EtuOpApdex) as EtuOpApdex avg(EtuServiceApdex) as EtuServiceApdex
| eval TotalApdexScore=(0.66*EtuServiceApdex + 0.33*EtuOpApdex)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Mar 2013 03:53:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Basic-search-help/m-p/73892#M18551</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2013-03-26T03:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: Basic search help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Basic-search-help/m-p/73893#M18552</link>
      <description>&lt;P&gt;I'm sorry jonuwz.&lt;BR /&gt;
My original question had a missing information bit which ended up forcing you to generate that REGEX.&lt;/P&gt;

&lt;P&gt;The .csv sources headers are respectively:&lt;BR /&gt;
_time,EtuServiceApdex&lt;/P&gt;

&lt;P&gt;_time,EtuOpApdex&lt;/P&gt;

&lt;P&gt;which is why splunk seamlessly generates the following charts,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| timechart avg(EtuServiceApdex)

| timechart avg(EtuOpApdex)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but I can't understand why it is failing with&lt;/P&gt;

&lt;P&gt;| eval TotalApdexScore=(0.66*EtuServiceApdex + 0.33*EtuOpApdex)&lt;/P&gt;

&lt;P&gt;until I precede it with&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats avg(EtuServiceApdex) as EtuServiceApdex avg(EtuOpApdex) as EtuOpApdex by _time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:36:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Basic-search-help/m-p/73893#M18552</guid>
      <dc:creator>splunk_zen</dc:creator>
      <dc:date>2020-09-28T13:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: Basic search help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Basic-search-help/m-p/73894#M18553</link>
      <description>&lt;P&gt;Because in any given line, only 1 of EtuServiceApdex and EtuOpApdex exists.&lt;/P&gt;

&lt;P&gt;Do &lt;CODE&gt;... | table _time EtuOpApdex EtuServiceApdex&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;If either is NULL, (0.66*EtuServiceApdex) + (0.33*EtuOpApdex)  will evaluate to NULL&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:36:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Basic-search-help/m-p/73894#M18553</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2020-09-28T13:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: Basic search help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Basic-search-help/m-p/73895#M18554</link>
      <description>&lt;P&gt;Thanks jonuwz.&lt;BR /&gt;
I've you promote the comment to an answer I'll gladly accept it.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2013 18:36:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Basic-search-help/m-p/73895#M18554</guid>
      <dc:creator>splunk_zen</dc:creator>
      <dc:date>2013-03-26T18:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: Basic search help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Basic-search-help/m-p/73896#M18555</link>
      <description>&lt;P&gt;incorporated into original answer.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2013 19:02:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Basic-search-help/m-p/73896#M18555</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2013-03-26T19:02:15Z</dc:date>
    </item>
  </channel>
</rss>

