Class: LogStash::Outputs::Wavefront

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/outputs/wavefront.rb

Overview

The Wavefront Output Plugin for Logstash

Every event processed by this plugin has all of its fields scanned. If those fields contain hashes, and those hashes have keys that match “metrics” below, they are sent to Wavefront.

For example, suppose you give the following config:


output {

wavefront {
  prefix => "mymetrics"
  metrics => ["count", "mean"]
}

}


Then, the following event…


{

"data1" => {
  "count" => 200,
  "mean" => 42.2
},
"data2" => {
  "count" => 123,
  "max" => 9001
},
"data3" => "I'm not a hash, so I'm not even parsed."

}


Will report the following metrics to Wavefront:

  • ‘mymetrics.data1.count 200`

  • ‘mymetrics.data1.mean 42.2`

  • ‘mymetrics.data2.count 123`

This scheme allows you to easily integrate with the <<plugins-filters-metrics,metrics filter plugin>>, but integration with any other filter should be possible with mutates and groks.

The Wavefront Proxy

This plugin is designed to send telemetry to the github.com/wavefrontHQ/java/tree/master/proxy[Wavefront Proxy] (github.com/wavefrontHQ/install[installation instructions]).

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sourceObject (readonly)

Access to these fields is provided for testing only!



82
83
84
# File 'lib/logstash/outputs/wavefront.rb', line 82

def source
  @source
end

Instance Method Details

#receive(event) ⇒ Object



108
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
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/logstash/outputs/wavefront.rb', line 108

def receive(event)
  if not @open
    if not try_set_writer
      @logger.error("Dropping point, connection to WF agent is down.")
      return
    else
      @open = true
    end
  end

  event.to_hash.each do |faux_metric_name, field_value|
    next if field_value.class != Hash

    # Parse out tags if any are encoded in the metric name.
    parts = faux_metric_name.split(".")
    tags = {}
    if parts.length == 1 || @tag_separator == ""
        metric_name = faux_metric_name
    else
        idx = parts.index(@tag_separator)
        if idx == nil
          metric_name = faux_metric_name
        else
            metric_name = parts.slice(0, idx).join(".")
            parts.slice(idx + 1, parts.length - 1).each do |keyvalue|
                tag_parts = keyvalue.split("=")
                if tag_parts.length <= 1
                    next
                else
                    tags[tag_parts[0]] = tag_parts.slice(1, tag_parts.length).join("=")
                end
            end
        end
    end

    field_value.each do |metric_specifier, metric_value|
      full_metric = "#{metric_name}.#{metric_specifier}"
      if @metrics.include? metric_specifier
        full_metric_name =\
          @prefix == "" ? full_metric : "#{@prefix}.#{full_metric}"
        @logger.debug? && logger.debug(
            "Sending #{full_metric_name}=#{metric_value}: #{tags}")
        begin
          @writer.write(metric_value, full_metric_name, {:point_tags => tags})
        rescue Errno::EPIPE
          @logger.error("Connection to WF agent dropped!")
          @open = false
          return
        end
      else
        @logger.debug? && logger.debug(
            "Skipping unmentioned metric #{metric_specifier}")
      end
    end
  end
end

#registerObject



85
86
87
88
89
90
# File 'lib/logstash/outputs/wavefront.rb', line 85

def register
  if @source == ""
    @source = Socket.gethostname
  end
  @open = false
end