Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bosun adding external collectors

Tags:

go

bosun

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

like image 496
Sandesh Avatar asked Aug 05 '15 13:08

Sandesh


2 Answers

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:

<external_collectors_dir>/<freq_sec>/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

like image 152
Kyle Brandt Avatar answered Sep 30 '22 14:09

Kyle Brandt


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:

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

And you can also send metadata:

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

Or send error messages to stderror:

2015/08/05 15:32:00 lookup OR-SQL03: no such host
like image 26
captncraig Avatar answered Sep 30 '22 12:09

captncraig