fluent-plugin-dynatrace 0.1.5 → 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 +48 -15
- metadata +2 -2
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
|
@@ -39,6 +39,9 @@ module Fluent
|
|
39
39
|
desc 'Disable SSL validation by setting :verify_mode OpenSSL::SSL::VERIFY_NONE'
|
40
40
|
config_param :ssl_verify_none, :bool, default: false
|
41
41
|
|
42
|
+
desc 'Inject timestamp into each log message'
|
43
|
+
config_param :inject_timestamp, :bool, default: false
|
44
|
+
|
42
45
|
#############################################
|
43
46
|
|
44
47
|
config_section :buffer do
|
@@ -78,20 +81,29 @@ module Fluent
|
|
78
81
|
#############################################
|
79
82
|
|
80
83
|
def process(_tag, es)
|
84
|
+
log.on_trace { log.trace('#process') }
|
85
|
+
records = 0
|
81
86
|
# es = inject_values_to_event_stream(tag, es)
|
82
|
-
es.each do |
|
83
|
-
|
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)
|
84
92
|
end
|
93
|
+
log.on_trace { log.trace("#process Processed #{records} records") }
|
85
94
|
end
|
86
95
|
|
87
96
|
def write(chunk)
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
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)
|
92
103
|
end
|
93
104
|
|
94
|
-
|
105
|
+
log.on_trace { log.trace("#write sent #{records.length} records") }
|
106
|
+
synchronized_send_records(records) unless records.empty?
|
95
107
|
end
|
96
108
|
|
97
109
|
#############################################
|
@@ -110,7 +122,8 @@ module Fluent
|
|
110
122
|
"fluent-plugin-dynatrace v#{DynatraceOutputConstants.version}"
|
111
123
|
end
|
112
124
|
|
113
|
-
def prepare_request
|
125
|
+
def prepare_request
|
126
|
+
log.on_trace { log.trace('#prepare_request') }
|
114
127
|
req = Net::HTTP::Post.new(uri, { 'User-Agent' => user_agent })
|
115
128
|
req['Content-Type'] = 'application/json; charset=utf-8'
|
116
129
|
req['Authorization'] = "Api-Token #{@api_token}"
|
@@ -118,17 +131,37 @@ module Fluent
|
|
118
131
|
req
|
119
132
|
end
|
120
133
|
|
121
|
-
def
|
134
|
+
def synchronized_send_records(records)
|
135
|
+
log.on_trace { log.trace('#synchronized_send_records') }
|
122
136
|
HTTP_REQUEST_LOCK.synchronize do
|
123
|
-
|
137
|
+
send_records(records)
|
138
|
+
end
|
139
|
+
end
|
124
140
|
|
125
|
-
|
126
|
-
|
141
|
+
def send_records(records)
|
142
|
+
log.on_trace { log.trace('#send_records') }
|
127
143
|
|
128
|
-
|
144
|
+
agent.start unless agent.started?
|
129
145
|
|
130
|
-
|
131
|
-
|
146
|
+
response = send_request(serialize(records))
|
147
|
+
|
148
|
+
return if response.is_a?(Net::HTTPSuccess)
|
149
|
+
|
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
|
159
|
+
|
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
|
132
165
|
end
|
133
166
|
|
134
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
|