fluent-plugin-lm-logs-gcp 1.0.6 → 1.0.8

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: 213a63d23d18929286a8201af426fe7e2b1ff68ac8a30cc9d50dc53cff532786
4
- data.tar.gz: 9e161f20a42725baf4b32ea931cfe225516802aa0952a221a8d86ce1dbec457e
3
+ metadata.gz: 2674bd9fe0d77cbb6b9960b69278261381d9ec8c73604c5eac247b016c839ea8
4
+ data.tar.gz: d2a14c818ee472ce3270a31ffe92d826ea06a06f4439f2ab88281678e8b80d2c
5
5
  SHA512:
6
- metadata.gz: 4a1e38a85f385fc408f3b74b40503ff255b2c3a3c29afa37854e4562b55ee21cc1d4c348f3ffda1f2378d22195ce995e842e15cf887d32eba73891027362fbe1
7
- data.tar.gz: fd3f360ef17b0a568f30dadf56b6df6417fe725a566ece3c3e5c4af7478b2c5132fe94d0866d1a66604bd383d0ccbd66f9df903aa5df0c7d7b4b381c70fc6e78
6
+ metadata.gz: 8880f059d56514bb76aac758f9b456aaf11f7b3ab2eb2852fb2b0d7d8939aa5b9eb8cd2a5dd8c73e44bf0abef6c67b32a08337d2a7fafe403e00f55f78187cff
7
+ data.tar.gz: 7bfeeb38ad29493ab5a73fd9f6f5a6a9a833ce1e0fe7d1da69fa089b67880abc08f55ca287006c5fd17d49f2531b3f6696ac7f741a36ef39e9f69c56a4b90249
data/README.md CHANGED
@@ -12,4 +12,5 @@ This filter plugin is provided for mapping the logs coming from GCP pubsub to '_
12
12
  | Property | Description |
13
13
  | --- | --- |
14
14
  | `metadata_keys` | Array of keys to be added as metadata. Filter will look for these keys in fluentd record and extract those if exist. in case of nested json, whole sub json would be added. default ` ["severity", "logName", "labels", "resource.type", "resource.labels", "httpRequest"] ` . few keys will be renamed as part of metadata standardization in Logicmonitor : ` {"trace" => "trace_id", "spanId" => "span_id","resource.type" => "_type"}`|
15
- | `use_default_severity` | When `true`, and log record does not have severity, severity=`DEFAULT` would be added to log. default `false`. |
15
+ | `use_default_severity` | When `true`, and log record does not have severity, log_level=`DEFAULT` would be added to log. default `false`. |
16
+ | `lm_tenant_id` | tenant id to be added as event metadata. This will be added directly into metadata as `_lm.tenantId` |
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "fluent-plugin-lm-logs-gcp"
8
- spec.version = '1.0.6'
8
+ spec.version = '1.0.8'
9
9
  spec.authors = ["LogicMonitor"]
10
10
  spec.email = "rubygems@logicmonitor.com"
11
11
  spec.summary = "LogicMonitor with GCP logs fluentd filter plugin"
@@ -22,4 +22,4 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_runtime_dependency "fluentd", [">= 1", "< 2"]
24
24
  spec.add_development_dependency 'hashdiff', '>= 1.0.0'
25
- end
25
+ end
@@ -4,11 +4,13 @@ module Fluent::Plugin
4
4
  class GCPLMFilter < Filter
5
5
  Fluent::Plugin.register_filter('gcplm', self)
6
6
 
7
- METADATA_KEYS_TO_RENAME = {"trace" => "trace_id", "spanId" => "span_id","resource.type" => "_type"}.freeze
7
+ METADATA_KEYS_TO_RENAME = {"trace" => "trace_id", "spanId" => "span_id","resource.type" => "_type", "severity" => "log_level"}.freeze
8
8
  STATIC_METADATA = {"_integration" => "gcp"}
9
+ LM_TENANT_ID_KEY = "_lm.tenantId".freeze
9
10
 
10
11
  config_param :metadata_keys, :array, default: ["severity", "logName", "labels", "resource.type", "resource.labels", "httpRequest"], value_type: :string
11
- config_param :use_default_severity, :bool, default: false
12
+ config_param :use_default_severity, :bool, default: false
13
+ config_param :lm_tenant_id, :string, default: nil
12
14
 
13
15
  def configure(conf)
14
16
  super
@@ -21,9 +23,9 @@ module Fluent::Plugin
21
23
  @final_metadata_keys = Hash.new
22
24
  if @metadata_keys
23
25
  @metadata_keys.each do | nested_key |
24
- @final_metadata_keys[nested_key] = nested_key.to_s.split('.')
25
- end
26
- end
26
+ @final_metadata_keys[nested_key] = nested_key.to_s.split('.')
27
+ end
28
+ end
27
29
  super
28
30
  end
29
31
 
@@ -92,26 +94,32 @@ module Fluent::Plugin
92
94
  filteredRecord['timestamp'] = record['timestamp']
93
95
 
94
96
  # Add metadata
95
- if @final_metadata_keys
97
+ if @final_metadata_keys
96
98
  @final_metadata_keys.each do | key, value |
97
99
  final_key = METADATA_KEYS_TO_RENAME[key] ? METADATA_KEYS_TO_RENAME[key] : key
98
100
  nestedVal = record
99
101
  value.each { |x| nestedVal = nestedVal[x] }
100
102
  if nestedVal != nil
101
103
  filteredRecord[final_key] = nestedVal
102
- end
103
- end
104
- end
104
+ end
105
+ end
106
+ end
105
107
 
106
108
  # Add static metadata
107
109
  STATIC_METADATA.each { | key, value| filteredRecord[key] = value }
108
110
 
109
- # Add default severity if does not exist
110
- if !filteredRecord["severity"] and @use_default_severity
111
- filteredRecord["severity"] = "DEFAULT"
112
- end
113
-
111
+ # Add tenantid
112
+ tenant_id_from_record = record[LM_TENANT_ID_KEY]
113
+ if (tenant_id_from_record != nil)
114
+ filteredRecord[LM_TENANT_ID_KEY] = tenant_id_from_record
115
+ elsif @lm_tenant_id != nil && ! @lm_tenant_id.empty?
116
+ filteredRecord[LM_TENANT_ID_KEY] = @lm_tenant_id
117
+ end
118
+ # Add default severity if does not exist
119
+ if !filteredRecord["log_level"] and @use_default_severity
120
+ filteredRecord["log_level"] = "DEFAULT"
121
+ end
114
122
  filteredRecord
115
123
  end
116
124
  end
117
- end
125
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-lm-logs-gcp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - LogicMonitor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-05 00:00:00.000000000 Z
11
+ date: 2023-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd