Splunk’s SDK for C# vNext: modern, scalable and portable

Since we released our first version of the Splunk SDK for C# for .NET 3.5, we’ve seen healthy adoption and it’s become one of our most highly used SDKs. Since that time, the .NET Framework has continued to evolve, offering a better language experience for building scalable applications, and supporting more platforms where you can run .NET applications including .NET 4.5, Windows Phone, Windows 8/RT and additional platforms with Xamarin.

A new version of our C# SDK

I am excited to announce that we are developing a new version of our C# SDK, version 2.0, which we are designing from scratch to leverage the modern advances of .NET and C#!

Here are our core high-level goals.

  • Modern standards – We’re putting in a lot of energy to make sure the new SDK meets the expectations of modern developers and follows .NET guidelines. To that end,  we are using tools like FXCop and StyleCop to statically analyze our code and enforce these standards in our codebase.
  • Async – All APIs that involve HTTP calls are 100% asynchronous supporting the new async/await language features in C#. This will come in really handy for building desktop, server and mobile applications.
  • Rx – Splunk’s query results allow usage with the .NET Reactive Extensions (Rx). Rx was built for pushing server results in a streaming manner, which makes this a great match for usage in the SDK.
  • Portable - .NET is no longer about just running on Windows Desktops and Servers, it is truly a cross platform solution. The new Splunk Client in the SDK is a Portable Class Library unlocking these new platforms for your Splunk development.
  • Xamarin – Thanks to Xamarin and the partnership with Microsoft, you’ll be able to use the latest SDK for Linux, iOS and Android development! In addition to Visual Studio, you will be able to build and debug whether in Xamarin Studio or Mono Develop.
  • Testable – We’ve seen a huge growth in the industry around TDD and unit testing. We want to make sure you can run all your own unit tests on top of our SDK without requiring a Splunk instance. Our own xUnit.net test suite runs without requiring Splunk. We’re building acceptance tests that do hit Splunk but in the future, you will be able to run the tests offline without hitting Splunk. 

What’s in the box?

As this is a rewrite of our existing SDK, we’re focusing on the most common areas that we’ve heard our customers are using. Here is a list of the areas we will cover in the 2.0 release.

  • Login
  • Access control (users and passwords)
  • Searches (normal, blocking, oneshot, and export)
  • Jobs
  • Reports (“saved searches” in Splunk Enterprise 5)
  • Configuration and Config Properties
  • Indexes
  • Inputs (sending simple and streamed events to Splunk Enterprise)
  • Applications
  • Modular inputs

A sneak peak at the APIs

Our new SDK offers a natural experience for working with async. Here’s a simple example of using the SDK to get search results:

using Splunk.Client;
  
var service = new Service(Scheme.Https, "localhost", 8089);

//login 
await service.LoginAsync("admin", "changeme");

//create a job 
var job = await service.StartJobAsync("search index=_internal | head 10");

//get the results 
var searchResults = await job.GetSearchResultsAsync();

//loop through the results 
foreach (var record in searchResults.ToEnumerator()) {
  Console.WriteLine(string.Format("{0:D8}: {1}", ++recordNumber, record));
}

And here is a snippet using Rx!

//subscribe to start receiving results
resultSet.SubscribeOn(ThreadPoolScheduler.Instance).Subscribe(
  onNext: (rec) =>
  {
    //output the result
    Console.WriteLine(string.Format("{0:D8}: {1}", ++recNo, rec));
  },
  onError: (ex) =>
  {
    //log errors
    Console.WriteLine(string.Format("SearchResults error: {0}",
      ex.Message));
  }
  onCompleted: () =>
  {
    Console.WriteLine("Export complete ");
  }
);

This is just touching the surface of what you’ll be able to do with the new SDK!

When can I get my hands on this?

The SDK is currently in development. It is completely open source and available for you to checkout now in our Github repository and we’re open for business to accept your pull requests!

In the coming months we’ll be shipping version 2.0, which will be available initially on NuGet and ultimately as a Xamarin Component.

We want your feedback!!!

This SDK is for you, developers using Splunk. We’d really love your experiences and input on the SDK, and if there are places we can improve.  In our next post will tell you can get even more deeply engaged in this effort.

It’s a great time for developing solutions with Splunk!

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*