HTTPDataCollectorAPI

Azure Log Analytics HTTP DataCollector API wrapper


Keywords
azure, log, analytics, azure-log-analytics, log-collector, oms
License
Apache-2.0
Install
Install-Package HTTPDataCollectorAPI -Version 1.0.5

Documentation

Azure Log Analytics HTTP Collector API wrapper

This package is a .Net adaptation of the Powershell code for implementing the HTTP Collector API for Azure Log Analytics as seen on the announcement.

Full API Documentation

Get it

You can obtain this project as a Nuget Package.

Install-Package HTTPDataCollectorAPI

Or reference it and use it according to the License.

Use it

Using it is simple:

var collector = new  HTTPDataCollectorAPI.Collector("{Your_Workspace_Id}", "{Your_Workspace_Key}");
await collector.Collect("TestLogType", "{\"TestAttribute\":\"TestValue\"}");

You can also pass serializable objects (they will be serialized with Newtonsoft.Json):

var anObject = new MySerializableClass(){
  MyIntAttribute = 4,
  MyStringAttribute = "hello",
  MyListAttribute = new List<string>(){"one","two"}
};
var collector = new  HTTPDataCollectorAPI.Collector("{Your_Workspace_Id}", "{Your_Workspace_Key}");
await collector.Collect("TestLogType", anObject);

If you are using a Depedency Injection mechanism (or ASP.NET Core) you can use the available interface. In ASP.NET Core for example:

public void ConfigureServices(IServiceCollection services)
{
  //... some other code
  services.AddSingleton<HTTPDataCollectorAPI.ICollector, HTTPDataCollectorAPI.Collector>();
}

Does it work on Azure Gov clouds?

Yes, just use the constructor overload to define the cloud service endpoint:

var collector = new  HTTPDataCollectorAPI.Collector("{Your_Workspace_Id}", "{Your_Workspace_Key}", "ods.opinsights.azure.us");

Issues

Please feel free to report any issues you might encounter. Keep in mind that this library won't assure that your JSON payloads are being indexed, it will make sure that the HTTP Data Collection API responds an Accept but there is no way (right now) to know when has the payload been indexed completely.

Supported Frameworks