Skip to content

Commit dd5c926

Browse files
committed
support sprintf-formatting of column names in coerce_values
1 parent decf02a commit dd5c926

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 5.0.6
2+
- Column names in coerce_values now supports sprintf formatting
3+
14
## 5.0.5
25
- Added clarifying information for `send_as_tags` config option [#80](https://github.com/logstash-plugins/logstash-output-influxdb/pull/80)
36

lib/logstash/outputs/influxdb.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ class LogStash::Outputs::InfluxDB < LogStash::Outputs::Base
7474
#
7575
# currently supported datatypes are `integer` and `float`
7676
#
77+
# supports sprintf-formatting in column names
78+
#
7779
config :coerce_values, :validate => :hash, :default => {}
7880

7981
# Automatically use fields from the event as the data points sent to Influxdb
@@ -155,7 +157,7 @@ def receive(event)
155157
time = timestamp_at_precision(event.timestamp, @time_precision.to_sym)
156158
point = create_point_from_event(event)
157159
exclude_fields!(point)
158-
coerce_values!(point)
160+
coerce_values!(point, event)
159161

160162
if point.has_key?('time')
161163
unless @allow_time_override
@@ -217,8 +219,9 @@ def create_point_from_event(event)
217219
# foreknowledge of what's in the data point, which is less than ideal. An
218220
# alternative is to use a `code` filter and manipulate the individual point's
219221
# data before sending to the output pipeline
220-
def coerce_values!(event_data)
222+
def coerce_values!(event_data, event)
221223
@coerce_values.each do |column, value_type|
224+
column = event.sprintf(column)
222225
if event_data.has_key?(column)
223226
begin
224227
@logger.debug? and @logger.debug("Converting column #{column} to type #{value_type}: Current value: #{event_data[column]}")

logstash-output-influxdb.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |s|
22
s.name = 'logstash-output-influxdb'
3-
s.version = '5.0.5'
3+
s.version = '5.0.6'
44
s.licenses = ['Apache License (2.0)']
55
s.summary = "Writes metrics to InfluxDB"
66
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"

0 commit comments

Comments
 (0)