Knowledge Management

Is there any way to limit the number of search results in a data model?

emiliavanderwer
Explorer

When searching on an index, you can pipe to "head 100" and retrieve 100 results.

index=my_index cookie* | head 100

However, when searching over a data model, how do you tell it to get only 100 results?

| tstats count from datamodel=my_dm where g.message=cookie* by g.id

0 Karma
1 Solution

renjith_nair
Legend

@emiliavanderwerf,

Did you try

| tstats count from datamodel=my_dm where g.message=cookie* by g.id|head 100

Below works for me

|tstats count from datamodel=test by sourcetype|head 2

Where test is index=_internal

Happy Splunking!

View solution in original post

woodcock
Esteemed Legend

The exact same way:

| tstats count from datamodel=my_dm where g.message=cookie* by g.id | head 100

Or, more productively,

| tstats count from datamodel=my_dm where g.message=cookie* by g.id | sort 100 - count

renjith_nair
Legend

@emiliavanderwerf,

Did you try

| tstats count from datamodel=my_dm where g.message=cookie* by g.id|head 100

Below works for me

|tstats count from datamodel=test by sourcetype|head 2

Where test is index=_internal

Happy Splunking!
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...