Skip to content

Instantly share code, notes, and snippets.

@trondhindenes
Created August 14, 2016 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trondhindenes/46096c6054a67e8b29377300ffb74345 to your computer and use it in GitHub Desktop.
Save trondhindenes/46096c6054a67e8b29377300ffb74345 to your computer and use it in GitHub Desktop.
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Net;
public static void Run(string myEventHubMessage, TraceWriter log)
{
String data = myEventHubMessage;
log.Info($"C# Event Hub trigger function processed a message: {data}");
data = data.Replace("http://schemas.microsoft.com", "");
data = data.Replace("http://schemas.xmlsoap.org", "");
JToken token = JObject.Parse(data);
//var parsedData = format_json(data);
string url = "http://<my_logstash_server>";
foreach (var record in token.SelectToken("records"))
{
Console.WriteLine("record:--------------------------------------------------------------------");
Console.WriteLine(record.ToString());
string result = ",";
using (var client = new WebClient())
{
client.Headers[HttpRequestHeader.ContentType] = "application/json";
result = client.UploadString(url, "POST", record.ToString());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment