All Apps and Add-ons

REST API JSON fields shown in search but search with stats fails

avilandau
Path Finder

I've downloaded and installed the rest-api modular input (rest_ta). I've defined in my inputs.conf REST end point that I'm interested in which returns JSON and when I do a search and display the results in list format Splunk shows the JSON format perfectly, i.e. all json fields are display in red with full expand/collapse on any part of the Json. I believe that this indicates Splunk recognizes it as JSON since the source type is _json and the response type is json. However, when I try to do any stats on it I get "no results found". So tried the samples shown in the "analytics.usa.gov Recreated Using Splunk sample" and I have the same issue, i.e. when I search "sourcetype="_json" source="rest://visits by desktop mobile tablet devices over 90 days p1d" I can see a perfect JSON breakdown but if I add stats (sourcetype="_json" source="rest://visits by desktop mobile tablet devices over 90 days p1d"| stats latest(totals.devices.desktop) I get no result found. I'm not sure what the issue is since it seems that for JSON response the default response handler is sufficient and there is no need for special handler and also the sample above doesn't mention anything else.

Tags (1)
0 Karma

somesoni2
Revered Legend

Since the field name has dot (.) , you should include it within single quotes while using in stats/eval/where. Probably you'll not need spath if the fields are appearing in the field side bar already.

(sourcetype="_json" source="rest://visits by desktop mobile tablet devices over 90 days p1d"| stats latest('totals.devices.desktop')
0 Karma

avilandau
Path Finder

I just realized that adding the spath solve this problem but I'm still not sure how to break the JSON. However that should probably be a different question.

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...