python - 使用 Python 实现 StatsD/Graphite

标签 python statsd

所以我有 Etsy 的 StatsD和 Graphite 在 OS X 10.9.3 上运行。

我现在正在尝试使用 Python 来实现它们,但我不想使用 python-statsd ,因为我想在求助于库之前了解如何单独使用该技术(如果我稍后需要使用 Ruby/PHP,那么我就无法理解基 native 制了)。

即我正在尝试使用 Python 将应用程序数据发送到 StatsD,然后该数据将显示在 Graphite 中。

在我的应用程序中,我使用的是 Steve Ivy 的 python_example.py 的精确副本.

在我的代码中,我这样调用增量函数:

from statsd import StatsdClient
client = StatsdClient()
client.increment('somename.someval')

这是引发的错误:

File "/Users/bengrunfeld/Desktop/Work/code/wf-ghconsole/console/statsd.py", line 163, in send
udp_sock.sendto(":".join(item).encode('utf-8'), addr)
....
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 234, in _MakeRealSyncCall
raise pickle.loads(response_pb.exception())
RuntimeError: error('illegal IP address string passed to inet_pton',)

以下是 udp_sock.sendto 发送的值: ('somename.someval:1|c', ('localhost', 8125))

链接到我的代码:https://github.com/bengrunfeld-wf/gae-github-console/blob/statsd/console/statsd.py

最佳答案

您的代码看起来不错,但要做的第一件事是尝试在应用程序引擎之外运行代码。如果他的工作,然后确认应用程序引擎是否会执行 UDP - 如果我没记错的话,它不会 - 我上次使用应用程序引擎实现此功能时必须创建一个 http 代理。

关于python - 使用 Python 实现 StatsD/Graphite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24091497/

相关文章:

Python/opencv 在使用 self 时从 .read() 获取 ret、frame

java - RemoteServer - 如何在 Robotframework 中使用 Java 关键字?

airflow - 如何检测卡住的 Airflow 作业?

graphite - 获取准确的 Graphite stats_counts

distributed - 分布式系统的 statsd 架构

graphite - 如何跟踪 Graphite 中的活跃用户数量

Python:用空行对文件进行排序会导致错误

python - django_openid_auth TypeError openid.yadis.manager.YadisServiceManager 对象不是 JSON 可序列化的

logging - 如何设置 statsd 日志文件配置的本地路径

python - 使用 Django 模型创建子类别