public void DefaultIndexArgs() { string indexName = "main"; DateTimeOffset offset = new DateTimeOffset(DateTime.Now); string now = DateTime.UtcNow.ToString("yyyy-MM-dd'T'HH:mm:ss") + string.Format("{0}{1} ", offset.Offset.Hours.ToString("D2"), offset.Offset.Minutes.ToString("D2")); Service service = this.Connect(); Receiver receiver = service.GetReceiver(); Index index = service.GetIndexes().Get(indexName); index.Enable(); Assert.IsFalse(index.IsDisabled); Args indexProperties = GetIndexProperties(index); // submit event to default index using variable arguments receiver.Log(indexProperties, "Hello World. \u0150"); receiver.Log(indexProperties, "Goodbye World. \u0150"); // stream event to default index with variable arguments Stream streamArgs = receiver.Attach(indexProperties); streamArgs.Write(Encoding.UTF8.GetBytes(" Hello World again. \u0150\r\n")); streamArgs.Write(Encoding.UTF8.GetBytes(" Goodbye World again.\u0150\r\n")); streamArgs.Close(); }
/// <summary> /// Emit a batch of log events, running to completion synchronously. /// </summary> /// <param name="events">The events to emit.</param> protected override void EmitBatch(IEnumerable <LogEvent> events) { _service.Login(_connectionInfo.Username, _connectionInfo.Password); var receiver = new Receiver(_service); receiver.Attach(_receiveSubmitArgs); foreach (var logEvent in events) { var data = new { logEvent.Timestamp, logEvent.Level, Data = logEvent.RenderMessage() }; var json = JsonConvert.SerializeObject(data, new StringEnumConverter()); receiver.Log(json); } }
protected override void EmitBatch(IEnumerable <LogEvent> events) { //TODO: Create formatter possibly format with following //TODO: Investigate AsynEmit _service.Login(_connectionInfo.UserName, _connectionInfo.Password); var receiver = new Receiver(_service); receiver.Attach(_receiveSubmitArgs); foreach (var logEvent in events) { dynamic data = new { Timestamp = logEvent.Timestamp, Level = logEvent.Level, Data = logEvent.RenderMessage() }; var json = Newtonsoft.Json.JsonConvert.SerializeObject(data, new Newtonsoft.Json.Converters.StringEnumConverter()); receiver.Log(json); } }
public bool OpenStream(string index = "main", string host = "localhost", string source = "dynaTrace", string sourcetype = "dynatrace/xml") { if (!connected) { return(false); } Receiver splunkReceiver = new Receiver(service); var args = new Args(); args.Add("host", host); args.Add("source", source); args.Add("sourcetype", sourcetype); iStream = splunkReceiver.Attach("main", args); Console.WriteLine("Opened Input Stream"); return(true); }