influxdata / influxdb-csharp

A .NET library for efficiently sending points to InfluxDB 1.x
Apache License 2.0
199 stars 60 forks source link

Request: Add method to get a formated string #66

Closed antonkolb closed 5 years ago

antonkolb commented 5 years ago

I would like to request a simple feature:
It should be possible to transform a point into a string, which follows the line protocol ' e.g. "cpu,dev=cpu0 temp=4,var1="bla",var2="miep" 1540900454326481400"

Our situation: We are communicating with Telegraf and use currently the Line Protocol. We generate the string ourselves including the handling of special characters. I hoped, that with this library we could save the additional work, as you guys have to generate an Inline String somewhere in the process eventually anyway.

gambrose commented 5 years ago

You can use the LineProtocolWriter to help write out correct line protocol.

See LineProtocolWriterTests for usage examples.

Does this help you at all?

antonkolb commented 5 years ago

This could be, what I was looking for. Let me try it later and I will come back you!

antonkolb commented 5 years ago

Yes! It escapes and generates the string. Merci!

Sorry for the bother, but I couldn't read the information out of the documentation and find a method that returns string, so I assumed what I want doesn't exist.

gambrose commented 5 years ago

Yeah, I wrote it as I was wanted something that would produce valid line protocol without having to allocation lots of objects. I created the pull request to get it merged in here, as it seamed the most appropriate place, but I never got round to writing any documentation.

Anyways I'm glad you are able to use it to do what you need to do.