Splunk Search

Javascript SDK (Nodejs) How should I write my search string to search based on host?

blazergun
Engager

Hi All,

I have Splunk running on my machine. I am using Nodejs (Javascript sdk) to search a query. I am using oneshotSearch to get all the results I want.

Through the web interface, I can run a very simple query host=V-MacBook-Pro.local and this returns me results. I want to search based on host=, because in the real dev environment, I might have logs aggregated and I need to filter out based on host.

This query does not run in my code.
In my code var searchQuery = "_host=V-MacBook-Pro.local" throws up:

[SPLUNKD] Error in 'SearchParser': Missing a search command before '_'. Error at position '0' of search query '_host=V-MacBook-Pro.local'.
Error with "host=V-MacBook-Pro.local" and no result with "search _host=V-MacBook-Pro.local". 

How exactly should my search string be to search based on "host" ?

0 Karma
1 Solution

masonmorales
Influencer

search host=V-MacBook-Pro.local

View solution in original post

masonmorales
Influencer

search host=V-MacBook-Pro.local

blazergun
Engager

Ah, missed one combination and that is the answer 🙂 Thanks.

Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...