prometheus_exporter 0.4.4 → 0.4.5
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82048f57a2ee65b704b92d2e74c2e8033215e0331c8604c1e45a63d16f8c3a1d
|
4
|
+
data.tar.gz: fc18bcc997f15bbdb182d5199543cd11e6ccad6a774ee838586b313eaa2a6de6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec6a0e811258775d28e2de42713481ddde3bbd40a7c6ec9773aaf1f0a557facf5b85a6ca00646b17747381c9b39481d5f3cb6b53a66db676b0bc30e74549990f
|
7
|
+
data.tar.gz: c15fb3209e8045e113169aaa884de7bc7bfe96d2cb20dcc6a1c57e3a82b68b828e4b513c0fc96e7b156f1dcc721055f036a37fe747a684f70a2b01f6eb238061
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
0.4.4 - 14-02-2019
|
2
|
+
|
3
|
+
- Feature: Allow process collector to ship custom labels for all process metrics
|
4
|
+
- Fix: Always scope process metrics on hostname in collector
|
5
|
+
|
1
6
|
0.4.3 - 11-02-2019
|
2
7
|
|
3
8
|
- Feature: Add alias for Gauge #observe called #set, this makes it a bit easier to migrate from prom
|
data/README.md
CHANGED
@@ -68,7 +68,7 @@ server.start
|
|
68
68
|
PrometheusExporter::Client.default = PrometheusExporter::LocalClient.new(collector: server.collector)
|
69
69
|
|
70
70
|
# this ensures basic process instrumentation metrics are added such as RSS and Ruby metrics
|
71
|
-
PrometheusExporter::Instrumentation::Process.start
|
71
|
+
PrometheusExporter::Instrumentation::Process.start(type: "my program", labels: {my_custom: "label for all process metrics"})
|
72
72
|
|
73
73
|
gauge = PrometheusExporter::Metric::Gauge.new("rss", "used RSS for process")
|
74
74
|
counter = PrometheusExporter::Metric::Counter.new("web_requests", "number of web requests")
|
@@ -3,8 +3,18 @@
|
|
3
3
|
# collects stats from currently running process
|
4
4
|
module PrometheusExporter::Instrumentation
|
5
5
|
class Process
|
6
|
-
def self.start(client: nil, type: "ruby", frequency: 30)
|
7
|
-
|
6
|
+
def self.start(client: nil, type: "ruby", frequency: 30, labels: nil)
|
7
|
+
|
8
|
+
metric_labels =
|
9
|
+
if labels && type
|
10
|
+
labels.merge(type: type)
|
11
|
+
elsif labels
|
12
|
+
labels
|
13
|
+
else
|
14
|
+
{ type: type }
|
15
|
+
end
|
16
|
+
|
17
|
+
process_collector = new(metric_labels)
|
8
18
|
client ||= PrometheusExporter::Client.default
|
9
19
|
|
10
20
|
stop if @thread
|
@@ -30,14 +40,26 @@ module PrometheusExporter::Instrumentation
|
|
30
40
|
end
|
31
41
|
end
|
32
42
|
|
33
|
-
def initialize(
|
34
|
-
@
|
43
|
+
def initialize(metric_labels)
|
44
|
+
@metric_labels = metric_labels
|
45
|
+
@hostname = nil
|
46
|
+
end
|
47
|
+
|
48
|
+
def hostname
|
49
|
+
@hostname ||=
|
50
|
+
begin
|
51
|
+
`hostname`.strip
|
52
|
+
rescue => e
|
53
|
+
STDERR.puts "Unable to lookup hostname #{e}"
|
54
|
+
"unknown-host"
|
55
|
+
end
|
35
56
|
end
|
36
57
|
|
37
58
|
def collect
|
38
59
|
metric = {}
|
39
60
|
metric[:type] = "process"
|
40
|
-
metric[:
|
61
|
+
metric[:metric_labels] = @metric_labels
|
62
|
+
metric[:hostname] = hostname
|
41
63
|
collect_gc_stats(metric)
|
42
64
|
collect_v8_stats(metric)
|
43
65
|
collect_process_stats(metric)
|
@@ -34,7 +34,7 @@ module PrometheusExporter::Server
|
|
34
34
|
metrics = {}
|
35
35
|
|
36
36
|
@process_metrics.map do |m|
|
37
|
-
metric_key =
|
37
|
+
metric_key = m["metric_labels"].merge("pid" => m["pid"])
|
38
38
|
|
39
39
|
PROCESS_GAUGES.map do |k, help|
|
40
40
|
k = k.to_s
|
@@ -62,8 +62,10 @@ module PrometheusExporter::Server
|
|
62
62
|
obj["created_at"] = now
|
63
63
|
|
64
64
|
@process_metrics.delete_if do |current|
|
65
|
-
obj["pid"] == current["pid"]
|
65
|
+
(obj["pid"] == current["pid"] && obj["hostname"] == current["hostname"]) ||
|
66
|
+
(current["created_at"] + MAX_PROCESS_METRIC_AGE < now)
|
66
67
|
end
|
68
|
+
|
67
69
|
@process_metrics << obj
|
68
70
|
end
|
69
71
|
end
|