Splunk Search

How to apply the predict command with group by for multiple column values in one search ?

intelsubham
Explorer

I want to apply the predict command on multiple column values with one search.

My table values are like this:

alt text

fetching table by applying timechart on a field which contains numeric values.

Tags (2)

laurie_gellatly
Communicator

If you have your columns in a 'somecategory' field and the values of the columns in a 'somecount' field that would allow you to do something like

... | timechart sum(somecount) BY somecategory | predict 10357 12745 13317

...Laurie:{)

0 Karma

gwobben
Communicator

Sorry, you cannot do that. Predict has no "by" clause, like stats, which makes it impossible to make multiple predictions.

HOWEVER

If you really need to, and don't really care for performance, you could use the map command to do something like:

 ... your search resulting in a list IDs (your column names) ... | map [search id=$id$ | timechart something | predict]

The map command will loop all of your column names (I guess they are IDs of something?) and execute predict for each of them. Then it will append the results of each run to the final results. Just remember this has quite the performance impact because you'll be starting a new search for each ID.

As an alternative you might consider user the R app, which is currently only available on github: https://github.com/rfsp/r. This app will allow you to run R commands in Splunk, and R is able to make multiple predictions at a time.

Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...