logstash-filter-influxdb 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b43ba5bafed8864daaa2f619dbfa6ab40fb4902559fb4df39acc2faf85d5be6
4
- data.tar.gz: dc3a8a0ed6cbcf48498480ebcff818529a980764bbcc3c46f763da4016ed93a7
3
+ metadata.gz: f08b4fd0ac6fb1e2f045fa176fc484fee88063330e7ed55b7ab99e5ebb4753f9
4
+ data.tar.gz: 6e3360f48644801ad49415286ee7c41673fae7b3551649b1cd53c70aff8450b1
5
5
  SHA512:
6
- metadata.gz: 9ed2b9d47aed8ab752eaade0eca718f50e6aa4cccfb74ca4e7814560871087fce23cbfdc9cc3261c9ec20b3226a9363b36cc7c85271c1b41028f8572883cb50a
7
- data.tar.gz: 5bfdcbc0ae045560c398307cca793129c74c1b645e97d3f299fc5c744073e06d11fd6db42c836de1ed92708bc9b11f412384f6b80a745d672c9fcd80535dab5f
6
+ metadata.gz: c467dc0e6c6d7b1093cfe7b3749e7ebd8f49f02847f7f3d9761f80523046734fbfd42d61008ee87e823be230c1297304fc72c203721e437aa210a1b46ad3c94a
7
+ data.tar.gz: 4cbdbc357bb25d0256893b8fd4c622e9a302a4cdf51a3496fabd6c22bec44b4473e8a954d24aafbecd350b87e7346a4ccd1438fc7d1563709001e47849ba34a0
data/README.md CHANGED
@@ -1 +1,33 @@
1
1
  # logstash-filter-influxdb
2
+
3
+ ## usage
4
+ ```
5
+ filter {
6
+ # multiple lines of Influx line protocol in a single event are valid, split on newlines to handle each one individually
7
+ split {
8
+ field => "message"
9
+ }
10
+
11
+ # parse the point
12
+ influxdb {
13
+ source => "message"
14
+ target => "point"
15
+ parse_types => true
16
+ time_format => "%Y-%d-%mT%H:%M:%S.%NZ"
17
+ }
18
+
19
+ # if it can't be parsed, just drop it (don't really do this)
20
+ if ([point][_influxparseerror]) {
21
+ drop {}
22
+ }
23
+ }
24
+ ```
25
+
26
+ ## options
27
+ The second parameter for parse_point is a hash array of options. The current options are
28
+
29
+ * `:parse_types`: Parse data types to ruby types (float, int, bool). If false all values in the fields are treated as strings.
30
+ * **default**: `false`
31
+
32
+ * `:time_format`: Parses the timestamp attribute (if present) and formats it accoring to a [strftime format](https://apidock.com/ruby/Time/strftime). InfluxDB time is always UTC so is this.
33
+ * **default**: `nil`
@@ -3,23 +3,15 @@ require "logstash/filters/base"
3
3
  require "logstash/namespace"
4
4
  require "influxparser"
5
5
 
6
- # Add any asciidoc formatted documentation here
7
- # This example filter will replace the contents of the default
8
- # message field with whatever you specify in the configuration.
9
- #
10
- # It is only intended to be used as an example.
11
6
  class LogStash::Filters::Influxdb < LogStash::Filters::Base
12
7
 
13
- # Setting the config_name here is required. This is how you
14
- # configure this filter from your Logstash config.
15
- #
16
- # filter {
17
- # example { message => "My message..." }
18
- # }
19
8
  config_name "influxdb"
20
9
 
21
10
  # Replace the message with this value.
22
11
  config :source, :validate => :string, :default => "message"
12
+ config :target, :validate => :string, :default => "point"
13
+ config :parse_types, :validate => :boolean, :default => false
14
+ config :time_format, :validate => :string, :default => nil
23
15
 
24
16
  public
25
17
  def register
@@ -29,12 +21,15 @@ class LogStash::Filters::Influxdb < LogStash::Filters::Base
29
21
  public
30
22
  def filter(event)
31
23
 
32
- point = InfluxParser.parse_point(event.get(@source))
24
+ point = InfluxParser.parse_point(event.get(@source),{
25
+ :parse_types => @parse_types,
26
+ :time_format => @time_format
27
+ })
33
28
 
34
29
  if point
35
- event.set('point', point)
30
+ event.set(@target, point)
36
31
  else
37
- event.set('point', {'_influxparseerror' => true })
32
+ event.set(@target, {'_influxparseerror' => true })
38
33
  end
39
34
 
40
35
  # filter_matched should go in the last line of our successful code
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-filter-influxdb'
3
- s.version = '0.0.4'
3
+ s.version = '0.1.0'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = "Parse a string of influx line protocol to fields"
6
6
  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"
@@ -19,6 +19,6 @@ Gem::Specification.new do |s|
19
19
 
20
20
  # Gem dependencies
21
21
  s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
22
- s.add_runtime_dependency "influxparser", "=0.0.2"
22
+ s.add_runtime_dependency "influxparser", "=0.0.4"
23
23
  s.add_development_dependency 'logstash-devutils'
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-influxdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Labrie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-03 00:00:00.000000000 Z
11
+ date: 2020-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-core-plugin-api
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - '='
38
38
  - !ruby/object:Gem::Version
39
- version: 0.0.2
39
+ version: 0.0.4
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - '='
45
45
  - !ruby/object:Gem::Version
46
- version: 0.0.2
46
+ version: 0.0.4
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: logstash-devutils
49
49
  requirement: !ruby/object:Gem::Requirement