fluent-plugin-lm-logs 0.0.7 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a4b80a29df39066cf4d0d02dd5d3dd8a409253a9ffac8e2df552aa6d836c8fd
4
- data.tar.gz: 80a03e355f4485810f8f591688d2193258a480de797f5b73a627c802ce940a7e
3
+ metadata.gz: c930b2614b184eeba146418a22a10d732b8fd7aa57aabc8db45ec6d9e8608f0a
4
+ data.tar.gz: 6ced74d3ff2e35a3771b63d7f88572c2ebfd4e3dccd23e7a450a5bce6b7a22f7
5
5
  SHA512:
6
- metadata.gz: d4d74839b0bf81fa4b43b79a87015dec5c1c4d15e19e021c966f5c936e1503f55643c7f6902c17cabfd3788701a0f98b6dec6c56903b3ce5aa8c2e9907f11448
7
- data.tar.gz: 7ecf5e67a5881154c9f0c5a82d0e824e6cb98bb9b8bf66abbda06bc800ecc2c472f445107bac72996df7bbf2558e4890fe61400f92b84c617c7bb2aaa1795d60
6
+ metadata.gz: dd6ecf139c62cfba239000b45f134bd5c162ea773112438223fcbc20291ddaf97aebc3dec7aca2469639160f585baa2af628b94d445cee01dcb10d5bea7ffc31
7
+ data.tar.gz: e4e97f690c535f223b8c934bcdcf03cf3821f799f6018520ea8c2400eeb726b75de98d7eefa52ab80abf679ec85cc8941123596275f964755b4751372ffc1daf
data/README.md CHANGED
@@ -1,12 +1,13 @@
1
1
 
2
+ [![Gem Version](https://badge.fury.io/rb/fluent-plugin-lm-logs.svg)](http://badge.fury.io/rb/fluent-plugin-lm-logs)
2
3
  # lm-logs-fluentd (beta)
3
4
  This output plugin sends Fluentd records to the configured LogicMonitor account.
4
5
 
5
6
  ## Prerequisites
6
7
 
7
8
  Install the plugin:
8
- * With gem: `gem install lm-logs-fluentd`
9
- * For deb packages: `td-agent-gem install lm-logs-fluentd`
9
+ * With gem: `gem install fluent-plugin-lm-logs`
10
+ * For deb packages: `td-agent-gem install fluent-plugin-lm-logs`
10
11
 
11
12
  Alternatively, you can add `out_lm.rb` to your Fluentd plugins directory.
12
13
 
@@ -19,11 +20,15 @@ Create a custom `fluent.conf` or edit the existing one to specify which logs sho
19
20
  # send them to LogicMonitor
20
21
  <match lm.**>
21
22
  @type lm
22
- company_name <account_name>
23
23
  resource_mapping {"<event_key>": "<lm_property>"}
24
- access_id <your_lm_access_id>
25
- access_key <your_lm_access_key>
26
- flush_interval 1s
24
+ company_name <lm_company_name>
25
+ access_id <lm_access_id>
26
+ access_key <lm_access_key>
27
+ <buffer>
28
+ @type memory
29
+ flush_interval 1s
30
+ chunk_limit_size 5m
31
+ </buffer>
27
32
  debug false
28
33
  </match>
29
34
  ```
@@ -34,7 +39,7 @@ Sending:
34
39
 
35
40
  `curl -X POST -d 'json={"message":"hello LogicMonitor from fluentd", "event_key":"lm_property_value"}' http://localhost:8888/lm.test`
36
41
 
37
- Returns the event:
42
+ Produces this event:
38
43
  ```
39
44
  {
40
45
  "message": "hello LogicMonitor from fluentd"
@@ -43,6 +48,10 @@ Returns the event:
43
48
 
44
49
  **Note:** Make sure that logs have a message field. Requests sent without a message will not be accepted.
45
50
 
51
+ ### Kubernetes
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).
54
+
46
55
  ### Resource mapping examples
47
56
 
48
57
  - `{"message":"Hey!!", "event_key":"lm_property_value"}` with mapping `{"event_key": "lm_property"}`
@@ -59,4 +68,4 @@ Returns the event:
59
68
  | `access_key` | LM API Token access key. |
60
69
  | `flush_interval` | Defines the time in seconds to wait before sending batches of logs to LogicMonitor. Default is `60s`. |
61
70
  | `debug` | When `true`, logs more information to the fluentd console. |
62
-
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.7'
9
- spec.authors = ["Logic Monitor"]
8
+ spec.version = '0.0.12'
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,6 +26,10 @@ 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 => ""
31
+
32
+ config_param :compression, :string, :default => ""
28
33
 
29
34
  # This method is called before starting.
30
35
  # 'conf' is a Hash that includes configuration parameters.
@@ -71,6 +76,11 @@ module Fluent
71
76
  resource_map = {}
72
77
  lm_event = {}
73
78
  lm_event["message"] = record["message"]
79
+
80
+ if @force_encoding != ""
81
+ lm_event["message"] = lm_event["message"].force_encoding(@force_encoding).encode("UTF-8")
82
+ end
83
+
74
84
  if record["_lm.resourceId"] == nil
75
85
  @resource_mapping.each do |key, value|
76
86
  k = value
@@ -84,8 +94,13 @@ module Fluent
84
94
  else
85
95
  lm_event["_lm.resourceId"] = record["_lm.resourceId"]
86
96
  end
87
-
88
- lm_event["timestamp"] = Time.at(time).utc.to_datetime.rfc3339
97
+
98
+ if record["timestamp"] != nil
99
+ lm_event["timestamp"] = record["timestamp"]
100
+ else
101
+ lm_event["timestamp"] = Time.at(time).utc.to_datetime.rfc3339
102
+ end
103
+
89
104
  return lm_event
90
105
  end
91
106
 
@@ -93,10 +108,9 @@ module Fluent
93
108
  url = "https://#{@company_name}.logicmonitor.com/rest/log/ingest"
94
109
  body = events.to_json
95
110
  uri = URI.parse(url)
96
-
97
- log.info "Sending #{events.length} events to logic monitor at #{url}"
98
111
 
99
112
  if @debug
113
+ log.info "Sending #{events.length} events to logic monitor at #{url}"
100
114
  log.info "Request json #{body}"
101
115
  end
102
116
 
@@ -105,16 +119,20 @@ module Fluent
105
119
 
106
120
  request = Net::HTTP::Post.new(uri.request_uri)
107
121
  request['authorization'] = generate_token(events)
108
- request['Content-type'] = "application/json"
109
- request.body = body
122
+ request['Content-type'] = "application/json"
110
123
 
111
- resp = http.request(request)
112
- if @debug
113
- log.info "Response #{resp.body}"
124
+ if @compression == "gzip"
125
+ request['Content-Encoding'] = "gzip"
126
+ gzip = Zlib::GzipWriter.new(StringIO.new)
127
+ gzip << body
128
+ request.body = gzip.close.string
129
+ else
130
+ request.body = body
114
131
  end
115
132
 
116
- if !resp.kind_of? Net::HTTPSuccess
117
- log.error "Error sending batch #{resp.body}"
133
+ resp = http.request(request)
134
+ if @debug || (!resp.kind_of? Net::HTTPSuccess)
135
+ log.info "Status code:#{resp.code} Request Id:#{resp.header['x-request-id']}"
118
136
  end
119
137
  end
120
138
 
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.7
4
+ version: 0.0.12
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-08-25 00:00:00.000000000 Z
11
+ date: 2020-11-25 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.1.4
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: []