在 Windows 环境中使用 Etsy 的 StatsD

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5436606/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:30:15  来源:igfitidea点击:

Using Etsy's StatsD in a Windows Environment

c#.netwindowsgraphite

提问by Christopher

What will I need to use Etsy's Statsdin a Windows Environment? My intentions are to create a .net client to use Statsd.

在 Windows 环境中使用 Etsy 的Statsd需要什么?我的意图是创建一个 .net 客户端来使用 Statsd。

采纳答案by bbrown

Your best bet is to have a Linux server with statsd and Graphite installed. You would then just need to write some C# code to make the UDP call to get the metric into the system.

最好的办法是安装一台装有 statsd 和 Graphite 的 Linux 服务器。然后,您只需要编写一些 C# 代码来进行 UDP 调用,从而将指标输入系统。

[UPDATE (6/23/2014): I came across a statsd/Graphite clone called statsd.netthat looks promising but largely lacking on the Graphite side of the equation. I still think the best bet is to use the actual statsd/Graphite projects since any clone is necessary playing catch-up.]

[更新(2014 年 6 月 23 日):我遇到了一个名为statsd.net的 statsd/Graphite 克隆,它看起来很有希望,但在等式的 Graphite 方面基本上缺乏。我仍然认为最好的选择是使用实际的 statsd/Graphite 项目,因为任何克隆都是必要的。]

回答by fiat

I have statsd+graphite running in my Windows environment using the C# client NStatsD.

我使用 C# 客户端NStatsD在我的 Windows 环境中运行 statsd+graphite 。

Here are my notes for getting the Linux VM setup:

以下是我获取 Linux VM 设置的注意事项:

Note: I know enough Linux to be dangerous but am otherwise a noob and could be doing something unwittingly horrible.

注意:我知道足够多的 Linux 是危险的,但在其他方面我是个菜鸟,可能会在不知不觉中做一些可怕的事情。

  1. Install Ubuntu Server 12.04. I used VirtualBox for dev and then later EC2 for prod.
  2. Download graphite-fabricto your home folder. This is a script that will download, compile and install graphite and statsd. It expects a clean box and uses nginx for the web server.

    sudo apt-get install git

    git clone git://github.com/gingerlime/graphite-fabric.git

    cd graphite-fabric/

  3. Install prereq's for fabric

    sudo apt-get install python-setuptools

  4. The next steps are a download, compile and install which can take some time. It is worthwhile setting a keep alive on any putty ssh session before continuing.

  5. Now install as per gingerlime's instructions in the README.md - including the requirements section.

  6. Install statsd as per gingerlime's instructions.
  7. Reboot
  8. Execute netstat -nulpand observe 8125 is in use to confirm statsd is listening.
  9. Check carbon is running tail /opt/graphite/storage/log/carbon-cache/carbon-cache-a/listener.log. If it isn't, try sudo /etc/init.d/carbon start
  1. 安装 Ubuntu 服务器 12.04。我使用 VirtualBox 进行开发,然后使用 EC2 进行生产。
  2. 石墨织物下载到您的主文件夹。这是一个将下载、编译和安装graphite 和statsd 的脚本。它需要一个干净的盒子,并使用 nginx 作为 Web 服务器。

    sudo apt-get install git

    git clone git://github.com/gingerlime/graphite-fabric.git

    cd graphite-fabric/

  3. 为织物安装先决条件

    sudo apt-get install python-setuptools

  4. 接下来的步骤是下载、编译和安装,这可能需要一些时间。在继续之前,值得在任何腻子 ssh 会话上设置保持活动状态。

  5. 现在按照 README.md 中姜酸的说明进行安装 - 包括要求部分。

  6. 按照gingerlime 的说明安装statsd。
  7. 重启
  8. 执行netstat -nulp并观察 8125 正在使用以确认 statsd 正在侦听。
  9. 检查碳是否正在运行tail /opt/graphite/storage/log/carbon-cache/carbon-cache-a/listener.log。如果不是,请尝试sudo /etc/init.d/carbon start

Now you have your server running, try throwing some counters at it with the NStatsDclient.

现在您的服务器正在运行,请尝试使用NStatsD客户端向其抛出一些计数器。

Timezone fix:

时区修复

This will fix graphite to graph times in your local zone

这会将石墨固定到您当地区域的图表时间

  1. cd /opt/graphite/webapp/graphite
  2. sudo cp local_settings.py.example local_settings.py
  3. sudo chown www-data:www-data local_settings.py(check with ls -lthat permissions look right)
  4. sudo pico local_settings.pySet TIME_ZONE to something like Australia/Sydney. Discover what timezones you can use in /usr/share/zoneinfo/
  5. Save and restart the box (not sure how to make it pick up the change without restart)
  1. cd /opt/graphite/webapp/graphite
  2. sudo cp local_settings.py.example local_settings.py
  3. sudo chown www-data:www-data local_settings.py(检查ls -l权限是否正确)
  4. sudo pico local_settings.py将 TIME_ZONE 设置为类似Australia/Sydney. 了解您可以在哪些时区中使用/usr/share/zoneinfo/
  5. 保存并重新启动该框(不知道如何让它在不重新启动的情况下进行更改)

