How to connect to Splunk Enterprise using the Splunk SDK for C# 2.x

Before you log on to Splunk Enterprise, you need to connect to it.

Add a using directive

Remember that before adding capabilities to your app, you must first add a using directive for the Splunk client library to your using block:

using Splunk.Client;

Create a Service object

Then, create an instance of the Service class, which is the primary entry point for the client library. For example, this code snippet creates an instance of the Service class using default scheme, host, port, and namespace values:

// Create a Service instance 
var service = new Service(new Uri("https://localhost:8089"));

// Log in
await service.LogOnAsync("admin", "changeme");

Of course, within your app, you should customize these values to your Splunk Enterprise instance, or build in a mechanism to retrieve these values from the user.

Reference