未提供项目描述
项目描述
An asyncio library for graphite.
你可以在以下链接中了解更多信息
http://aiographite.readthedocs.io/en/latest/
什么是aiographite?
aiographite是一个利用asyncio设计的Python3库,旨在帮助Graphite用户轻松将数据发送到Graphite。
全局安装
你可以使用任何Python包管理器全局安装aiographite
pip install aiographite
快速入门
让我们开始吧。
from aiographite import connect
from aiographite.protocol import PlaintextProtocol
"""
Initialize a aiographite instance
"""
loop = asyncio.get_event_loop()
plaintext_protocol = PlaintextProtocol()
graphite_conn = await connect(*httpd.address, plaintext_protocol, loop=loop)
"""
Send a tuple (metric, value , timestamp)
"""
await graphite_conn.send(metric, value, timestamp)
"""
Send a list of tuples List[(metric, value , timestamp)]
"""
await 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)
await graphite_conn.send(metric, value, timestamp)
"""
Close connection
"""
await graphite_conn.close()
示例
一个简单的示例。
from aiographite.protocol import PlaintextProtocol
from aiographite import connect
import time
import asyncio
LOOP = asyncio.get_event_loop()
SERVER = '127.0.0.1'
PORT = 2003
async def test_send_data():
# Initiazlize an aiographite instance
plaintext_protocol = PlaintextProtocol()
graphite_conn = await connect(SERVER, PORT, plaintext_protocol, loop=LOOP)
# Send data
timestamp = time.time()
for i in range(10):
await graphite_conn.send("yun_test.aiographite", i, timestamp + 60 * i)))
def main():
LOOP.run_until_complete(test_send_data())
LOOP.close()
if __name__ == '__main__':
main()
开发
运行单元测试。
./uranium test
Graphite配置
没有Graphite实例?在你的本地机器上设置一个Graphite实例!
请参考
项目详情
下载文件
下载适合您平台的项目文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分发
aiographite-0.2.0.tar.gz (8.7 kB 查看哈希值)
构建分发
aiographite-0.2.0-py3-none-any.whl (10.8 kB 查看哈希值)
关闭
aiographite-0.2.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 9016e91929c37693ff21100eda917b37ec4d435ea230dd8913c2a2f8e75bb613 |
|
MD5 | 9b70e58b82cf727cc9711ca57122ffd2 |
|
BLAKE2b-256 | 1b731163c4ce2679a590dc9248c2baf6ed982494383db6423f94103311592672 |
关闭
aiographite-0.2.0-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 10386908c964213266fcc98a2e0781925bce1c35a261740402dbb425f90a762d |
|
MD5 | 97e29dab445a4556630844f8df98efac |
|
BLAKE2b-256 | 6d015142990e5b05386219ab4c93633a7abc43383a3f882c4f3c6af1e9515413 |