Bosun添加外部收集器

huangapple go评论95阅读模式
英文:

Bosun adding external collectors

问题

在Bosun中使用scollector定义新的外部收集器的步骤是什么?我们可以编写Python或Shell脚本来收集数据吗?

英文:

What is the procedure to define new external collectors in bosun using scollector.<br>
Can we write python or shell scripts to collect data?

答案1

得分: 7

关于这个问题的文档并不是最新的。你可以按照http://godoc.org/bosun.org/cmd/scollector#hdr-External_Collectors中描述的方式进行操作,但我们也支持更好的JSON输出。

无论哪种方式,你需要编写一个脚本或二进制文件,并将其放置在外部收集器目录中,然后是一个频率目录,类似这样的结构:

<external_collectors_dir>/<freq_sec>/foo.sh

如果频率目录为零0,则脚本应该持续运行,并在代码中加入一个sleep语句(这是我首选的外部收集器方法)。脚本将输出Telnet格式或未记录的JSON格式到stdout。Scollector会捕获这些信息并将其排队发送。

我不久前创建了一个问题,以便将其记录下来:https://github.com/bosun-monitor/bosun/issues/1225。在我们有空处理之前,这是添加JSON的PR:https://github.com/bosun-monitor/bosun/commit/fced1642fd260bf6afa8cba169d84c60f2e23e92。

英文:

The documentation around this is not quite up to date. You can do it as described in http://godoc.org/bosun.org/cmd/scollector#hdr-External_Collectors , but we also support JSON output which is better.

Either way, you write something and put it in the external collectors directory, followed by a frequency directory, and then an executable script or binary. Something like:

&lt;external_collectors_dir&gt;/&lt;freq_sec&gt;/foo.sh.

If the directory frequency is zero 0, then the the script is expected to be continuously running, and you put a sleep inside the code (This is my preferred method for external collectors). The scripts outputs the telnet format, or the undocumented JSON format to stdout. Scollector picks it up, and queues that information for sending.

I created an issue to get this documented not long ago https://github.com/bosun-monitor/bosun/issues/1225. Until one of us gets around to that, here is the PR that added JSON https://github.com/bosun-monitor/bosun/commit/fced1642fd260bf6afa8cba169d84c60f2e23e92

答案2

得分: 2

根据Kyle的说法,你可以查看一些现有的外部收集器,看看它们的输出。这里是一个用Java编写的示例,我们的一位同事编写了它来监控JVM相关的内容。它使用文本格式,格式如下:

metricname timestamp value tag1=foo tag2=bar

如果你想使用JSON格式,这里有一个我们的收集器的示例:

{&quot;metric&quot;:&quot;exceptional.exceptions.count&quot;,&quot;timestamp&quot;:1438788720,&quot;value&quot;:0,&quot;tags&quot;:{&quot;application&quot;:&quot;AdServer&quot;,&quot;machine&quot;:&quot;ny-web03&quot;,&quot;source&quot;:&quot;NY_Status&quot;}}

你还可以发送元数据:

{&quot;Metric&quot;:&quot;exceptional.exceptions.count&quot;,&quot;Name&quot;:&quot;rate&quot;,&quot;Value&quot;:&quot;counter&quot;}
{&quot;Metric&quot;:&quot;exceptional.exceptions.count&quot;,&quot;Name&quot;:&quot;unit&quot;,&quot;Value&quot;:&quot;errors&quot;}
{&quot;Metric&quot;:&quot;exceptional.exceptions.count&quot;,&quot;Name&quot;:&quot;desc&quot;,&quot;Value&quot;:&quot;每秒应用程序和机器抛出的异常数量。数据从多个来源查询。有关异常的详细信息,请参阅状态实例。&quot;}`

或者将错误消息发送到标准错误输出:

2015/08/05 15:32:00 lookup OR-SQL03: no such host
英文:

Adding to what Kyle said, you can take a look at some existing external collectors to see what they output. here is one written in java that one of our colleagues wrote to monitor jvm stuff. It uses the text format, which is simply:

metricname timestamp value tag1=foo tag2=bar

If you want to use the JSON format, here is an example from one of our collectors:

{&quot;metric&quot;:&quot;exceptional.exceptions.count&quot;,&quot;timestamp&quot;:1438788720,&quot;value&quot;:0,&quot;tags&quot;:{&quot;application&quot;:&quot;AdServer&quot;,&quot;machine&quot;:&quot;ny-web03&quot;,&quot;source&quot;:&quot;NY_Status&quot;}}

And you can also send metadata:

{&quot;Metric&quot;:&quot;exceptional.exceptions.count&quot;,&quot;Name&quot;:&quot;rate&quot;,&quot;Value&quot;:&quot;counter&quot;}
{&quot;Metric&quot;:&quot;exceptional.exceptions.count&quot;,&quot;Name&quot;:&quot;unit&quot;,&quot;Value&quot;:&quot;errors&quot;}
{&quot;Metric&quot;:&quot;exceptional.exceptions.count&quot;,&quot;Name&quot;:&quot;desc&quot;,&quot;Value&quot;:&quot;The number of exceptions thrown per second by applications and machines. Data is queried from multiple sources. See status instances for details on exceptions.&quot;}`

Or send error messages to stderror:

2015/08/05 15:32:00 lookup OR-SQL03: no such host

huangapple
  • 本文由 发表于 2015年8月5日 21:55:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/31834586.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定