fluent-plugin-lm-logs 0.0.9 → 1.0.1

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: cd3e7b9db6e1987cb6c973f5f2158a38cced85cd91f674ab431556212a821ca1
4
- data.tar.gz: 18788379b54ac12b84b1bfa5b3f0d6aa5b0ea61d7e2c59386d36bf581b9c6565
3
+ metadata.gz: 6ac69aa367c60b885d377a7c818fbfcb70c8af34d86315fee0d2b18778351a92
4
+ data.tar.gz: b3cfdfbe4362b7f8d71a79d5aa34e92cc2b29c1a63b18a00b7aaa0cbe09cb14a
5
5
  SHA512:
6
- metadata.gz: 0c4777a3d6c39163d779ec794c26d9792a191ee3ed9730043698dc68000b61ea5e81bf8bf0e7c24f7851d4a99cdc1eef6fe22b0ccd335299bc93bea481b77b23
7
- data.tar.gz: e230f2badade41a1126ecc9ea73c0c0aacf62920f41fbcbb063d1ba7dbdbba9a051b4d886b239916d9a3d836f2c54aeb024aebf2107c8f30dbff460a7d86dbc5
6
+ metadata.gz: aae1c2c44c9cc03c7256147322eb34d14eb551ea115a5befde0aa56903afb9a98e21d5670f0c253ac6fc7ef9a0be65ebd827ccc0581bda097597de77a1a5861f
7
+ data.tar.gz: fb6d25f6b71ad3c30084840e145ec1e7c4d98d036773762babb3b9d18c8136f5f384f85f065c3758972448f861f4e5617a5d57a97efcb5e0d77f30c8a945b446
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  [![Gem Version](https://badge.fury.io/rb/fluent-plugin-lm-logs.svg)](http://badge.fury.io/rb/fluent-plugin-lm-logs)
3
- # lm-logs-fluentd (beta)
3
+ # lm-logs-fluentd
4
4
  This output plugin sends Fluentd records to the configured LogicMonitor account.
5
5
 
6
6
  ## Prerequisites
@@ -20,10 +20,10 @@ Create a custom `fluent.conf` or edit the existing one to specify which logs sho
20
20
  # send them to LogicMonitor
21
21
  <match lm.**>
22
22
  @type lm
23
- company_name <account_name>
24
23
  resource_mapping {"<event_key>": "<lm_property>"}
25
- access_id <your_lm_access_id>
26
- access_key <your_lm_access_key>
24
+ company_name <lm_company_name>
25
+ access_id <lm_access_id>
26
+ access_key <lm_access_key>
27
27
  <buffer>
28
28
  @type memory
29
29
  flush_interval 1s
@@ -39,7 +39,7 @@ Sending:
39
39
 
40
40
  `curl -X POST -d 'json={"message":"hello LogicMonitor from fluentd", "event_key":"lm_property_value"}' http://localhost:8888/lm.test`
41
41
 
42
- Returns the event:
42
+ Produces this event:
43
43
  ```
44
44
  {
45
45
  "message": "hello LogicMonitor from fluentd"
@@ -49,9 +49,8 @@ Returns the event:
49
49
  **Note:** Make sure that logs have a message field. Requests sent without a message will not be accepted.
50
50
 
51
51
  ### Kubernetes
52
- Logic Monitor collects k8s logs automatically via FluentD daemonset, It requires a plugin for this. We recommend using [fluent-plugin-kubernetes_metadata_filter](https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter) to collect Kubernetes metadata.
53
-
54
- See the [example](https://github.com/logicmonitor/lm-logs-fluentd/tree/master/Examples/k8s) to forward k8s logs to Logic Monitor.
52
+ The Kubernetes configuration for LM Logs is deployed as a Helm chart.
53
+ See the [LogicMonitor Helm repository](https://github.com/logicmonitor/k8s-helm-charts/tree/master/lm-logs).
55
54
 
56
55
  ### Resource mapping examples
57
56
 
@@ -68,4 +67,5 @@ See the [example](https://github.com/logicmonitor/lm-logs-fluentd/tree/master/Ex
68
67
  | `access_id` | LM API Token access ID. |
69
68
  | `access_key` | LM API Token access key. |
70
69
  | `flush_interval` | Defines the time in seconds to wait before sending batches of logs to LogicMonitor. Default is `60s`. |
71
- | `debug` | When `true`, logs more information to the fluentd console. |
70
+ | `debug` | When `true`, logs more information to the fluentd console. |
71
+ | `force_encoding` | Specify charset when logs contains invalid utf-8 characters. |
@@ -1,14 +1,14 @@
1
1
  # Unless explicitly stated otherwise all files in this repository are licensed
2
2
  # under the Apache License Version 2.0.
3
- # This product includes software developed at Logic Monitor (https://www.logicmonitor.com).
4
- # Copyright 2020 Logic Monitor, Inc.
3
+ # This product includes software developed at LogicMonitor (https://www.logicmonitor.com).
4
+ # Copyright 2020 LogicMonitor, Inc.
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "fluent-plugin-lm-logs"
8
- spec.version = '0.0.9'
9
- spec.authors = ["Logic Monitor"]
8
+ spec.version = '1.0.1'
9
+ spec.authors = ["LogicMonitor"]
10
10
  spec.email = "rubygems@logicmonitor.com"
11
- spec.summary = "Logic Monitor logs fluentd output plugin"
11
+ spec.summary = "LogicMonitor logs fluentd output plugin"
12
12
  spec.description = "This output plugin sends fluentd records to the configured LogicMonitor account."
13
13
  spec.homepage = "https://www.logicmonitor.com"
14
14
  spec.license = "Apache-2.0"
@@ -5,9 +5,10 @@ require 'uri'
5
5
  require 'digest'
6
6
  require 'json'
7
7
  require 'openssl'
8
- require "base64"
8
+ require 'base64'
9
9
  require 'net/http'
10
10
  require 'net/https'
11
+ require('zlib')
11
12
 
12
13
 
13
14
  module Fluent
@@ -25,7 +26,15 @@ module Fluent
25
26
  config_param :resource_mapping, :hash, :default => {"host": "system.hostname", "hostname": "system.hostname"}
26
27
 
27
28
  config_param :debug, :bool, :default => false
29
+
30
+ config_param :force_encoding, :string, :default => ""
28
31
 
32
+ config_param :compression, :string, :default => ""
33
+
34
+ config_param :log_source, :string, :default => "lm-logs-fluentd"
35
+
36
+ config_param :version_id, :string, :default => "version_id"
37
+
29
38
  # This method is called before starting.
30
39
  # 'conf' is a Hash that includes configuration parameters.
31
40
  # If the configuration is invalid, raise Fluent::ConfigError.
@@ -71,6 +80,11 @@ module Fluent
71
80
  resource_map = {}
72
81
  lm_event = {}
73
82
  lm_event["message"] = record["message"]
83
+
84
+ if @force_encoding != ""
85
+ lm_event["message"] = lm_event["message"].force_encoding(@force_encoding).encode("UTF-8")
86
+ end
87
+
74
88
  if record["_lm.resourceId"] == nil
75
89
  @resource_mapping.each do |key, value|
76
90
  k = value
@@ -84,8 +98,13 @@ module Fluent
84
98
  else
85
99
  lm_event["_lm.resourceId"] = record["_lm.resourceId"]
86
100
  end
87
-
88
- lm_event["timestamp"] = Time.at(time).utc.to_datetime.rfc3339
101
+
102
+ if record["timestamp"] != nil
103
+ lm_event["timestamp"] = record["timestamp"]
104
+ else
105
+ lm_event["timestamp"] = Time.at(time).utc.to_datetime.rfc3339
106
+ end
107
+
89
108
  return lm_event
90
109
  end
91
110
 
@@ -104,8 +123,22 @@ module Fluent
104
123
 
105
124
  request = Net::HTTP::Post.new(uri.request_uri)
106
125
  request['authorization'] = generate_token(events)
107
- request['Content-type'] = "application/json"
108
- request.body = body
126
+ request['Content-type'] = "application/json"
127
+ request['User-Agent'] = log_source + "/" + version_id
128
+
129
+ if @compression == "gzip"
130
+ request['Content-Encoding'] = "gzip"
131
+ gzip = Zlib::GzipWriter.new(StringIO.new)
132
+ gzip << body
133
+ request.body = gzip.close.string
134
+ else
135
+ request.body = body
136
+ end
137
+
138
+ if @debug
139
+ log.info "Sending the below request headers to logicmonitor:"
140
+ request.each_header {|key,value| log.info "#{key} = #{value}" }
141
+ end
109
142
 
110
143
  resp = http.request(request)
111
144
  if @debug || (!resp.kind_of? Net::HTTPSuccess)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-lm-logs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
- - Logic Monitor
7
+ - LogicMonitor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-18 00:00:00.000000000 Z
11
+ date: 2021-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -65,8 +65,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  - !ruby/object:Gem::Version
66
66
  version: '0'
67
67
  requirements: []
68
- rubygems_version: 3.1.2
68
+ rubygems_version: 3.2.15
69
69
  signing_key:
70
70
  specification_version: 4
71
- summary: Logic Monitor logs fluentd output plugin
71
+ summary: LogicMonitor logs fluentd output plugin
72
72
  test_files: []