fluent-plugin-node-exporter-metrics 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +9 -2
- data/fluent-plugin-node-exporter-metrics.gemspec +1 -1
- data/lib/fluent/plugin/in_node_exporter_metrics.rb +4 -3
- data/lib/fluent/plugin/node_exporter/cmetrics_dataschema_parser.rb +1 -1
- data/lib/fluent/plugin/node_exporter/meminfo_collector.rb +22 -14
- data/lib/fluent/plugin/node_exporter/netdev_collector.rb +12 -12
- data/lib/fluent/plugin/node_exporter/vmstat_collector.rb +10 -4
- data/test/plugin/test_in_node_exporter_metrics.rb +1 -1
- 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: a62cd74f3d7cf5b3e1dbca91ddf364d74ef624f5bbbf7fc4c433cb01fe0fe395
|
4
|
+
data.tar.gz: ef90042396cde24e70b97238ce3bf9d1d477f60ccada8e387c750edc13904976
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe568aa876e4f02e8c2ad36a89e41f6499c3fc6cbd7c0bb048c7e1f889e87e2b4deb6cfc1cbd3d952c1dd69423912d804203e8e0f9e245d75204583cf972ed91
|
7
|
+
data.tar.gz: 64aa9bb65c333d5add6fcad002da4225977b766b6bec9bea0f8f8bbfbe26e8761a432cf6fe5ce52f1a3bc40c92c9ff0b6b9a07413a59fa1308681b1ed28f6730
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# 0.2.0
|
2
|
+
|
3
|
+
## Release v0.2.0 - 2021/09/22
|
4
|
+
|
5
|
+
* Fixed memory leaks with meminfo, netdev and vmstat collectors
|
6
|
+
* Fixed a bug that raising wrong exception with CMetricsDataSchemaParser.
|
7
|
+
* Added a FAQ for cpufreq configuration
|
8
|
+
* Updated missing cmake 3.x install instruction for CentOS 7/RHEL 7
|
9
|
+
|
1
10
|
# 0.1.0
|
2
11
|
|
3
12
|
## Release v0.1.0 - 2021/09/21
|
data/README.md
CHANGED
@@ -22,13 +22,14 @@ Note that CMake 3.13 or later must be installed.
|
|
22
22
|
### CentOS 7/RHEL 7
|
23
23
|
|
24
24
|
```
|
25
|
-
$ sudo yum install
|
25
|
+
$ sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
|
26
|
+
$ sudo yum install libcap-ng-devel gcc cmake3 make
|
26
27
|
```
|
27
28
|
|
28
29
|
### CentOS 8/RHEL 8
|
29
30
|
|
30
31
|
```
|
31
|
-
$ sudo dnf install libcap-ng-devel gcc cmake
|
32
|
+
$ sudo dnf install libcap-ng-devel gcc cmake make
|
32
33
|
```
|
33
34
|
|
34
35
|
|
@@ -160,6 +161,12 @@ Here is the result.
|
|
160
161
|
2021-09-21 10:57:48.015023773 +0900 node_metrics: [{"name":"node_time_seconds","value":1.632189468,"desc":"System time in seconds since epoch (1970).","ts":1632189468014812147}]
|
161
162
|
```
|
162
163
|
|
164
|
+
## FAQ
|
165
|
+
|
166
|
+
### Why is error_class=Fluent::ConfigError error="Linux capability CAP_DAC_READ_SEARCH must be enabled" happen?
|
167
|
+
|
168
|
+
See [Prerequisite for cpufreq](docs/cpufreq.md#prerequisite) section for enabling cpufreq collector.
|
169
|
+
|
163
170
|
## Copyright
|
164
171
|
|
165
172
|
* Copyright(c) 2021- Kentaro Hayashi
|
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = "fluent-plugin-node-exporter-metrics"
|
6
|
-
spec.version = "0.
|
6
|
+
spec.version = "0.2.0"
|
7
7
|
spec.authors = ["Kentaro Hayashi"]
|
8
8
|
spec.email = ["hayashi@clear-code.com"]
|
9
9
|
|
@@ -110,20 +110,21 @@ module Fluent
|
|
110
110
|
|
111
111
|
def refresh_watchers
|
112
112
|
begin
|
113
|
-
|
113
|
+
serde = CMetrics::Serde.new
|
114
114
|
@collectors.each do |collector|
|
115
115
|
begin
|
116
116
|
collector.run
|
117
117
|
collector.cmetrics.each do |key, cmetric|
|
118
|
-
|
118
|
+
serde.concat(cmetric) if cmetric
|
119
119
|
end
|
120
120
|
rescue => e
|
121
121
|
$log.error(e.message)
|
122
122
|
end
|
123
123
|
end
|
124
124
|
record = {
|
125
|
-
"cmetrics" =>
|
125
|
+
"cmetrics" => serde.to_msgpack
|
126
126
|
}
|
127
|
+
serde = nil
|
127
128
|
es = OneEventStream.new(Fluent::EventTime.now, record)
|
128
129
|
router.emit_stream(@tag, es)
|
129
130
|
end
|
@@ -26,29 +26,37 @@ module Fluent
|
|
26
26
|
super(config)
|
27
27
|
|
28
28
|
@metrics = {}
|
29
|
+
meminfo_path = File.join(@procfs_path, "meminfo")
|
30
|
+
File.readlines(meminfo_path).each do |line|
|
31
|
+
metric_name, name, _ = parse_meminfo_line(line)
|
32
|
+
@gauge = CMetrics::Gauge.new
|
33
|
+
@gauge.create("node", "memory", name, "Memory information field #{metric_name}.")
|
34
|
+
@metrics[metric_name.intern] = @gauge
|
35
|
+
end
|
29
36
|
end
|
30
37
|
|
31
38
|
def run
|
32
39
|
meminfo_update
|
33
40
|
end
|
34
41
|
|
42
|
+
def parse_meminfo_line(line)
|
43
|
+
name, value, unit = line.split
|
44
|
+
name.delete!(":")
|
45
|
+
if name.end_with?("(anon)") or name.end_with?("(file)")
|
46
|
+
name.sub!(/\((anon)\)|\((file)\)/, "_\\1\\2")
|
47
|
+
end
|
48
|
+
if unit
|
49
|
+
name << "_bytes"
|
50
|
+
value = value.to_f * 1024
|
51
|
+
end
|
52
|
+
["node_memory_#{name}", name, value]
|
53
|
+
end
|
54
|
+
|
35
55
|
def meminfo_update
|
36
56
|
meminfo_path = File.join(@procfs_path, "meminfo")
|
37
57
|
File.readlines(meminfo_path).each do |line|
|
38
|
-
|
39
|
-
|
40
|
-
if name.end_with?("(anon)") or name.end_with?("(file)")
|
41
|
-
name.sub!(/\((anon)\)|\((file)\)/, "_\\1\\2")
|
42
|
-
end
|
43
|
-
if unit
|
44
|
-
name << "_bytes"
|
45
|
-
value = value.to_f * 1024
|
46
|
-
end
|
47
|
-
metric_name = "node_memory_#{name}"
|
48
|
-
@gauge = CMetrics::Gauge.new
|
49
|
-
@gauge.create("node", "memory", name, "#{name}.")
|
50
|
-
@gauge.set(value.to_f)
|
51
|
-
@metrics[metric_name.intern] = @gauge
|
58
|
+
metric_name, _, value = parse_meminfo_line(line)
|
59
|
+
@metrics[metric_name.intern].set(value.to_f)
|
52
60
|
end
|
53
61
|
end
|
54
62
|
|
@@ -26,6 +26,18 @@ module Fluent
|
|
26
26
|
super(config)
|
27
27
|
|
28
28
|
@metrics = {}
|
29
|
+
RECEIVE_FIELDS.each_with_index do |field, index|
|
30
|
+
metric_name = "receive_#{field}_total"
|
31
|
+
@counter = CMetrics::Counter.new
|
32
|
+
@counter.create("node", "network", metric_name, "Network device statistic #{metric_name}.", ["device"])
|
33
|
+
@metrics[metric_name.intern] = @counter
|
34
|
+
end
|
35
|
+
TRANSMIT_FIELDS.each_with_index do |field, index|
|
36
|
+
metric_name = "transmit_#{field}_total"
|
37
|
+
@counter = CMetrics::Counter.new
|
38
|
+
@counter.create("node", "network", metric_name, "Network device statistic #{metric_name}.", ["device"])
|
39
|
+
@metrics[metric_name.intern] = @counter
|
40
|
+
end
|
29
41
|
end
|
30
42
|
|
31
43
|
def run
|
@@ -49,18 +61,6 @@ module Fluent
|
|
49
61
|
|
50
62
|
def netdev_update
|
51
63
|
netdev_path = File.join(@procfs_path, "net/dev")
|
52
|
-
RECEIVE_FIELDS.each_with_index do |field, index|
|
53
|
-
metric_name = "receive_#{field}_total"
|
54
|
-
@counter = CMetrics::Counter.new
|
55
|
-
@counter.create("node", "network", metric_name, "Network device statistic #{metric_name}.", ["device"])
|
56
|
-
@metrics[metric_name.intern] = @counter
|
57
|
-
end
|
58
|
-
TRANSMIT_FIELDS.each_with_index do |field, index|
|
59
|
-
metric_name = "transmit_#{field}_total"
|
60
|
-
@counter = CMetrics::Counter.new
|
61
|
-
@counter.create("node", "network", metric_name, "Network device statistic #{metric_name}.", ["device"])
|
62
|
-
@metrics[metric_name.intern] = @counter
|
63
|
-
end
|
64
64
|
File.readlines(netdev_path).each_with_index do |line, index|
|
65
65
|
# net/dev must be 3 columns
|
66
66
|
if index == 0 and line.split("|").size != 3
|
@@ -28,6 +28,15 @@ module Fluent
|
|
28
28
|
super(config)
|
29
29
|
|
30
30
|
@metrics = {}
|
31
|
+
vmstat_path = File.join(@procfs_path, "vmstat")
|
32
|
+
File.readlines(vmstat_path).each do |line|
|
33
|
+
if VMSTAT_ENTRIES_REGEX.match?(line)
|
34
|
+
key, _ = line.split(' ', 2)
|
35
|
+
@untyped = CMetrics::Untyped.new
|
36
|
+
@untyped.create("node", "vmstat", key, "#{vmstat_path} information field #{key}.")
|
37
|
+
@metrics[key.intern] = @untyped
|
38
|
+
end
|
39
|
+
end
|
31
40
|
end
|
32
41
|
|
33
42
|
def run
|
@@ -39,10 +48,7 @@ module Fluent
|
|
39
48
|
File.readlines(vmstat_path).each do |line|
|
40
49
|
if VMSTAT_ENTRIES_REGEX.match?(line)
|
41
50
|
key, value = line.split(' ', 2)
|
42
|
-
@
|
43
|
-
@untyped.create("node", "vmstat", key, "#{vmstat_path} information field #{key}.")
|
44
|
-
@untyped.set(value.to_f)
|
45
|
-
@metrics[key.intern] = @untyped
|
51
|
+
@metrics[key.intern].set(value.to_f)
|
46
52
|
end
|
47
53
|
end
|
48
54
|
end
|
@@ -391,7 +391,7 @@ class NodeExporterMetricsInputTest < Test::Unit::TestCase
|
|
391
391
|
))
|
392
392
|
opts = []
|
393
393
|
fields.each do |field|
|
394
|
-
opts << {"ns"=>"node", "ss"=>"memory", "name"=>field, "desc"=>"#{field}."}
|
394
|
+
opts << {"ns"=>"node", "ss"=>"memory", "name"=>field, "desc"=>"Memory information field node_memory_#{field}."}
|
395
395
|
end
|
396
396
|
assert_equal([
|
397
397
|
fields.size,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-node-exporter-metrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kentaro Hayashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cmetrics
|