Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ivanshamatov/metrico
Metrics via NATS protocol
https://github.com/ivanshamatov/metrico
Last synced: 2 months ago
JSON representation
Metrics via NATS protocol
- Host: GitHub
- URL: https://github.com/ivanshamatov/metrico
- Owner: IvanShamatov
- License: mit
- Created: 2017-06-09T14:24:32.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-12-29T21:00:41.000Z (almost 5 years ago)
- Last Synced: 2024-04-25T01:08:23.991Z (8 months ago)
- Language: Ruby
- Size: 13.7 KB
- Stars: 4
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this 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:
```ruby
gem 'metrico'
``````
$ bundle install
``````ruby
# 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](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:
```ruby
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](http://opensource.org/licenses/MIT).