Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.
/ cabin-es Public archive

ElasticSearch output provider for the Ruby Cabin logging framework

License

Notifications You must be signed in to change notification settings

starkriedesel/cabin-es

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cabin - ElasticSearch

ElasticSearch output provider for the Ruby Cabin logging framework.

Installation

Add this line to your application's Gemfile:

gem 'cabin-es', require: 'cabin/es'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cabin-es

Usage

Used just like any other Cabin output plugin:

require 'cabin'
require 'cabin/es'

# Create a new Cabin channel
@logger = Cabin::Channel.new

# Subscribe to an ElasticSearch host
es = Cabin::Output::ElasticSearch.new(url: 'http://elasticsearch.example.com:9200', index: 'cabin', type: 'log')
@logger.subscribe(es)

# Send logs just like normal
@logger.info "Test Message", {some: 'data', nested: { data: 'is cool' }}

# Set the ElasticSearch "_type" on a per-message basis
@logger.info "Special Message", {some: 'data', _type: 'special'}

Message and data fields are imported into ElasticSearch as you would expect

{
  "_index": "cabin",
  "_type": "log",
  "_id": "AVgrn6PBq2Wn7-YPg6FT",
  "_score": null,
  "_source": {
    "timestamp": "2016-11-03T14:17:12.076636-0500",
    "message": "Test Message",
    "level": "info",
    "some": "data",
    "nested": {
      "data": "is cool"
    }
  },
  "fields": {
    "timestamp": [
      1478200632076
    ]
  },
  "sort": [
    1478200632076
  ]
}

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/starkriedesel/cabin-es.

License

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

About

ElasticSearch output provider for the Ruby Cabin logging framework

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published