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


async def send_data(metric, timestamp, value):
  plaintext_protocol = PlaintextProtocol()
  aiographite_instance = AIOGraphite(SERVER, PORT, plaintext_protocol, loop = LOOP)
  await aiographite_instance.connect()
  await aiographite_instance.send(metric, value, timestamp)


def main():
  tasks = []
  timestamp = int(time.time())
  for i in range(10):
    tasks.append(asyncio.ensure_future(send_data("yun_test.aiographite", timestamp + 60 * i, i)))
  LOOP.run_until_complete(asyncio.gather(*tasks))
  LOOP.close()

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.2.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: aiographite-0.1.2.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aiographite-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b231c525859b3fc7343f54f16fbc57dc58ffd0aee32a535ec8ed3a0ac68231f1
MD5 419a5503bab3ef94584276e6a86dc7fb
BLAKE2b-256 0cc5a0a4f1da97506d64fc45b35146f0e20c9c7f3c1f9f8438c44f01935f68e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aiographite-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 84a21582dd15b71abc40aa43ab5d776459e6ee3ad6255eb293cfd2aaf3af0b70
MD5 2ec3f17a03f0a0ad9317bd35876d7976
BLAKE2b-256 cf5c1c0bac2073bd3201ffc7dfac494392a83367b7d217c72db2764c05fd6570

See more details on using hashes here.

Supported by

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