fluent-plugin-prometheus-smarter 1.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.rspec +2 -0
- data/.travis.yml +14 -0
- data/Gemfile +4 -0
- data/LICENSE +202 -0
- data/README.md +484 -0
- data/Rakefile +7 -0
- data/fluent-plugin-prometheus.gemspec +22 -0
- data/lib/fluent/plugin/filter_prometheus.rb +30 -0
- data/lib/fluent/plugin/in_prometheus.rb +222 -0
- data/lib/fluent/plugin/in_prometheus_monitor.rb +99 -0
- data/lib/fluent/plugin/in_prometheus_output_monitor.rb +202 -0
- data/lib/fluent/plugin/in_prometheus_tail_monitor.rb +95 -0
- data/lib/fluent/plugin/metric_prometheus.rb +71 -0
- data/lib/fluent/plugin/out_prometheus.rb +29 -0
- data/lib/fluent/plugin/prometheus.rb +296 -0
- data/lib/fluent/plugin/prometheus/placeholder_expander.rb +132 -0
- data/lib/fluent/plugin/prometheus_metrics.rb +77 -0
- data/misc/fluentd_sample.conf +170 -0
- data/misc/nginx_proxy.conf +22 -0
- data/misc/prometheus.yaml +13 -0
- data/misc/prometheus_alerts.yaml +59 -0
- data/spec/fluent/plugin/filter_prometheus_spec.rb +48 -0
- data/spec/fluent/plugin/in_prometheus_monitor_spec.rb +42 -0
- data/spec/fluent/plugin/in_prometheus_spec.rb +225 -0
- data/spec/fluent/plugin/in_prometheus_tail_monitor_spec.rb +42 -0
- data/spec/fluent/plugin/out_prometheus_spec.rb +43 -0
- data/spec/fluent/plugin/prometheus/placeholder_expander_spec.rb +110 -0
- data/spec/fluent/plugin/prometheus_metrics_spec.rb +138 -0
- data/spec/fluent/plugin/shared.rb +249 -0
- data/spec/spec_helper.rb +10 -0
- metadata +174 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 14f6d74f25a99bbb50495a9a4e8dfd451d1a1fd0f2c8a458444dc8fa08366edd
|
4
|
+
data.tar.gz: 8a678666bd43839f2c59450857c2f2f08f197e0d2618aa410c303ab6931d8dab
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f22e62078c028668c54ed0e68f7a5882a64e276b78f5d910a3429ea300257bf04b0a300de25c8c56550540e1834578b259071ba53a95d5f7713a0119d52492b5
|
7
|
+
data.tar.gz: 00b4dced745fe66e36a52fab5fc2453ba2573a6b43db728029f0639a7368025892820f83155129d846f3277b8cad1e6f294aa2f841fbeb48ad0bf5a02cb1dc59
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
178
|
+
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
180
|
+
|
181
|
+
To apply the Apache License to your work, attach the following
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
+
replaced with your own identifying information. (Don't include
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
185
|
+
comment syntax for the file format. We also recommend that a
|
186
|
+
file or class name and description of purpose be included on the
|
187
|
+
same "printed page" as the copyright notice for easier
|
188
|
+
identification within third-party archives.
|
189
|
+
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
191
|
+
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
+
you may not use this file except in compliance with the License.
|
194
|
+
You may obtain a copy of the License at
|
195
|
+
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
+
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
+
See the License for the specific language governing permissions and
|
202
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,484 @@
|
|
1
|
+
# fluent-plugin-prometheus, a plugin for [Fluentd](https://www.fluentd.org)
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/fluent/fluent-plugin-prometheus.svg?branch=master)](https://travis-ci.org/fluent/fluent-plugin-prometheus)
|
4
|
+
|
5
|
+
A fluent plugin that instruments metrics from records and exposes them via web interface. Intended to be used together with a [Prometheus server](https://github.com/prometheus/prometheus).
|
6
|
+
|
7
|
+
## Requirements
|
8
|
+
|
9
|
+
| fluent-plugin-prometheus | fluentd | ruby |
|
10
|
+
|--------------------------|------------|--------|
|
11
|
+
| 1.x.y | >= v0.14.8 | >= 2.1 |
|
12
|
+
| 0.x.y | >= v0.12.0 | >= 1.9 |
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'fluent-plugin-prometheus'
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
$ bundle
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
|
28
|
+
$ gem install fluent-plugin-prometheus
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
fluentd-plugin-prometheus includes 6 plugins.
|
33
|
+
|
34
|
+
- `prometheus` input plugin
|
35
|
+
- `prometheus_monitor` input plugin
|
36
|
+
- `prometheus_output_monitor` input plugin
|
37
|
+
- `prometheus_tail_monitor` input plugin
|
38
|
+
- `prometheus` output plugin
|
39
|
+
- `prometheus` filter plugin
|
40
|
+
|
41
|
+
See [sample configuration](./misc/fluentd_sample.conf), or try [tutorial](#try-plugin-with-nginx).
|
42
|
+
|
43
|
+
### prometheus input plugin
|
44
|
+
|
45
|
+
You have to configure this plugin to expose metrics collected by other Prometheus plugins.
|
46
|
+
This plugin provides a metrics HTTP endpoint to be scraped by a Prometheus server on 24231/tcp(default).
|
47
|
+
|
48
|
+
With following configuration, you can access http://localhost:24231/metrics on a server where fluentd running.
|
49
|
+
|
50
|
+
```
|
51
|
+
<source>
|
52
|
+
@type prometheus
|
53
|
+
</source>
|
54
|
+
```
|
55
|
+
|
56
|
+
More configuration parameters:
|
57
|
+
|
58
|
+
- `bind`: binding interface (default: '0.0.0.0')
|
59
|
+
- `port`: listen port (default: 24231)
|
60
|
+
- `metrics_path`: metrics HTTP endpoint (default: /metrics)
|
61
|
+
- `aggregated_metrics_path`: metrics HTTP endpoint (default: /aggregated_metrics)
|
62
|
+
|
63
|
+
When using multiple workers, each worker binds to port + `fluent_worker_id`.
|
64
|
+
To scrape metrics from all workers at once, you can access http://localhost:24231/aggregated_metrics.
|
65
|
+
|
66
|
+
### prometheus_monitor input plugin
|
67
|
+
|
68
|
+
This plugin collects internal metrics in Fluentd. The metrics are similar to/part of [monitor_agent](https://docs.fluentd.org/input/monitor_agent).
|
69
|
+
|
70
|
+
|
71
|
+
#### Exposed metrics
|
72
|
+
|
73
|
+
- `fluentd_status_buffer_queue_length`
|
74
|
+
- `fluentd_status_buffer_total_bytes`
|
75
|
+
- `fluentd_status_retry_count`
|
76
|
+
- `fluentd_status_buffer_newest_timekey` from fluentd v1.4.2
|
77
|
+
- `fluentd_status_buffer_oldest_timekey` from fluentd v1.4.2
|
78
|
+
|
79
|
+
#### Configuration
|
80
|
+
|
81
|
+
With following configuration, those metrics are collected.
|
82
|
+
|
83
|
+
```
|
84
|
+
<source>
|
85
|
+
@type prometheus_monitor
|
86
|
+
</source>
|
87
|
+
```
|
88
|
+
|
89
|
+
More configuration parameters:
|
90
|
+
|
91
|
+
- `<labels>`: additional labels for this metric (optional). See [Labels](#labels)
|
92
|
+
- `interval`: interval to update monitor_agent information in seconds (default: 5)
|
93
|
+
|
94
|
+
### prometheus_output_monitor input plugin
|
95
|
+
|
96
|
+
This plugin collects internal metrics for output plugin in Fluentd. This is similar to `prometheus_monitor` plugin, but specialized for output plugin. There are Many metrics `prometheus_monitor` does not include, such as `num_errors`, `retry_wait` and so on.
|
97
|
+
|
98
|
+
#### Exposed metrics
|
99
|
+
|
100
|
+
Metrics for output
|
101
|
+
|
102
|
+
- `fluentd_output_status_retry_count`
|
103
|
+
- `fluentd_output_status_num_errors`
|
104
|
+
- `fluentd_output_status_emit_count`
|
105
|
+
- `fluentd_output_status_retry_wait`
|
106
|
+
- current retry_wait computed from last retry time and next retry time
|
107
|
+
- `fluentd_output_status_emit_records`
|
108
|
+
- `fluentd_output_status_write_count`
|
109
|
+
- `fluentd_output_status_rollback_count`
|
110
|
+
- `fluentd_output_status_flush_time_count` from fluentd v1.6.0
|
111
|
+
- `fluentd_output_status_slow_flush_count` from fluentd v1.6.0
|
112
|
+
|
113
|
+
Metrics for buffer
|
114
|
+
|
115
|
+
- `fluentd_output_status_buffer_total_bytes`
|
116
|
+
- `fluentd_output_status_buffer_stage_length` from fluentd v1.6.0
|
117
|
+
- `fluentd_output_status_buffer_stage_byte_size` from fluentd v1.6.0
|
118
|
+
- `fluentd_output_status_buffer_queue_length`
|
119
|
+
- `fluentd_output_status_buffer_queue_byte_size` from fluentd v1.6.0
|
120
|
+
- `fluentd_output_status_buffer_newest_timekey` from fluentd v1.6.0
|
121
|
+
- `fluentd_output_status_buffer_oldest_timekey` from fluentd v1.6.0
|
122
|
+
- `fluentd_output_status_buffer_available_space_ratio` from fluentd v1.6.0
|
123
|
+
|
124
|
+
#### Configuration
|
125
|
+
|
126
|
+
With following configuration, those metrics are collected.
|
127
|
+
|
128
|
+
```
|
129
|
+
<source>
|
130
|
+
@type prometheus_output_monitor
|
131
|
+
</source>
|
132
|
+
```
|
133
|
+
|
134
|
+
More configuration parameters:
|
135
|
+
|
136
|
+
- `<labels>`: additional labels for this metric (optional). See [Labels](#labels)
|
137
|
+
- `interval`: interval to update monitor_agent information in seconds (default: 5)
|
138
|
+
|
139
|
+
### prometheus_tail_monitor input plugin
|
140
|
+
|
141
|
+
This plugin collects internal metrics for in_tail plugin in Fluentd. in_tail plugin holds internal state for files that the plugin is watching. The state is sometimes important to monitor plugins work correctly.
|
142
|
+
|
143
|
+
This plugin uses internal class of Fluentd, so it's easy to break.
|
144
|
+
|
145
|
+
#### Exposed metrics
|
146
|
+
|
147
|
+
- `fluentd_tail_file_position`
|
148
|
+
- Current bytes which plugin reads from the file
|
149
|
+
- `fluentd_tail_file_inode`
|
150
|
+
- inode of the file
|
151
|
+
|
152
|
+
Default labels:
|
153
|
+
|
154
|
+
- `plugin_id`: a value set for a plugin in configuration.
|
155
|
+
- `type`: plugin name. `in_tail` only for now.
|
156
|
+
- `path`: file path
|
157
|
+
|
158
|
+
#### Configuration
|
159
|
+
|
160
|
+
With following configuration, those metrics are collected.
|
161
|
+
|
162
|
+
```
|
163
|
+
<source>
|
164
|
+
@type prometheus_tail_monitor
|
165
|
+
</source>
|
166
|
+
```
|
167
|
+
|
168
|
+
More configuration parameters:
|
169
|
+
|
170
|
+
- `<labels>`: additional labels for this metric (optional). See [Labels](#labels)
|
171
|
+
- `interval`: interval to update monitor_agent information in seconds (default: 5)
|
172
|
+
|
173
|
+
### prometheus output/filter plugin
|
174
|
+
|
175
|
+
Both output/filter plugins instrument metrics from records. Both plugins have no impact against values of each records, just read.
|
176
|
+
|
177
|
+
Assuming you have following configuration and receiving message,
|
178
|
+
|
179
|
+
```
|
180
|
+
<match message>
|
181
|
+
@type stdout
|
182
|
+
</match>
|
183
|
+
```
|
184
|
+
|
185
|
+
```
|
186
|
+
message {
|
187
|
+
"foo": 100,
|
188
|
+
"bar": 200,
|
189
|
+
"baz": 300
|
190
|
+
}
|
191
|
+
```
|
192
|
+
|
193
|
+
In filter plugin style,
|
194
|
+
|
195
|
+
```
|
196
|
+
<filter message>
|
197
|
+
@type prometheus
|
198
|
+
<metric>
|
199
|
+
name message_foo_counter
|
200
|
+
type counter
|
201
|
+
desc The total number of foo in message.
|
202
|
+
key foo
|
203
|
+
</metric>
|
204
|
+
</filter>
|
205
|
+
|
206
|
+
<match message>
|
207
|
+
@type stdout
|
208
|
+
</match>
|
209
|
+
```
|
210
|
+
|
211
|
+
In output plugin style:
|
212
|
+
|
213
|
+
```
|
214
|
+
<filter message>
|
215
|
+
@type prometheus
|
216
|
+
<metric>
|
217
|
+
name message_foo_counter
|
218
|
+
type counter
|
219
|
+
desc The total number of foo in message.
|
220
|
+
key foo
|
221
|
+
</metric>
|
222
|
+
</filter>
|
223
|
+
|
224
|
+
<match message>
|
225
|
+
@type copy
|
226
|
+
<store>
|
227
|
+
@type prometheus
|
228
|
+
<metric>
|
229
|
+
name message_foo_counter
|
230
|
+
type counter
|
231
|
+
desc The total number of foo in message.
|
232
|
+
key foo
|
233
|
+
</metric>
|
234
|
+
</store>
|
235
|
+
<store>
|
236
|
+
@type stdout
|
237
|
+
</store>
|
238
|
+
</match>
|
239
|
+
```
|
240
|
+
|
241
|
+
With above configuration, the plugin collects a metric named `message_foo_counter` from key `foo` of each records.
|
242
|
+
|
243
|
+
You can access nested keys in records via dot or bracket notation (https://docs.fluentd.org/plugin-helper-overview/api-plugin-helper-record_accessor#syntax), for example: `$.kubernetes.namespace`, `$['key1'][0]['key2']`. The record accessor is enable only if the value starts with `$.` or `$[`.
|
244
|
+
|
245
|
+
See Supported Metric Type and Labels for more configuration parameters.
|
246
|
+
|
247
|
+
## Supported Metric Types
|
248
|
+
|
249
|
+
For details of each metric type, see [Prometheus documentation](http://prometheus.io/docs/concepts/metric_types/). Also see [metric name guide](http://prometheus.io/docs/practices/naming/).
|
250
|
+
|
251
|
+
### counter type
|
252
|
+
|
253
|
+
```
|
254
|
+
<metric>
|
255
|
+
name message_foo_counter
|
256
|
+
type counter
|
257
|
+
desc The total number of foo in message.
|
258
|
+
key foo
|
259
|
+
<labels>
|
260
|
+
tag ${tag}
|
261
|
+
host ${hostname}
|
262
|
+
foo bar
|
263
|
+
</labels>
|
264
|
+
</metric>
|
265
|
+
```
|
266
|
+
|
267
|
+
- `name`: metric name (required)
|
268
|
+
- `type`: metric type (required)
|
269
|
+
- `desc`: description of this metric (required)
|
270
|
+
- `key`: key name of record for instrumentation (**optional**)
|
271
|
+
- `<labels>`: additional labels for this metric (optional). See [Labels](#labels)
|
272
|
+
|
273
|
+
If key is empty, the metric values is treated as 1, so the counter increments by 1 on each record regardless of contents of the record.
|
274
|
+
|
275
|
+
### gauge type
|
276
|
+
|
277
|
+
```
|
278
|
+
<metric>
|
279
|
+
name message_foo_gauge
|
280
|
+
type gauge
|
281
|
+
desc The total number of foo in message.
|
282
|
+
key foo
|
283
|
+
<labels>
|
284
|
+
tag ${tag}
|
285
|
+
host ${hostname}
|
286
|
+
foo bar
|
287
|
+
</labels>
|
288
|
+
</metric>
|
289
|
+
```
|
290
|
+
|
291
|
+
- `name`: metric name (required)
|
292
|
+
- `type`: metric type (required)
|
293
|
+
- `desc`: description of metric (required)
|
294
|
+
- `key`: key name of record for instrumentation (required)
|
295
|
+
- `<labels>`: additional labels for this metric (optional). See [Labels](#labels)
|
296
|
+
|
297
|
+
### summary type
|
298
|
+
|
299
|
+
```
|
300
|
+
<metric>
|
301
|
+
name message_foo
|
302
|
+
type summary
|
303
|
+
desc The summary of foo in message.
|
304
|
+
key foo
|
305
|
+
<labels>
|
306
|
+
tag ${tag}
|
307
|
+
host ${hostname}
|
308
|
+
foo bar
|
309
|
+
</labels>
|
310
|
+
</metric>
|
311
|
+
```
|
312
|
+
|
313
|
+
- `name`: metric name (required)
|
314
|
+
- `type`: metric type (required)
|
315
|
+
- `desc`: description of metric (required)
|
316
|
+
- `key`: key name of record for instrumentation (required)
|
317
|
+
- `<labels>`: additional labels for this metric (optional). See [Labels](#labels)
|
318
|
+
|
319
|
+
### histogram type
|
320
|
+
|
321
|
+
```
|
322
|
+
<metric>
|
323
|
+
name message_foo
|
324
|
+
type histogram
|
325
|
+
desc The histogram of foo in message.
|
326
|
+
key foo
|
327
|
+
buckets 0.1, 1, 5, 10
|
328
|
+
<labels>
|
329
|
+
tag ${tag}
|
330
|
+
host ${hostname}
|
331
|
+
foo bar
|
332
|
+
</labels>
|
333
|
+
</metric>
|
334
|
+
```
|
335
|
+
|
336
|
+
- `name`: metric name (required)
|
337
|
+
- `type`: metric type (required)
|
338
|
+
- `desc`: description of metric (required)
|
339
|
+
- `key`: key name of record for instrumentation (required)
|
340
|
+
- `buckets`: buckets of record for instrumentation (optional)
|
341
|
+
- `<labels>`: additional labels for this metric (optional). See [Labels](#labels)
|
342
|
+
|
343
|
+
## Labels
|
344
|
+
|
345
|
+
See [Prometheus Data Model](http://prometheus.io/docs/concepts/data_model/) first.
|
346
|
+
|
347
|
+
You can add labels with static value or dynamic value from records. In `prometheus_monitor` input plugin, you can't use label value from records.
|
348
|
+
|
349
|
+
### labels section
|
350
|
+
|
351
|
+
```
|
352
|
+
<labels>
|
353
|
+
key1 value1
|
354
|
+
key2 value2
|
355
|
+
</labels>
|
356
|
+
```
|
357
|
+
|
358
|
+
All labels sections has same format. Each lines have key/value for label.
|
359
|
+
|
360
|
+
You can access nested fields in records via dot or bracket notation (https://docs.fluentd.org/plugin-helper-overview/api-plugin-helper-record_accessor#syntax), for example: `$.kubernetes.namespace`, `$['key1'][0]['key2']`. The record accessor is enable only if the value starts with `$.` or `$[`. Other values are handled as raw string as is and may be expanded by placeholder described later.
|
361
|
+
|
362
|
+
You can use placeholder for label values. The placeholders will be expanded from reserved values and records.
|
363
|
+
If you specify `${hostname}`, it will be expanded by value of a hostname where fluentd runs.
|
364
|
+
The placeholder for records is deprecated. Use record accessor syntax instead.
|
365
|
+
|
366
|
+
Reserved placeholders are:
|
367
|
+
|
368
|
+
- `${hostname}`: hostname
|
369
|
+
- `${worker_id}`: fluent worker id
|
370
|
+
- `${tag}`: tag name
|
371
|
+
- only available in Prometheus output/filter plugin
|
372
|
+
- `${tag_parts[N]}` refers to the Nth part of the tag.
|
373
|
+
- only available in Prometheus output/filter plugin
|
374
|
+
- `${tag_prefix[N]}` refers to the [0..N] part of the tag.
|
375
|
+
- only available in Prometheus output/filter plugin
|
376
|
+
- `${tag_suffix[N]}` refers to the [`tagsize`-1-N..] part of the tag.
|
377
|
+
- where `tagsize` is the size of tag which is splitted with `.` (when tag is `1.2.3`, then `tagsize` is 3)
|
378
|
+
- only available in Prometheus output/filter plugin
|
379
|
+
|
380
|
+
### top-level labels and labels inside metric
|
381
|
+
|
382
|
+
Prometheus output/filter plugin can have multiple metric section. Top-level labels section specifies labels for all metrics. Labels section inside metric section specifies labels for the metric. Both are specified, labels are merged.
|
383
|
+
|
384
|
+
```
|
385
|
+
<filter message>
|
386
|
+
@type prometheus
|
387
|
+
<metric>
|
388
|
+
name message_foo_counter
|
389
|
+
type counter
|
390
|
+
desc The total number of foo in message.
|
391
|
+
key foo
|
392
|
+
<labels>
|
393
|
+
key foo
|
394
|
+
data_type ${type}
|
395
|
+
</labels>
|
396
|
+
</metric>
|
397
|
+
<metric>
|
398
|
+
name message_bar_counter
|
399
|
+
type counter
|
400
|
+
desc The total number of bar in message.
|
401
|
+
key bar
|
402
|
+
<labels>
|
403
|
+
key bar
|
404
|
+
</labels>
|
405
|
+
</metric>
|
406
|
+
<labels>
|
407
|
+
tag ${tag}
|
408
|
+
hostname ${hostname}
|
409
|
+
</labels>
|
410
|
+
</filter>
|
411
|
+
```
|
412
|
+
|
413
|
+
In this case, `message_foo_counter` has `tag`, `hostname`, `key` and `data_type` labels.
|
414
|
+
|
415
|
+
|
416
|
+
## Try plugin with nginx
|
417
|
+
|
418
|
+
Checkout repository and setup.
|
419
|
+
|
420
|
+
```
|
421
|
+
$ git clone git://github.com/fluent/fluent-plugin-prometheus
|
422
|
+
$ cd fluent-plugin-prometheus
|
423
|
+
$ bundle install --path vendor/bundle
|
424
|
+
```
|
425
|
+
|
426
|
+
Download pre-compiled Prometheus binary and start it. It listens on 9090.
|
427
|
+
|
428
|
+
```
|
429
|
+
$ wget https://github.com/prometheus/prometheus/releases/download/v1.5.2/prometheus-1.5.2.linux-amd64.tar.gz -O - | tar zxf -
|
430
|
+
$ ./prometheus-1.5.2.linux-amd64/prometheus -config.file=./misc/prometheus.yaml -storage.local.path=./prometheus/metrics
|
431
|
+
```
|
432
|
+
|
433
|
+
Install Nginx for sample metrics. It listens on 80 and 9999.
|
434
|
+
|
435
|
+
```
|
436
|
+
$ sudo apt-get install -y nginx
|
437
|
+
$ sudo cp misc/nginx_proxy.conf /etc/nginx/sites-enabled/proxy
|
438
|
+
$ sudo chmod 777 /var/log/nginx && sudo chmod +r /var/log/nginx/*.log
|
439
|
+
$ sudo service nginx restart
|
440
|
+
```
|
441
|
+
|
442
|
+
Start fluentd with sample configuration. It listens on 24231.
|
443
|
+
|
444
|
+
```
|
445
|
+
$ bundle exec fluentd -c misc/fluentd_sample.conf -v
|
446
|
+
```
|
447
|
+
|
448
|
+
Generate some records by accessing nginx.
|
449
|
+
|
450
|
+
```
|
451
|
+
$ curl http://localhost/
|
452
|
+
$ curl http://localhost:9999/
|
453
|
+
```
|
454
|
+
|
455
|
+
Confirm that some metrics are exported via Fluentd.
|
456
|
+
|
457
|
+
```
|
458
|
+
$ curl http://localhost:24231/metrics
|
459
|
+
```
|
460
|
+
|
461
|
+
Then, make a graph on Prometheus UI. http://localhost:9090/
|
462
|
+
|
463
|
+
## Contributing
|
464
|
+
|
465
|
+
1. Fork it ( https://github.com/fluent/fluent-plugin-prometheus/fork )
|
466
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
467
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
468
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
469
|
+
5. Create a new Pull Request
|
470
|
+
|
471
|
+
|
472
|
+
## Copyright
|
473
|
+
|
474
|
+
<table>
|
475
|
+
<tr>
|
476
|
+
<td>Author</td><td>Masahiro Sano <sabottenda@gmail.com></td>
|
477
|
+
</tr>
|
478
|
+
<tr>
|
479
|
+
<td>Copyright</td><td>Copyright (c) 2015- Masahiro Sano</td>
|
480
|
+
</tr>
|
481
|
+
<tr>
|
482
|
+
<td>License</td><td>Apache License, Version 2.0</td>
|
483
|
+
</tr>
|
484
|
+
</table>
|