splunk / splunk-sdk-csharp-pcl

Splunk's next generation C# SDK
https://dev.splunk.com/enterprise/docs/csharp
Apache License 2.0
64 stars 46 forks source link

Stats Query in SDK - Task Cancelled error #94

Closed gsureshkumarcse closed 2 years ago

gsureshkumarcse commented 5 years ago

Hi Team,

I am trying to run stats splunk query 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));
                    }
                }
ncanumalla-splunk commented 2 years ago

This SDK is deprecated and no longer under active development.