Python 2.x
How to send metrics using Python
Interesting Python Graphite Libraries
Sending a metric via TCP
import socket
conn = socket.create_connection(("YOUR-UID.carbon.hostedgraphite.com", 2003))
conn.send("YOUR-API-KEY.foo.py-tcp 1.2\n")
conn.close()Sending a metric via UDP
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto("YOUR-API-KEY.foo.py-udp 1.2\n", ("YOUR-UID.carbon.hostedgraphite.com", 2003))Sending a metric using HTTP POST
import urllib2, base64
url = "https://www.hostedgraphite.com/api/v1/sink"
api_key = "YOUR-API-KEY"
request = urllib2.Request(url, "foo.py-http 1.2")
request.add_header("Authorization", "Basic %s" % base64.encodestring(api_key).strip())
result = urllib2.urlopen(request)Sending a metric via TCP over TLS tunnel
Python 3.x
Sending a metric via TCP
Sending a metric via UDP
Sending a metric using HTTP POST
Sending a metric via TCP over TLS tunnel
Sending a metric via StatsD
Last updated