Class: LogStash::Outputs::Riak
- Defined in:
- lib/logstash/outputs/riak.rb
Overview
Riak is a distributed k/v store from Basho. It’s based on the Dynamo model.
Constant Summary
Constants included from Config::Mixin
Instance Attribute Summary
Attributes included from Config::Mixin
Attributes inherited from Plugin
Instance Method Summary collapse
Methods inherited from Base
#handle, #handle_worker, #initialize, #worker_setup, #workers_not_supported
Methods included from Config::Mixin
Methods inherited from Plugin
#eql?, #finished, #finished?, #hash, #initialize, #inspect, lookup, #reload, #running?, #shutdown, #teardown, #terminating?, #to_s
Constructor Details
This class inherits a constructor from LogStash::Outputs::Base
Instance Method Details
#receive(event) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/logstash/outputs/riak.rb', line 109 def receive(event) return unless output?(event) @bucket.each do |b| # setup our bucket(s) bukkit = @client.bucket(event.sprintf(b)) # Disable bucket props for now # Need to detect params passed that should be converted to int # otherwise setting props fails =( # Logstash syntax only supports strings and bools # likely fix is to either hack in is_numeric? # or whitelist certain params and call to_i ##@logger.debug("Setting bucket props", :props => @bucket_props) ##bukkit.props = @bucket_props if @bucket_props ##@logger.debug("Bucket", :bukkit => bukkit.inspect) if @enable_search @logger.debug("Enable search requested", :bucket => bukkit.inspect) # Check if search is enabled @logger.debug("Checking bucket status", :search_enabled => bukkit.is_indexed?) bukkit.enable_index! unless bukkit.is_indexed? @logger.debug("Rechecking bucket status", :search_enabled => bukkit.is_indexed?) end @key_name.nil? ? evt_key=nil : evt_key=event.sprintf(@key_name) evt = Riak::RObject.new(bukkit, evt_key) @logger.debug("RObject", :robject => evt.to_s) begin evt.content_type = "application/json" evt.data = event if @indices @indices.each do |k| idx_name = "#{k.gsub('@','')}_bin" @logger.debug("Riak index name", :idx => idx_name) @logger.info("Indexes", :indexes => evt.indexes.to_s) evt.indexes[idx_name] << event.sprintf("%{#{k}}") end end evt.store rescue Exception => e @logger.warn("Exception storing", :message => e.) end end end |
#register ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/logstash/outputs/riak.rb', line 82 def register require 'riak' riak_opts = {} cluster_nodes = Array.new @logger.debug("Setting protocol", :protocol => @proto) proto_type = "#{@proto}_port".to_sym @nodes.each do |node,port| @logger.debug("Adding node", :node => node, :port => port) cluster_nodes << {:host => node, proto_type => port} end @logger.debug("Cluster nodes", :nodes => cluster_nodes) if @enable_ssl @logger.debug("SSL requested") if @ssl_opts @logger.debug("SSL options provided", @ssl_opts) riak_opts.merge!(@ssl_opts.inject({}) {|h,(k,v)| h[k.to_sym] = v; h}) else riak_opts.merge!({:ssl => true}) end @logger.debug("Riak options:", :riak_opts => riak_opts) end riak_opts.merge!({:nodes => cluster_nodes}) @logger.debug("Riak options:", :riak_opts => riak_opts) @client = Riak::Client.new(riak_opts) end |