This commit is contained in:
26
InfluxDB/InfluxWriter.cs
Normal file
26
InfluxDB/InfluxWriter.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using InfluxDB.Client;
|
||||
using InfluxDB.Client.Api.Domain;
|
||||
using InfluxDB.Client.Core;
|
||||
using InfluxDB.Client.Writes;
|
||||
|
||||
namespace OutputServiceTSDB.InfluxDB
|
||||
{
|
||||
public class InfluxWriter
|
||||
{
|
||||
private readonly char[] Token = "".ToCharArray();
|
||||
|
||||
public void Write(MeasurementObject measurementObject)
|
||||
{
|
||||
var influxDBClient = InfluxDBClientFactory.Create("http://localhost:9999", Token);
|
||||
|
||||
using (var writeApi = influxDBClient.GetWriteApi())
|
||||
{
|
||||
var measurement = new MeasurementObject { DeviceID = "south", Probability = 0.5, Time = DateTime.UtcNow };
|
||||
writeApi.WriteMeasurement("bucket_name", "org_id", WritePrecision.Ns, measurement);
|
||||
}
|
||||
|
||||
influxDBClient.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user