fluent-plugin-lm-logs 0.0.8 → 1.0.0

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: 321e02b24adb9528c90c7cdddd17ebdbc193dd3abcd0a66cdb6b7eaa1394b78e
4
- data.tar.gz: c0ab73b0026f74fde357f5cdb38d1c2c0618b06a2e2389b5ba246d5eee7eb3ea
3
+ metadata.gz: a22de1423e4cac56363b99b31828c5add123ac4f843d4aeae4112aab02c4b6b4
4
+ data.tar.gz: e35849d3c43ef4f83fdeecae137b2d4e38f5c69ec52a7bf147191ac46773e61c
5
5
  SHA512:
6
- metadata.gz: 0c863145fc51cc9473113c469d81acf6e96a770481b83665b9ed11e15e13fc2c259d6bad983092620813de982ede3f9df74389fdf3e2635f4298d3a1d807c5b4
7
- data.tar.gz: b87af1e8f8469d7b365aad2aa670d526f022132b8e7a630caef0e342c7c979db8e47a53e6e2bc79deb07c394c15e1391b1ec40e85f7f33e96f9f3c62dd4e70e9
6
+ metadata.gz: f34bab74bbf201ca0af3ff2de35307560f5bb79a37b9ea549b5627f421c7214ea2a5ab7304efe6ddc54f774af161fa594aed8a6c4ce75b9dfb38f2eb2a852788
7
+ data.tar.gz: 14341d2be42d2d7530cc964178f514a530adb3c8d3679ff60ab6cdef653f83eaf38f70b68bb1578a7393f7bd6172c63f9185623eb7acf450f4db343ca2f0abfb
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.8'
9
- spec.authors = ["Logic Monitor"]
8
+ spec.version = '1.0.0'
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
 
@@ -93,10 +112,9 @@ module Fluent
93
112
  url = "https://#{@company_name}.logicmonitor.com/rest/log/ingest"
94
113
  body = events.to_json
95
114
  uri = URI.parse(url)
96
-
97
- log.info "Sending #{events.length} events to logic monitor at #{url}"
98
115
 
99
116
  if @debug
117
+ log.info "Sending #{events.length} events to logic monitor at #{url}"
100
118
  log.info "Request json #{body}"
101
119
  end
102
120
 
@@ -105,13 +123,21 @@ module Fluent
105
123
 
106
124
  request = Net::HTTP::Post.new(uri.request_uri)
107
125
  request['authorization'] = generate_token(events)
108
- request['Content-type'] = "application/json"
109
- 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
110
137
 
111
138
  resp = http.request(request)
112
139
  if @debug || (!resp.kind_of? Net::HTTPSuccess)
113
- log.info "Status code #{resp.code}"
114
- log.info "Request Id #{resp.header['x-request-id']}"
140
+ log.info "Status code:#{resp.code} Request Id:#{resp.header['x-request-id']}"
115
141
  end
116
142
  end
117
143
 
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.8
4
+ version: 1.0.0
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-16 00:00:00.000000000 Z
11
+ date: 2021-03-31 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.3
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: []