AIOGraphite

AIOGraphite is a Graphite client class, ultilizing asyncio, designed to help Graphite users to send data into graphite easily.

from aiographite.aiographite import connect

"""
  Initialize a aiographite instance
"""
loop = asyncio.get_event_loop()
plaintext_protocol = PlaintextProtocol()
graphite_conn = await aiographite.connect(*httpd.address, plaintext_protocol, loop=loop)


"""
  Send a tuple (metric, value , timestamp)
"""
graphite_conn.send(metric, value, timestamp)


"""
  Send a list of tuples List[(metric, value , timestamp)]
"""
graphite_conn.send_multiple(list)


"""
  aiographite library also provides GraphiteEncoder module,
  which helps users to send valid metric name to graphite.
  For Example: (metric_parts, value ,timestamp)
"""
metric = graphite_conn.clean_and_join_metric_parts(metric_parts)
graphite_conn.send(metric, value, timestamp)


"""
  Close connection
"""
graphite_conn.close()

Full API Reference

class aiographite.aiographite.AIOGraphite(graphite_server, graphite_port=2003, protocol=<aiographite.protocol.PlaintextProtocol object>, loop=None)[source]

AIOGraphite is a Graphite client class, ultilizing asyncio, designed to help Graphite users to send data into graphite easily.

clean_and_join_metric_parts(metric_parts: typing.List) → str[source]

This method helps encode any input metric to valid metric for graphite in case that the metric name includes any special character which is not supported by Graphite.

args: a list of metric parts(string).

returns a valid metric name for graphite.

example:

metric = aiographite.clean_and_join_metric_parts(metric_parts)
close() → None[source]

Close the TCP connection to graphite server.

send(metric: str, value: int, timestamp: int=None) → None[source]

send a single metric.

args: metric, value, timestamp. (str, int, int).

send_multiple(dataset: typing.List, timestamp: int=None) → None[source]

send a list of tuples.

args: a list of tuples (metric, value, timestamp), and timestamp is optional.