prometheus_exporter 0.1.12 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +32 -5
- data/lib/prometheus_exporter/server/collector.rb +6 -0
- data/lib/prometheus_exporter/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 405a56b4f80812423e624398bc135af0ba955af9
|
4
|
+
data.tar.gz: 597a3f4587b851f436dafc8687a85c97373e5e06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2a19111517b005751654f0084e66300cc6e2c70207c1529ced65d84031b19aa90f218daf71e10624653c976213833e4bc88551371f21e627410fef6b8e9355e
|
7
|
+
data.tar.gz: 1c94b5f7d8606c0384211faeaf91e2595e154cbef85013764e7de3d0bda39c966527bd153696b8aa48418ade3c7507dccdb2104156a399638d706da9457bdadf
|
data/README.md
CHANGED
@@ -20,6 +20,10 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
$ gem install prometheus_exporter
|
22
22
|
|
23
|
+
## Can I have some pretty pictures please?
|
24
|
+
|
25
|
+
Sure, check out: [Instrumenting Rails with Prometheus](https://samsaffron.com/archive/2018/02/02/instrumenting-rails-with-prometheus)
|
26
|
+
|
23
27
|
## Usage
|
24
28
|
|
25
29
|
### Single process mode
|
@@ -199,13 +203,36 @@ bundle exec prometheus_exporter -a person_collector.rb
|
|
199
203
|
|
200
204
|
```
|
201
205
|
|
206
|
+
#### Global metrics in a custom type collector
|
207
|
+
|
208
|
+
Custom type collectors are the ideal place to collect global metrics, such as user/article counts and connection counts. The custom type collector runs in the collector which usually runs in the prometheus exporter process.
|
209
|
+
|
210
|
+
Out-of-the-box we try to keep the prometheus exporter as lean as possible, we do not load all the Rails dependencies so you will not have access to your models. You can always ensure it is loaded in your custom type collector with:
|
211
|
+
|
212
|
+
```
|
213
|
+
unless defined? Rails
|
214
|
+
require File.expand_path("../../config/environment", __FILE__)
|
215
|
+
end
|
216
|
+
```
|
217
|
+
|
218
|
+
Then you can collect the metrics you need on demand:
|
219
|
+
|
220
|
+
```
|
221
|
+
def metrics
|
222
|
+
user_count_gague = PrometheusExporter::Metric::Gauge.new('user_count', 'number of users in the app')
|
223
|
+
user_count_gague.observe User.count
|
224
|
+
[user_count_gauge]
|
225
|
+
end
|
226
|
+
```
|
227
|
+
|
228
|
+
The metrics endpoint is called whenever prometheus calls the `/metrics` HTTP endpoint, it may make sense to introduce some caching so database calls are only performed once every N seconds. [lru_redux](https://github.com/SamSaffron/lru_redux) is the perfect gem for that kind of job as you can `LruRedux::TTL::Cache` which will automatically expire after N seconds.
|
229
|
+
|
230
|
+
|
202
231
|
### Multi process mode with custom collector
|
203
232
|
|
204
233
|
You can opt for custom collector logic in a multi process environment.
|
205
234
|
|
206
|
-
This allows you
|
207
|
-
|
208
|
-
The standard collector ships "help", "type" and "name" for every metric, in some cases you may want to avoid sending all that data.
|
235
|
+
This allows you to completely replace the collector logic.
|
209
236
|
|
210
237
|
First, define a custom collector, it is critical you inherit off `PrometheusExporter::Server::Collector`, also it is critical you have custom implementations for #process and #prometheus_metrics_text
|
211
238
|
|
@@ -241,7 +268,7 @@ end
|
|
241
268
|
Next, launch the exporter process:
|
242
269
|
|
243
270
|
```bash
|
244
|
-
% bin/prometheus_exporter
|
271
|
+
% bin/prometheus_exporter --collector examples/custom_collector.rb
|
245
272
|
```
|
246
273
|
|
247
274
|
In your application ship it the metrics you want:
|
@@ -274,7 +301,7 @@ thing2 12
|
|
274
301
|
|
275
302
|
## Transport concerns
|
276
303
|
|
277
|
-
Prometheus Exporter handles transport using a simple HTTP protocol. In multi process mode we avoid needing a large number of HTTP request by using chunked encoding to send metrics. This means that a single HTTP channel can deliver 100s or even 1000s of metrics over a single HTTP session to the `/send-metrics` endpoint.
|
304
|
+
Prometheus Exporter handles transport using a simple HTTP protocol. In multi process mode we avoid needing a large number of HTTP request by using chunked encoding to send metrics. This means that a single HTTP channel can deliver 100s or even 1000s of metrics over a single HTTP session to the `/send-metrics` endpoint. All calls to `send` and `send_json` on the PrometheusExporter::Client class are **non-blocking** and batched.
|
278
305
|
|
279
306
|
The `/bench` directory has simple benchmark it is able to send through 10k messages in 500ms.
|
280
307
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prometheus_exporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
157
|
version: '0'
|
158
158
|
requirements: []
|
159
159
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.
|
160
|
+
rubygems_version: 2.5.2
|
161
161
|
signing_key:
|
162
162
|
specification_version: 4
|
163
163
|
summary: Prometheus Exporter
|