Question

I am trying to use python socket instead of netcat to send metric data to OpenTSDB, but got no luck. Can anybody let me know if it is possible to do so?

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("hostname", port))
s.send("put foo 123456789 12.9 host=dummy")

s.send(...) returns a nonzero value, so I guess the string was indeed sent, it is just that OpenTSDB does not recognize it. I tried to use netcat to send the same string, and it works.

Was it helpful?

Solution

OpenTSDB parses line-by-line, so yes you need a \n at the end of the string you're sending.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top