fluent-plugin-dynatrace 0.1.2 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fluent/plugin/dynatrace_constants.rb +1 -1
- data/lib/fluent/plugin/out_dynatrace.rb +53 -14
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ed15669d3529fd2d869b4e620a38caee00310b2cc5a56bd3ea5d879b3e0a61a
|
4
|
+
data.tar.gz: a4cb4ba89820f96e07fc9b0f96bc9716d97c64d86987d6a7eee9e54bc8a69936
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d610192bd5c57739f5fb3a0cc37d4e2ab277a08b049ebf719051b624e755f67fc46392758042de0982b56bbd5ca2c821d88e9a8d481370899e7b0d20cb8f907
|
7
|
+
data.tar.gz: 232945ad4cc7cc31f01599700a465868b1e97159371b7a09a4ad8abac7347ae4ccdb8460831eea6c0ad632d2d4dd18defe951bc7f806a95a30263f369024dc4b
|
@@ -24,17 +24,24 @@ module Fluent
|
|
24
24
|
class DynatraceOutput < Output
|
25
25
|
Fluent::Plugin.register_output('dynatrace', self)
|
26
26
|
|
27
|
+
HTTP_REQUEST_LOCK = Mutex.new
|
28
|
+
|
27
29
|
helpers :compat_parameters # add :inject if need be
|
28
30
|
|
29
31
|
# Configurations
|
30
32
|
desc 'The full URL of the Dynatrace log ingestion endpoint, e.g. https://my-active-gate.example.com/api/logs/ingest'
|
31
33
|
config_param :active_gate_url, :string
|
32
|
-
desc 'The API token to use to authenticate requests to the log ingestion endpoint.
|
34
|
+
desc 'The API token to use to authenticate requests to the log ingestion endpoint. '\
|
35
|
+
'Must have logs.ingest (Ingest Logs) scope. '\
|
36
|
+
'It is recommended to limit scope to only this one.'
|
33
37
|
config_param :api_token, :string, secret: true
|
34
38
|
|
35
39
|
desc 'Disable SSL validation by setting :verify_mode OpenSSL::SSL::VERIFY_NONE'
|
36
40
|
config_param :ssl_verify_none, :bool, default: false
|
37
41
|
|
42
|
+
desc 'Inject timestamp into each log message'
|
43
|
+
config_param :inject_timestamp, :bool, default: false
|
44
|
+
|
38
45
|
#############################################
|
39
46
|
|
40
47
|
config_section :buffer do
|
@@ -74,20 +81,29 @@ module Fluent
|
|
74
81
|
#############################################
|
75
82
|
|
76
83
|
def process(_tag, es)
|
84
|
+
log.on_trace { log.trace('#process') }
|
85
|
+
records = 0
|
77
86
|
# es = inject_values_to_event_stream(tag, es)
|
78
|
-
es.each do |
|
79
|
-
|
87
|
+
es.each do |time, record|
|
88
|
+
records += 1
|
89
|
+
log.on_trace { log.trace("#process Processing record #{records}") }
|
90
|
+
record['@timestamp'] = time * 1000 if @inject_timestamp
|
91
|
+
synchronized_send_records(record)
|
80
92
|
end
|
93
|
+
log.on_trace { log.trace("#process Processed #{records} records") }
|
81
94
|
end
|
82
95
|
|
83
96
|
def write(chunk)
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
97
|
+
log.on_trace { log.trace('#write') }
|
98
|
+
records = []
|
99
|
+
chunk.each do |time, record|
|
100
|
+
# records.push(inject_values_to_record(chunk.metadata.tag, time, record))
|
101
|
+
record['@timestamp'] = time * 1000 if @inject_timestamp
|
102
|
+
records.push(record)
|
88
103
|
end
|
89
104
|
|
90
|
-
|
105
|
+
log.on_trace { log.trace("#write sent #{records.length} records") }
|
106
|
+
synchronized_send_records(records) unless records.empty?
|
91
107
|
end
|
92
108
|
|
93
109
|
#############################################
|
@@ -106,7 +122,8 @@ module Fluent
|
|
106
122
|
"fluent-plugin-dynatrace v#{DynatraceOutputConstants.version}"
|
107
123
|
end
|
108
124
|
|
109
|
-
def prepare_request
|
125
|
+
def prepare_request
|
126
|
+
log.on_trace { log.trace('#prepare_request') }
|
110
127
|
req = Net::HTTP::Post.new(uri, { 'User-Agent' => user_agent })
|
111
128
|
req['Content-Type'] = 'application/json; charset=utf-8'
|
112
129
|
req['Authorization'] = "Api-Token #{@api_token}"
|
@@ -114,15 +131,37 @@ module Fluent
|
|
114
131
|
req
|
115
132
|
end
|
116
133
|
|
117
|
-
def
|
134
|
+
def synchronized_send_records(records)
|
135
|
+
log.on_trace { log.trace('#synchronized_send_records') }
|
136
|
+
HTTP_REQUEST_LOCK.synchronize do
|
137
|
+
send_records(records)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def send_records(records)
|
142
|
+
log.on_trace { log.trace('#send_records') }
|
143
|
+
|
118
144
|
agent.start unless agent.started?
|
119
145
|
|
120
|
-
|
121
|
-
|
146
|
+
response = send_request(serialize(records))
|
147
|
+
|
148
|
+
return if response.is_a?(Net::HTTPSuccess)
|
122
149
|
|
123
|
-
|
150
|
+
raise failure_message response
|
151
|
+
end
|
152
|
+
|
153
|
+
def serialize(records)
|
154
|
+
log.on_trace { log.trace('#serialize') }
|
155
|
+
body = "#{records.to_json.chomp}\n"
|
156
|
+
log.on_trace { log.trace("#serialize body length #{body.length}") }
|
157
|
+
body
|
158
|
+
end
|
124
159
|
|
125
|
-
|
160
|
+
def send_request(body)
|
161
|
+
log.on_trace { log.trace('#send_request') }
|
162
|
+
response = @agent.request(prepare_request, body)
|
163
|
+
log.on_trace { log.trace("#send_request response #{response}") }
|
164
|
+
response
|
126
165
|
end
|
127
166
|
|
128
167
|
def failure_message(res)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-dynatrace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dynatrace Open Source Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -102,7 +102,7 @@ files:
|
|
102
102
|
- LICENSE
|
103
103
|
- lib/fluent/plugin/dynatrace_constants.rb
|
104
104
|
- lib/fluent/plugin/out_dynatrace.rb
|
105
|
-
homepage: https://
|
105
|
+
homepage: https://github.com/dynatrace-oss/fluent-plugin-dynatrace
|
106
106
|
licenses:
|
107
107
|
- Apache-2.0
|
108
108
|
metadata:
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
|
-
rubygems_version: 3.1.
|
127
|
+
rubygems_version: 3.1.6
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: A fluentd output plugin for sending logs to the Dynatrace Generic log ingest
|