Project

metrico

0.0
No commit activity in last 3 years
No release in over 3 years
Use it to write your metrics in InfluxDB format through NATS
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.15
~> 10.0
~> 3.0

Runtime

 Project Readme

Metrico

NATS ruby client to write metrics Use it to push in InfluxDB format through NATS https://docs.influxdata.com/influxdb/v1.2/write_protocols/line_protocol_tutorial/

Installation

Add this line to your application's Gemfile:

gem 'metrico'
$ bundle install
# config/initializers/metrico.rb
Metrico.configure do |config|
  config.app_name = 'app_name' # required
  config.hostname = 'globalhost' # required
  config.nats_connect_options = {
    servers: ['nats://telegraf-0.somenatsnode.com:4222']
  }
  # define lambdas for these callbacks if you need some
  config.on_error = ->{}
  config.on_reconnect = ->{}
  config.on_disconnect = ->{}
  config.on_close = ->{}
end

For more nats connect options see https://github.com/nats-io/pure-ruby-nats/blob/master/lib/nats/io/client.rb#L154. You also can define most of all connection config via ENV variables.

Usage

In your app you have to push metrics, passing name, hash of metric/value and hash of tags.

Examples:

Metrico.push('3rd_party', {response_time: 1300, sidekiq_retry: 2}, {service: :first})

Metrico.push(
  'heartbeat',
  { cpu: 99, memory: 3200 }
)

License

The gem is available as open source under the terms of the MIT License.