EC2 Notes

EC2 笔记

root is disabled on EC2. Fabric prompts for a root password which you don't have. Use the -i keyfileargument with fab to give it your ssh keyfile instead.

在 EC2 上禁用 root。Fabric 会提示您输入您没有的 root 密码。使用-i keyfile带有 fab的参数来代替给它你的 ssh 密钥文件。

VirtualBox Notes

VirtualBox 笔记

VBoxVMServicewas handy to automatically run the VM as a service in my Windows dev environment.

VBoxVMService可以方便地在我的 Windows 开发环境中自动将 VM 作为服务运行。

回答by user141682

TL;DR:

特尔;博士:

  • statsd.netis a scalable statsd clone with lots of cool extras, and designed for windows-centric environments. First production release is on the 29th of May, 2013
  • statsd-csharp-clientis a lightweight statsd and statsd.net client, available for .net 3.5, 4.0 and 4.5 via nuget.
  • statsd.net是一个可扩展的 statsd 克隆,具有许多很酷的附加功能,专为以 Windows 为中心的环境而设计。第一个生产版本是在 2013 年 5 月 29 日
  • statsd-csharp-client是一个轻量级的 statsd 和 statsd.net 客户端,可通过 nuget 用于 .net 3.5、4.0 和 4.5。

Full Disclosure: I'm the author of these two projects and I wrote them because I couldn't take etsy's statsd service to production - my organisation isn't ready to deploy and support nodejs-based services.

完全披露:我是这两个项目的作者,我编写它们是因为我无法将 etsy 的 statsd 服务投入生产——我的组织还没有准备好部署和支持基于 nodejs 的服务。

I had the same problem in my organisation - we're a windows-centric environment that wants to collect stats from all over the world into a single graphite repository. I had initially thought of using etsy's statsd but my company is not yet ready to roll with nodejs services in production. Along the way I found that having my own aggregation service meant I can do lots of interesting things like add memcached support for scalability, add new aggregators and so on.

我在我的组织中遇到了同样的问题——我们是一个以 Windows 为中心的环境,想要将来自世界各地的统计数据收集到一个单一的石墨存储库中。我最初想使用 etsy 的 statsd,但我的公司还没有准备好在生产中使用 nodejs 服务。在此过程中,我发现拥有自己的聚合服务意味着我可以做很多有趣的事情,例如为可扩展性添加 memcached 支持、添加新的聚合器等等。

The service is usable in console mode right now, and will be ready for production use from the 29th of May 2013 onwards.

该服务现在可以在控制台模式下使用,并将从 2013 年 5 月 29 日起准备用于生产。

回答by Anton Gogolev

We've re-built Graphite/StatsD in pure .NET. It is currently being used in production environment, processing around 600M datapoints daily.

我们在纯 .NET 中重新构建了 Graphite/StatsD。它目前正在生产环境中使用,每天处理大约 6 亿个数据点。

Statsify:

统计

enter image description here

在此处输入图片说明

回答by Leonmax

There is quite a few open-source StatsD client implementations available in different Language including C#.NET. Etsy provide one on their github examples, also check out AppFirst version of statsd_clients.

有相当多的开源 StatsD 客户端实现可用于不同的语言,包括 C#.NET。Etsy的提供一个对他们的github上的例子,还检查出的AppFirst版本statsd_clients

回答by Alexey Zimarev

Current statsd and nodejs versions allow you to run statsd on Windows without amendments. statsd package.json file already contains scripts to install and uninstall it as Windows service.

当前的 statsd 和 nodejs 版本允许您无需修改​​即可在 Windows 上运行 statsd。statsd package.json 文件已经包含脚本来安装和卸载它作为 Windows 服务。

The installation procedure would be:

安装过程如下:

  • Install nodejs for Windows
  • Create a directory like C:\StatsD
  • Open a console window and do cd \StatsD
  • Then do npm install https://github.com/etsy/statsd.git
  • In node_modules\statsddirectory create your own config.json
  • In the console window do cd node_modules\statsdand npm run-script install-windows-service
  • 为 Windows安装nodejs
  • 创建一个目录,如 C:\StatsD
  • 打开控制台窗口并执行 cd \StatsD
  • 然后做 npm install https://github.com/etsy/statsd.git
  • node_modules\statsd目录中创建自己的config.json
  • 在控制台窗口中执行cd node_modules\statsdnpm run-script install-windows-service

However, Graphite only runs on Linux.

但是,Graphite 只能在 Linux 上运行。

回答by Anthony

You need a statsd server to connect to.
You also need a client library to connect to it, e.g. this oneand the nuget packageof it.

您需要一个 statsd 服务器来连接。
您还需要一个客户端库来连接到它,例如这个和它的 nuget 包