public async void Query_DB_Test() { string dbName = GetNewDbName(); InfluxDbApiCreateResponse createResponse = await _db.CreateDatabaseAsync(dbName); const string TmpSerieName = "testSeries"; Serie serie = new Serie.Builder(TmpSerieName) .Columns("value1", "value2") .Values(DateTime.Now.Millisecond, 5) .Build(); InfluxDbApiResponse writeResponse = await _db.WriteAsync(dbName, TimeUnit.Milliseconds, serie); List <Serie> series = await _db.QueryAsync(dbName, string.Format("select * from {0}", TmpSerieName), TimeUnit.Milliseconds); InfluxDbApiDeleteResponse deleteResponse = await _db.DeleteDatabaseAsync(dbName); series.Should().NotBeNull(); series.Count.Should().Be(1); createResponse.Success.Should().BeTrue(); writeResponse.Success.Should().BeTrue(); deleteResponse.Success.Should().BeTrue(); }
/// <summary> /// /// </summary> /// <returns></returns> public InfluxDbApiResponse Write() { Serie serie = new Serie.Builder(seriesName) .Columns(columns) .Values(values) .Build(); InfluxDbApiResponse writeResponse = dbConnection.WriteAsync(dbName, TimeUnit.Milliseconds, serie).Result; return(writeResponse); }
public async void Write_DB_Test() { string dbName = GetNewDbName(); InfluxDbApiCreateResponse createResponse = await _db.CreateDatabaseAsync(dbName); Serie serie = new Serie.Builder("testSeries") .Columns("value1", "value2") .Values(DateTime.Now.Millisecond, 5) .Build(); InfluxDbApiResponse writeResponse = await _db.WriteAsync(dbName, TimeUnit.Milliseconds, serie); InfluxDbApiDeleteResponse deleteResponse = await _db.DeleteDatabaseAsync(dbName); createResponse.Success.Should().BeTrue(); writeResponse.Success.Should().BeTrue(); deleteResponse.Success.Should().BeTrue(); }
public override Result Process(Result result) { if (!result.EventTimeStamp.HasValue) { return(result); } var t = result.EventTimeStamp.Value - new DateTime(1970, 1, 1); var secondsSinceEpoch = (long)t.TotalMilliseconds; var _client = new InfluxDb("http://192.168.33.101:8086", "root", "root"); Serie serie = new Serie.Builder("iislog") .Columns("FruitName", "Quantity", "time") .Values(result.Json.Value <string>("FruitName").ToString(), result.Json.Value <string>("Quantity"), secondsSinceEpoch) .Build(); Task.Run(() => _client.WriteAsync("graphana", TimeUnit.Milliseconds, serie)); return(result); }
private static async Task WriteInfluxDb(List <Metric> metricList) { // convert metriclist to lists(s) that is optimal for influxdb //foreach influxdbmetric do sent it to influxdb var connect = new InfluxDb(@"http://influxdb.jollyrogers.nl:8086", "tessup", "tessup"); foreach (var m in metricList) { var payload = new Serie.Builder(m.ObjectName).Columns(m.ValueName).Values(m.Values).Build(); try { await connect.WriteAsync(m.TargetName, TimeUnit.Milliseconds, payload); } catch (Exception ex) { MyLogger.Warning(string.Format("Sending metric to influxdb failed: " + ex.InnerException.Message)); } MetricHandlerEvent.MetricEvent -= WriteInfluxDb; return; } }