<?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: Fields missing only when queried via SDK / Rest API in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Fields-missing-only-when-queried-via-SDK-Rest-API/m-p/144634#M29535</link>
    <description>&lt;P&gt;It did indeed turn out to be a permissions issue.  If you like, make this into a full answer and I will gladly accept it.  Either way, thanks!&lt;/P&gt;</description>
    <pubDate>Fri, 03 Oct 2014 21:09:19 GMT</pubDate>
    <dc:creator>ardave</dc:creator>
    <dc:date>2014-10-03T21:09:19Z</dc:date>
    <item>
      <title>Fields missing only when queried via SDK / Rest API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Fields-missing-only-when-queried-via-SDK-Rest-API/m-p/144630#M29531</link>
      <description>&lt;P&gt;I have a query to average out the performance of requests each individual server for the last one minutes, as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=iis earliest=-1m host=group1_* OR host=group2_*  | STATS avg(time_taken) as Value BY host | EVAL counter="Server Response Time" | fields + host, Value, counter
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This works fine via the Splunk Web/UI but the exact same query yields no "Value" column when submitted via the SDK.&lt;/P&gt;

&lt;P&gt;So this query returns exactly what I want/expect via Splunk web access:  three columns: one for the host/server name, one for the average of the time_taken fields for that host, and one column containing the literal "Server Response Time", just so that the client code that I'm writing (via the Splunk C# SDK v2.0.0) can distinguish the results of this query from other queries.&lt;/P&gt;

&lt;P&gt;However, I can't get the REST API to return any values for for the "Value" column.  I've mimicked the code sample from the C# SDK found in root\examples\normal-search\Program.cs, using the example of the "Pull Model" code sample.&lt;/P&gt;

&lt;P&gt;And my code works fine for other Splunk queries; just not this query with the "STATS avg(...)" clause.&lt;/P&gt;

&lt;P&gt;Interestingly, the &lt;STRONG&gt;Splunk.Client.SearchResult&lt;/STRONG&gt; object &lt;EM&gt;does&lt;/EM&gt; have an entry in its &lt;STRONG&gt;.FieldNames&lt;/STRONG&gt; collection named "Value", but the dynamic object itself never has a &lt;STRONG&gt;.Value&lt;/STRONG&gt; property, nor can I find anything resembling the Value column I see just fine when running the same query within the Web/UI.  I &lt;EM&gt;can&lt;/EM&gt; however find all other columns in the dynamic object.&lt;/P&gt;

&lt;P&gt;Additionally, I looked at the request to the REST API itself and it appears as though the "Value" field is defined differently than the other fields, "host" and "counter", but I cannot understand the reasons why.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;?xml version='1.0' encoding='UTF-8'?&amp;gt;
&amp;lt;results preview='0'&amp;gt;
&amp;lt;meta&amp;gt;
&amp;lt;fieldOrder&amp;gt;
&amp;lt;field groupby_rank="0"&amp;gt;host&amp;lt;/field&amp;gt;
&amp;lt;field&amp;gt;Value&amp;lt;/field&amp;gt;
&amp;lt;field type="str"&amp;gt;counter&amp;lt;/field&amp;gt;
&amp;lt;/fieldOrder&amp;gt;
&amp;lt;/meta&amp;gt;
    &amp;lt;result offset='0'&amp;gt;
        &amp;lt;field k='host'&amp;gt;
            &amp;lt;value h='1'&amp;gt;&amp;lt;text&amp;gt;[redacted]&amp;lt;/text&amp;gt;&amp;lt;/value&amp;gt;
        &amp;lt;/field&amp;gt;
        &amp;lt;field k='counter'&amp;gt;
            &amp;lt;value&amp;gt;&amp;lt;text&amp;gt;Server Response Time&amp;lt;/text&amp;gt;&amp;lt;/value&amp;gt;
        &amp;lt;/field&amp;gt;
    &amp;lt;/result&amp;gt;
    &amp;lt;result offset='1'&amp;gt;
        &amp;lt;field k='host'&amp;gt;
            &amp;lt;value h='1'&amp;gt;&amp;lt;text&amp;gt;[redacted]&amp;lt;/text&amp;gt;&amp;lt;/value&amp;gt;
        &amp;lt;/field&amp;gt;
        &amp;lt;field k='counter'&amp;gt;
            &amp;lt;value&amp;gt;&amp;lt;text&amp;gt;Server Response Time&amp;lt;/text&amp;gt;&amp;lt;/value&amp;gt;
        &amp;lt;/field&amp;gt;
    &amp;lt;/result&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and so on.&lt;/P&gt;

