Skip to main content

UNKNOWN

Project description

build status

An asyncio library for graphite.

What is aiographite ?

aiographite is Python3 library ultilizing asyncio, designed to help Graphite users to send data into graphite easily.

Installing it globally

You can install aiographite globally with any Python package manager:

pip install aiographite

Quick start

Let’s get started.

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


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


"""
  Send a list of tuples List[(metric, value , timestamp)]
"""
aiographite.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 = aiographite.clean_and_join_metric_parts(metric_parts)
aiographite.send(metric, value, timestamp)

Example

A simple example.

from aiographite.protocol import PlaintextProtocol
from aiographite.aiographite import AIOGraphite
import time
import asyncio


LOOP = asyncio.get_event_loop()
SERVER = '127.0.0.1'
PORT = 2003


def test_send_data():
  # Initiazlize an aiographite instance
  plaintext_protocol = PlaintextProtocol()
  aiographite_instance = AIOGraphite(SERVER, PORT, plaintext_protocol, loop = LOOP)

  # Connect to graphite server
  LOOP.run_until_complete(aiographite_instance.connect())

  # Send data
  tasks = []
  timestamp = time.time()
  for i in range(10):
    tasks.append(asyncio.ensure_future(aiographite_instance.send("yun_test.aiographite", i, timestamp + 60 * i)))
  LOOP.run_until_complete(asyncio.gather(*tasks))
  LOOP.close()


def main():
  test_send_data()


if __name__ == '__main__':
  main()

Graphite setup

Do not have graphite instances ? Set up a graphite instance on your local machine!

Please refer:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiographite-0.1.3.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

aiographite-0.1.3-py2.py3-none-any.whl (10.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file aiographite-0.1.3.tar.gz.

File metadata

File hashes

Hashes for aiographite-0.1.3.tar.gz
Algorithm Hash digest
SHA256 224db6181918deae2cfc8e4962edbeed789e46e2230d0beb320a04a52126b56b
MD5 e9f5b6e0c5a17153039cc29c3029b22b
BLAKE2b-256 8ffa31e35b7b65567556b2c1ff9bbdf49b4e0c4ddb21c111f0bd70b85885bf59

See more details on using hashes here.

Provenance

File details

Details for the file aiographite-0.1.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for aiographite-0.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6fda1d3e08f21582ac659484e4da5f8be6f8e11cc520915b5dd3aa13b1cf7774
MD5 2ffa97df9bc0ba1b0552379ab7bf5e0f
BLAKE2b-256 351b4bacc49c962994e1241a0457dff4544de0c6f9e30b65623f6a657cec3fa2

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page