Proper Method for Writing Points
In your Readme.md you have a section demonstrating how to Write Points using a Serie builder. I assume this should have been Series but it appears this was carried over form the previous repo.
Write
var _client = new InfluxDb("http://...:8086", "root", "root");
Serie serie = new Serie.Builder("testSeries")
.Columns("value1", "value2")
.Values(DateTime.Now.Millisecond, 5)
.Build();
InfluxDbApiResponse writeResponse =await _client.WriteAsync("MyDb", TimeUnit.Milliseconds, serie);
However, it appears from exploring your definition that you should instead be writing a single point or an Array of point
Can you please comment on the proper way to write single points and or bulk points. It seems the method of adding a single point or an array of points is much cleaner and more manageable.
Hi,
yes, I didn't have the time yet to rework the docs (up until a few days ago I was mostly into refactoring only as I forked the library only very recently). I would assume you're using the nuget version are you, and not this latest dev version?
For the NuGet version (2.0.2), this is essentially how I do it currently in the project where I use the library (I have this scattered through a few wrapper functions of course, but this part of the code is relevant to you):
var influxDbClient = new InfluxDb(_influxDbUri, _influxDbUserName, _influxDbPassword, InfluxVersion.v095);
var point = BuildReadingPoint(someReadingDto);
var points = someReadingsDtoList.Select(p => BuildReadingPoint(p));
// in 2.0.2 there are two overloads for writing data, so you can use whatever you need
var pointResult = await influxDbClient.WriteAsync("SomeDbName", point);
var pointsResult = await influxDbClient.WriteAsync("SomeDbName", points);
Where BuildReadingPoint is something like this:
public Point BuildReadingPoint(ReadingMessageDTO dto)
{
return new Point()
{
Name = "reading",
Tags = new Dictionary<string, object>()
{
{ "SensorId", dto.SensorId },
{ "SerialNumber", dto.SerialNumber }
},
Fields = new Dictionary<string, object>()
{
{ "RawMessage", dto.RawMessage },
{ "Humidity", dto.Humidity },
{ "Temperature", dto.Temperature },
{ "Resistance", dto.Resistance }
},
Timestamp = dto.DateCreated
};
}
I'll most probably update the library this weekend (it will have a few small breaking changes, but nothing much, should be very easy to update). And then I'll also prepare the docs to go with that as well.
Let me know if that worked for you, and if you need any additional help, feel free to ask. :)
Great, thanks! I'm using it with the points method and it works really well. I'll be posting a video soon showing a cool store/forward feature I have in my app I'm building. May be something you would want to build into the library. I think you could make a solid debate either way though.
No problem, I'm glad it works well. :)
Sure, when it's ready, open a new issue and explain what you mean by this, you can link your video also. Perhaps provide a short code sample of what you would like it to do as well.