Giter Club home page Giter Club logo

statsd-zabbix-backend's Introduction

StatsD Zabbix backend Build Status

Backend for StatsD to publish stats to Zabbix.

Table of Contents generated with DocToc

Installation

Tested with Node 6+.

npm install statsd-zabbix-backend

Configuration

Example StatsD configuration:

{
  debug: true,
  flushInterval: 10000,
  percentThreshold: [95, 99],
  backends: ["statsd-zabbix-backend"],
  zabbixHost: "zabbix.example.com",
}

Options

  • zabbixHost: Hostname or IP for Zabbix server [default: localhost]
  • zabbixPort: Port for Zabbix server [default: 10051]
  • zabbixSendTimestamps: Send timestamps to Zabbix, otherwise [default: false]
  • zabbixTargetHostname: Set static hostname, use full stat as key [default: undefined]

Usage

This plugin is primarily designed for use with logstash > statsd > zabbix pipline, but should work for getting data from any source into Zabbix.

Zabbix

All Zabbix items are expected to be type Zabbix trapper to support receiving push data.

Most values should be decimal. Average (avg) or mean values should be float.

Stat Names

Send your host and key separated by an underscore, for example:

host.example.com_my.key:1|c

Stats starting with any of the following prefixes will be handled differently:

  • logstash.
  • kamon.
  • statsd.

Static Hostname

If you run statsd on each host, set option zabbixTargetHostname to send all stats to a single host. In this mode, the full stat name will be used as the item key in Zabbix.

Logstash

Logstash's statsd output sends data in the format namespace.sender.metric.

  • namespace: default is "logstash"
  • sender: default is "%{host}", replacing dots with underscores
  • metric: name of the metric used in increment

See Logstash examples for specific keys Zabbix will receive based on metric type.

Note: sender and metric will have underscores replaced by periods before being sent to Zabbix.

Counters

Logstash statsd output using increment:

{
  statsd {
    host => "127.0.0.1"
    increment => ["my_key"]
  }
}

Logstash sends to Statsd: logstash.host_example_com.my_key:1|c.

Statsd calculates 2 values every flushInterval and sends each as a separate key to Zabbix for host "host.example.com":

  • my.key[avg]
  • my.key[total]

Timers

Logstash statsd output using timing:

{
  statsd {
    host => "127.0.0.1"
    timing => {
      "my_key" => "1"
    }
  }
}

Logstash sends to Statsd: logstash.host_example_com.my_key:1|ms

Given the percentThreshold in the example Statsd config, each of the following values would be calculated every flushInterval and sent as a separate keys to Zabbix for host "host.example.com":

  • my.key[mean][95]
  • my.key[upper][95]
  • my.key[mean][99]
  • my.key[upper][99]
  • my.key[upper]
  • my.key[lower]
  • my.key[count]

Gauges

Gauges are also supported.

{
  statsd {
    host => "127.0.0.1"
    gauge => {
      "my_key" => "1"
    }
  }
}

Logstash sends to Statsd: logstash.host_example_com.my_key:1|g

Zabbix will receive a single item:

  • my.key

statsd-zabbix-backend's People

Contributors

gilday avatar parkerd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

statsd-zabbix-backend's Issues

No license is provided

Hi, @parkerd

I appreciate all your work on this module, and I'd like to use it in production environments at my company. However, the lack of an explicit provided license would preclude me from doing so.

Could you please provide a license with the module?

Thanks!

Is there any option to use 2 zabbix backends in parallel?

Hi,

Currently I'm using the zabbix backend, and it works fine, but I want to send the same information to the other zabbix entity.

Is there any way to perform this? (I think there would be the problems with the configuration fields)
Any advice?

Regards,

Publish new version to npm

Please publish current version that uses the node-zabbix-sender to npm.
Spent quite some time debugging to realize the difference.
Thanks

Issue sending data

Hi, I was trying to setup statsd with this plugin and hit small issue.

Looks like by default plugin sends wrong data format to zabbix. I made logging move verbose so here is output when plugin is just running without any external data:

30 Jun 15:14:53 - statsd.bad lines[total] 1404141293 0
statsd.bad lines[avg] 1404141293 0
statsd.packets received[total] 1404141293 0
statsd.packets received[avg] 1404141293 0
statsd.timestamp lag 1404141293 0

30 Jun 15:14:53 - /usr/bin/zabbix_sender: zabbix_sender [32]: DEBUG: answer [{
        "response":"success",
        "info":"processed: 0; failed: 5; total: 5; seconds spent: 0.000061"}]

