public void Publishing_state_is_written_to_riemann_index() { var serviceName = "TcpClientTest#" + Guid.NewGuid(); var description = Guid.NewGuid().ToString(); var metric = DateTime.Now.Ticks; const float timeToLive = 110.5f; const string host = "tests"; var tags = new[] { "tag1", "tag2" }; IEnumerable <EventRecord> results; using (var client = new CompositeClient(maxDatagramSize: 0)) { client.Send(tags: tags, host: host, service: serviceName, state: "ok", description: description, metric: metric, ttl: timeToLive); results = client.Query(string.Format("service=\"{0}\"", serviceName)).ToList(); } Assert.That(results.Any()); Assert.That(results.Single().Host, Is.EqualTo(host)); Assert.That(results.Single().Description, Is.EqualTo(description)); Assert.That(results.Single().Service, Is.EqualTo(serviceName)); Assert.That(results.Single().State, Is.EqualTo("ok")); Assert.That(results.Single().Tags, Is.EquivalentTo(tags)); Assert.That(results.Single().metric_f, Is.EqualTo(metric)); Assert.That(results.Single().TTL, Is.EqualTo(timeToLive)); }
static void Main() { var rand = new Random(); using (var client = new CompositeClient()) { client.Send(service: "Demo Client", state: "warn", description: "Simple event description"); client.Send(new EventRecord { Host = "c#", Service = "Demo Client (1)", State = "ok", metric_f = 34.5f }, new EventRecord { Service = "Demo Client (2)", metric_f = rand.Next(100) }); var results = client.Query("service =~ \"Demo%\""); foreach (var eventRecord in results) { Console.WriteLine("Host:{0}|Service:{1}|Metric:{2}|State:{3}", eventRecord.Host, eventRecord.Service, eventRecord.metric_f, eventRecord.State); } } }