Splunk Search

Stats search in SDK: Receiving task cancelled error

gsureshkumarcse
New Member

Hi Team,

I am trying to run stats splunk search using c# SDK and getting task cancelled error.
Kindly help me on this. I have tried with/without sleep too.

{
await service.LogOnAsync("USERNAME", "PASSWORD");
                Job job = await service.Jobs.CreateAsync("search index=windows_inetpub cs_uri_stem=\"*/search\" | stats count", 10);
                SearchResultStream stream;

                while (!job.IsDone)
                {
                    Thread.Sleep(1000);
                }

                using (stream = await job.GetSearchResultsAsync(1))
                {
                    try
                    {
                        foreach (SearchResult result in stream)
                        {
                            Console.WriteLine(string.Format("{0:D8}: {1}", stream.ReadCount, result));
                        }

                        Console.WriteLine("End of search results");
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(string.Format("SearchResults error: {0}", e.Message));
                    }
                }
}

Any help on this will be more helpfull.

Thank you,
Suresh Kumar G.

0 Karma
Get Updates on the Splunk Community!

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...

Cloud Monitoring Console - Unlocking Greater Visibility in SVC Usage Reporting

For Splunk Cloud customers, understanding and optimizing Splunk Virtual Compute (SVC) usage and resource ...

Automatic Discovery Part 3: Practical Use Cases

If you’ve enabled Automatic Discovery in your install of the Splunk Distribution of the OpenTelemetry ...