statsd version is v0.7.1
zabbix_sender version is:

zabbix_sender --version
Zabbix Sender v2.2.2 (revision 42525) (12 February 2014)
Compilation time: Feb 16 2014 23:34:44

Is it some issue in my configuration? Or is plugin outdated?

Thanks!

statsd fails after some time

Hello,

Trying to use statsd-zabbix-backend, but the statsd exits after some time:

root@ip-10-75-22-83 ~/statsd # sudo nodejs stats.js config.js 
6 Jun 14:43:03 - reading config file: config.js
6 Jun 14:43:03 - server is up
6 Jun 14:43:03 - DEBUG: Loading backend: statsd-zabbix-backend
6 Jun 14:43:07 - DEBUG: foo:1|c
6 Jun 14:43:13 - statsd.bad lines[total] 1402058593 0
statsd.bad lines[avg] 1402058593 0
statsd.packets received[total] 1402058593 1
statsd.packets received[avg] 1402058593 0.1
foo undefined[total] 1402058593 1
foo undefined[avg] 1402058593 0.1

6 Jun 14:43:13 - statsd.bad lines[total] 1402058593 0
statsd.bad lines[avg] 1402058593 0
statsd.packets received[total] 1402058593 0
statsd.packets received[avg] 1402058593 0
foo undefined[total] 1402058593 0
foo undefined[avg] 1402058593 0
statsd.timestamp lag 1402058593 -10


/root/statsd/node_modules/statsd-zabbix-backend/lib/zabbix.js:37
          throw error;
                ^
Error: Command failed: 
    at ChildProcess.exithandler (child_process.js:637:15)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Socket.<anonymous> (child_process.js:956:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:466:12)

My zabbixSender path is correct.

The output which proc.exec returns:

processed: 0; failed: 4; total: 4; seconds spent: 0.000112

Before that I've used zabbix_sender as logstash output and the items were getting zabbix server, so there is the high probability that it's working.

The line which it tries to execute is:

/usr/bin/zabbix_sender -T -i - -z 148.251.141.49 -p 10051

When I run it in my terminal it just executes, without any errors:
image

Any thoughts?

statsd-php vs statsd-zabbix-backend

Hi,

I'm trying to integrate 2 beautiful projects - https://github.com/domnikl/statsd-php with the statsd-zabbix-backend.

In my php, I'm trying to send gauge to the statsd.

Here is how it looks like:

$logstashLength = rand(100,1000);

$connection = new \Domnikl\Statsd\Connection\Socket('localhost', 8125);
$statsd = new \Domnikl\Statsd\Client($connection, "redis.subdomain_domain_com");
$statsd->gauge('length', $logstashLength);

Here is how the value is stored in the mysql-backend:
image

Here is how the value is displayed in the statsd log:

5 Aug 10:37:47 - statsd.bad lines[total] 1407227867 0
statsd.bad lines[avg] 1407227867 0
statsd.packets received[total] 1407227867 1
statsd.packets received[avg] 1407227867 0.1
subdomain_domain_com length 1407227867 245

So, to catch the value on the zabbix side, currently I need to declare the host "subdomain_domain_com" and the attribute called "length".

My question - why zabbix backend doesn't convert the "_" to "." , as it did with the logstash values?

As soon as I would update my php to:

$logstashLength = rand(100,1000);

$connection = new \Domnikl\Statsd\Connection\Socket('localhost', 8125);
$statsd = new \Domnikl\Statsd\Client($connection, "redis.subdomain.domain.com");
$statsd->gauge('length', $logstashLength);

I receive the next in the logs:

5 Aug 10:48:36 - statsd.bad lines[total] 1407228517 0
statsd.bad lines[avg] 1407228517 0
statsd.packets received[total] 1407228517 1
statsd.packets received[avg] 1407228517 0.1
redis.subdomain.domain.com.length undefined 1407228517 169

What should I do in php to receive the correct hosname (with dots) during the zabbix export?

Regards,

Name correlation statsd vs zabbix

Hi there, in my logstash config I have the next:

 statsd {
        type => "apache-access"
        increment => "apache_status_%{response}"
        host => "127.0.0.1"
 }

My Zabbix item is configured this way:
image

And here is what the statsd debug shows:
image

It looks like it sends the averages, not the exact name. Should it be like that?

Mysql statsd backend shows the next:
image

While I don't see any data in my zabbix.

How should I name the variable in the logstash config and in Zabbix so I would receive the information ?
Am I configured the hostname in Zabbix correctly?

Regards,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.