Splunk Search

Count # of sensors by host and dashboard

ksheikh786
Loves-to-Learn

Calculating metrics. I need to count the number of sensors that are created and monitored for each host. I have the index and sourcetype.

I created about 7 different dashboards with multiple host on each dashboard and I need to get a count on the number of sensors that are being monitored by each host. 

index=idx_sensors sourcetype = sensorlog | stats count by host

the above query is giving me all the hostnames that are being monitored but the count is giving me all the events... I just need the # of sensors per host. 

 

Labels (1)
0 Karma

ksheikh786
Loves-to-Learn

Lets say I have a dashboard setup with 5 hosts (serverA, serverB, serverC, serverD, serverE), for each host there are 5-10 queries setup to pull data using the same index=idx_sensors.

I can manually count and see that there are x # of sensors setup per hostname. 

How would I create a query to check how many sensors are being monitored by hostname? 

(I've got 7 diff dashboards w/ multiple hosts monitoring X number of sensors. I need to get metrics for which host has how many sensors that are currently being monitored.)

 

0 Karma

ksheikh786
Loves-to-Learn

I need to track the number of alerts configured under index=idx_sensors by hostname

0 Karma

yuanliu
SplunkTrust
SplunkTrust

You haven't answered key questions from me and @bowesmana.  Without SPL, what do you use to count number of sensors per host (if the total number of events is not the answer).

Let me repeat the four commandments of asking answerable questions in this forum:

  • Illustrate data input (in raw text, anonymize as needed), whether they are raw events or output from a search (SPL that volunteers here do not have to look at).
  • Illustrate the desired output from illustrated data.
  • Explain the logic between illustrated data and desired output without SPL.
  • If you also illustrate attempted SPL, illustrate actual output and compare with desired output, explain why they look different to you if that is not painfully obvious.
0 Karma

yuanliu
SplunkTrust
SplunkTrust

I can manually count and see that there are x # of sensors setup per hostname. 

You need to show volunteers here HOW do you count number of sensors from logs (without using SPL).

Here are four commandments to help you ask answerable questions in this forum:

  • Illustrate data input (in raw text, anonymize as needed), whether they are raw events or output from a search (SPL that volunteers here do not have to look at).
  • Illustrate the desired output from illustrated data.
  • Explain the logic between illustrated data and desired output without SPL.
  • If you also illustrate attempted SPL, illustrate actual output and compare with desired output, explain why they look different to you if that is not painfully obvious.
0 Karma

bowesmana
SplunkTrust
SplunkTrust

Did you try the query I posted?

0 Karma

ksheikh786
Loves-to-Learn

Yes, it returned 0s

0 Karma

bowesmana
SplunkTrust
SplunkTrust

What field does your data contain that holds the sensor value? Did you change the query as needed to pick up that field.

 

0 Karma

bowesmana
SplunkTrust
SplunkTrust

Use dc

index=idx_sensors sourcetype = sensorlog 
| stats dc(sensor_field) as sensors by host
0 Karma

isoutamo
SplunkTrust
SplunkTrust
Can you give sample of your events?
You could add another or more field after by on stats if there is something which you could use.
0 Karma
Get Updates on the Splunk Community!

Technical Workshop Series: Splunk Data Management and SPL2 | Register here!

Hey, Splunk Community! Ready to take your data management skills to the next level? Join us for a 3-part ...

Spotting Financial Fraud in the Haystack: A Guide to Behavioral Analytics with Splunk

In today's digital financial ecosystem, security teams face an unprecedented challenge. The sheer volume of ...

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability As businesses scale ...