&lt;P&gt;Thank you in advance for any help!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Sep 2014 00:32:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Fields-missing-only-when-queried-via-SDK-Rest-API/m-p/144630#M29531</guid>
      <dc:creator>ardave</dc:creator>
      <dc:date>2014-09-30T00:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: Fields missing only when queried via SDK / Rest API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Fields-missing-only-when-queried-via-SDK-Rest-API/m-p/144631#M29532</link>
      <description>&lt;P&gt;Have you tried using some other name instead of Value (say avg_time_taken or so)?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:44:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Fields-missing-only-when-queried-via-SDK-Rest-API/m-p/144631#M29532</guid>
      <dc:creator>sk314</dc:creator>
      <dc:date>2020-09-28T17:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: Fields missing only when queried via SDK / Rest API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Fields-missing-only-when-queried-via-SDK-Rest-API/m-p/144632#M29533</link>
      <description>&lt;P&gt;That's a good idea to try.  Unfortunately "Foo" doesn't work either, as in:  index=iis earliest=-1m host=group1_* OR host=group2_**  | STATS avg(time_taken) as Foo BY host | EVAL counter="Server Response Time" | fields + host, Foo, counter&lt;BR /&gt;
My guess is that something to do with "STATS" or "avg" or the piping is preventing the field from being returned, but I haven't been able to figure out how to overcome.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:44:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Fields-missing-only-when-queried-via-SDK-Rest-API/m-p/144632#M29533</guid>
      <dc:creator>ardave</dc:creator>
      <dc:date>2020-09-28T17:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: Fields missing only when queried via SDK / Rest API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Fields-missing-only-when-queried-via-SDK-Rest-API/m-p/144633#M29534</link>
      <description>&lt;P&gt;Check the field extract permissions and if the scope is defined as app or global... try to make it "global" and accessible to everybody.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Sep 2014 23:09:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Fields-missing-only-when-queried-via-SDK-Rest-API/m-p/144633#M29534</guid>
      <dc:creator>musskopf</dc:creator>
      <dc:date>2014-09-30T23:09:34Z</dc:date>
    </item>
    <item>
      <title>Re: Fields missing only when queried via SDK / Rest API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Fields-missing-only-when-queried-via-SDK-Rest-API/m-p/144634#M29535</link>
      <description>&lt;P&gt;It did indeed turn out to be a permissions issue.  If you like, make this into a full answer and I will gladly accept it.  Either way, thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 03 Oct 2014 21:09:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Fields-missing-only-when-queried-via-SDK-Rest-API/m-p/144634#M29535</guid>
      <dc:creator>ardave</dc:creator>
      <dc:date>2014-10-03T21:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: Fields missing only when queried via SDK / Rest API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Fields-missing-only-when-queried-via-SDK-Rest-API/m-p/144635#M29536</link>
      <description>&lt;P&gt;Check the field extract permissions and if the scope is defined as app or global... try to make it "global" and accessible to everybody.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2014 21:01:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Fields-missing-only-when-queried-via-SDK-Rest-API/m-p/144635#M29536</guid>
      <dc:creator>musskopf</dc:creator>
      <dc:date>2014-10-06T21:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: Fields missing only when queried via SDK / Rest API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Fields-missing-only-when-queried-via-SDK-Rest-API/m-p/144636#M29537</link>
      <description>&lt;P&gt;Could you show me how to define the scope as global? Thanks so much!&lt;/P&gt;</description>
      <pubDate>Mon, 15 Dec 2014 16:20:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Fields-missing-only-when-queried-via-SDK-Rest-API/m-p/144636#M29537</guid>
      <dc:creator>trustin</dc:creator>
      <dc:date>2014-12-15T16:20:16Z</dc:date>
    </item>
  </channel>
</rss>

