yabeda-prometheus2influxdb 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f15f494fc8c977f0d4f5bd61ac5234872165a902b1227fa1b299acd0758ea00
4
- data.tar.gz: 733c8ffb3ae626818364dee09e08dc0d5ee7c11706f8e4a244916fb16921b820
3
+ metadata.gz: f1a7af6485a7f682b94f632ebcb1443f339d268d1a930d699b1bc6e0bde54503
4
+ data.tar.gz: d2c67473c04d0ff6a5195d6058fa540748eff0d7d5ea508bca0e41cf30365942
5
5
  SHA512:
6
- metadata.gz: c7e85c6baac1cd1d9e24441550ec593a0e7fa8473dd1128b81673ade914873a8e28e3a76a29d2aba5cb1fb0b2911e97feffea177f227b7a9ae0493c1aa5d76eb
7
- data.tar.gz: 3e8532ce668138428d0bad5ca3c2220bbf7348b4496a01815c9e60d9f806892da0697d1888a8bf102a5ef5b41f8e17cac68a58b72e5a250202b7ce68c6d541ed
6
+ metadata.gz: ffcec5c4ef30f280586a00b18379994c23ff07500e15601dfdf78593c009796bc5222b9005fa36a9cafbff4e2fbb5e3168c370cbafaa628fc30826d6db07c259
7
+ data.tar.gz: 0020410b81275c0441b07d149998f0eb345cdc4a37fc59c31f7eec72dd7e4e7692d8624179a8e6b6bf2a262bc45146cc2064e81be7a8916fe893d557adfbeb04
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.0] - 2022-09-14
4
+
5
+ - Switch to prometheus-client-mmap
6
+
7
+ To be able to aggregate metrics from multiple processes on the same machine to reduce number of time series.
8
+
3
9
  ## [0.1.0] - 2022-09-01
4
10
 
5
11
  - Initial release
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yabeda
4
4
  class Prometheus2InfluxDB
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
@@ -3,7 +3,7 @@
3
3
  require "singleton"
4
4
 
5
5
  require "influxdb"
6
- require "yabeda/prometheus"
6
+ require "yabeda/prometheus/mmap"
7
7
 
8
8
  require_relative "prometheus2influxdb/config"
9
9
  require_relative "prometheus2influxdb/version"
@@ -22,12 +22,11 @@ module Yabeda
22
22
  instance.config.configured?
23
23
  end
24
24
 
25
- attr_reader :influxdb_client, :registry, :instance_label, :config
25
+ attr_reader :influxdb_client, :instance_label, :config
26
26
 
27
27
  def initialize
28
28
  @config = Config.new
29
29
  @influxdb_client = ::InfluxDB::Client.new(**config.to_h)
30
- @registry = Yabeda::Prometheus.registry
31
30
  @instance_label = "#{Socket.gethostname}##{Process.pid}"
32
31
  end
33
32
 
@@ -46,30 +45,13 @@ module Yabeda
46
45
  private
47
46
 
48
47
  def prepare_points
49
- Yabeda::Prometheus.registry.metrics.map do |metric|
50
- series = metric.name.to_s
51
- metric.values.map do |tags, value|
52
- tags = tags.merge(instance: instance_label)
53
- case metric
54
- when ::Prometheus::Client::Counter, ::Prometheus::Client::Gauge
55
- { series: series, tags: tags, values: { value: value } }
56
- when ::Prometheus::Client::Histogram
57
- histogram_points(series, tags, value)
58
- else
59
- raise NotImplementedError, "#{metric.class} isn't supported for exporting to InfluxDB yet"
60
- end
48
+ metrics = ::Prometheus::Client::Formats::Text.send(:load_metrics, ::Prometheus::Client.configuration.multiprocess_files_dir)
49
+ metrics.map do |_, samples:, **|
50
+ samples.map do |series, tags, value|
51
+ tags = Hash[tags].merge("instance" => instance_label)
52
+ { series: series, tags: tags, values: { value: value } }
61
53
  end
62
54
  end.flatten
63
55
  end
64
-
65
- def histogram_points(name, tags, bucketed_values)
66
- bucketed_values.map do |bucket, value|
67
- if bucket == "sum"
68
- { series: "#{name}_sum", tags: tags, values: { value: value } }
69
- else
70
- { series: "#{name}_bucket", tags: tags.merge("le" => bucket), values: { value: value } }
71
- end
72
- end
73
- end
74
56
  end
75
57
  end
@@ -30,5 +30,5 @@ Gem::Specification.new do |spec|
30
30
 
31
31
  spec.add_dependency "anyway_config"
32
32
  spec.add_dependency "influxdb"
33
- spec.add_dependency "yabeda-prometheus"
33
+ spec.add_dependency "yabeda-prometheus-mmap"
34
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yabeda-prometheus2influxdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Novikov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-01 00:00:00.000000000 Z
11
+ date: 2022-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: anyway_config
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: yabeda-prometheus
42
+ name: yabeda-prometheus-mmap
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="