File: mod_prometheus.html

package info (click to toggle)
proftpd-mod-prometheus 0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 984 kB
  • sloc: ansic: 7,459; perl: 5,314; sh: 3,314; makefile: 129
file content (268 lines) | stat: -rw-r--r-- 9,383 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
<!DOCTYPE html>
<html>
<head>
<title>ProFTPD module mod_prometheus</title>
</head>

<body bgcolor=white>

<hr>
<center>
<h2><b>ProFTPD module <code>mod_prometheus</code></b></h2>
</center>
<hr><br>

<p>
The purpose of the <code>mod_prometheus</code> module is to provide metrics
for scraping by <a href="https://prometheus.io/">Prometheus</a>.

<p>
Installation instructions are discussed <a href="#Installation">here</a>.
<b>Note</b> that <code>mod_prometheus</code> requires ProFTPD 1.3.7a or later.
Detailed notes on best practices for using this module are
<a href="#Usage">here</a>.

<p>
The most current version of <code>mod_prometheu</code> can be found at:
<pre>
  <a href="https://github.com/Castaglia/proftpd-mod_prometheus.git">https://github.com/Castaglia/proftpd-mod_prometheus.git</a>
</pre>

<h2>Author</h2>
<p>
Please contact TJ Saunders &lt;tj <i>at</i> castaglia.org&gt; with any
questions, concerns, or suggestions regarding this module.

<h2>Directives</h2>
<ul>
  <li><a href="#PrometheusEngine">PrometheusEngine</a>
  <li><a href="#PrometheusExporter">PrometheusExporter</a>
  <li><a href="#PrometheusLog">PrometheusLog</a>
  <li><a href="#PrometheusTables">PrometheusTables</a>
</ul>

<p>
<hr>
<h3><a name="PrometheusEngine">PrometheusEngine</a></h3>
<strong>Syntax:</strong> PrometheusEngine <em>on|off</em><br>
<strong>Default:</strong> off<br>
<strong>Context:</strong> server config</br>
<strong>Module:</strong> mod_prometheus<br>
<strong>Compatibility:</strong> 1.3.7a and later

<p>
The <code>PrometheusEngine</code> directive controls whether the
<code>mod_prometheus</code> module lists for Prometheus HTTP requests for
scraping metrics.

<p>
<hr>
<h3><a name="PrometheusExporter">PrometheusExporter</a></h3>
<strong>Syntax:</strong> PrometheusExporter <em>address[:port] [username password]</em><br>
<strong>Default:</strong> None<br>
<strong>Context:</strong> server config</br>
<strong>Module:</strong> mod_prometheus<br>
<strong>Compatibility:</strong> 1.3.7a and later

<p>
The <code>PrometheusExporter</code> directive configures the
<code>mod_prometheus</code> module to act as an exporter for scraping by
Prometheus.

<p>
<b>Note</b> that the <code>PrometheusExporter</code> directive is
<b>required</b>.

<p>
The <em>address</em> parameter can be an IP address or a DNS name; this
parameter configures the address/port on which <code>mod_prometheus</code>
will listen for Prometheus scrape requests.  By default, a port of 9273 is
assumed; use <em>address:port</em> to specify an alternate port, <i>e.g.</i>:
<pre>
  PrometheusExporter 0.0.0.0:19273
</pre>
Note that IPv6 addresses should be enclosed in square brackets, as they can
contain colons as well, <i>e.g.</i>:
<pre>
  PrometheusExporter [::]:19273
</pre>

<p>
HTTP basic authentication can be required by providing the optional
<em>username</em> and <em>password</em> parameters.  The following environment
variables can also be used, instead of configuring these credentials in the
config file:
<ul>
  <li><code>PROMETHEUS_USERNAME</code>
  <li><code>PROMETHEUS_PASSWORD</code>
</ul>

<p>
<hr>
<h3><a name="PrometheusLog">PrometheusLog</a></h3>
<strong>Syntax:</strong> PrometheusLog <em>path|"none"</em><br>
<strong>Default:</strong> None<br>
<strong>Context:</strong> server config</br>
<strong>Module:</strong> mod_prometheus<br>
<strong>Compatibility:</strong> 1.3.7a and later

<p>
The <code>PrometheusLog</code> directive is used to specify a log file for
<code>mod_prometheus</code>'s reporting.  The <em>path</em> parameter given
must be the full path to the file to use for logging.

<p>
Note that this path must <b>not</b> be to a world-writable directory and,
unless <code>AllowLogSymlinks</code> is explicitly set to <em>on</em>
(generally a bad idea), the path must <b>not</b> be a symbolic link.

<p>
<hr>
<h3><a name="PrometheusTables">PrometheusTables</a></h3>
<strong>Syntax:</strong> PrometheusTables <em>path</em><br>
<strong>Default:</strong> <em>None</em><br>
<strong>Context:</strong> server config<br>
<strong>Module:</strong> mod_prometheus<br>
<strong>Compatibility:</strong> 1.3.7a and later

<p>
The <code>PrometheusTables</code> directive is used to specify a directory that
<code>mod_prometheus</code> will use for storing its database files; these files
are used for tracking the various statistics reported via Prometheus.

<p>
Note that the <code>PrometheusTables</code> directive is <b>required</b>.

<p>
<hr>
<h2><a name="Usage">Usage</a></h2>

<p>
<b>Important Security Considerations</b><br>
Do <b>not</b> configure <code>mod_prometheus</code> to listen on a public
Internet address.  The information provided via <code>mod_prometheus</code>
can be used by attackers to gain more information about your running
<code>proftpd</code>, including being able to determine whether their logins
fail due to a wrong password (in which case, they know that that user name is
valid) or not.  It is <b>highly recommended</b> that you configure
<code>mod_prometheus</code> to only listen on internal/LAN addresses.
Furthermore, you should employ a firewall rule that <b>rejects</b> any TCP
connections from the public Internet to your <code>mod_prometheus</code>
exporter.

<p>
That said, things are a little different when running in an <i>e.g.</i>
Kubernetes cluster, with an isolated network.  In these cases, given that
Kubernetes pods will have dynamic IP addresses, the recommended configuration
<i>is</i> to listen on the wildcard address, <i>i.e.</i> "0.0.0.0".  This
works <i>because</i> the Kubernetes cluster network is already isolated from
the public Internet by default.

<p>
<b>Prometheus Exporter Process</b><br>
When <code>proftpd</code> starts up with <code>mod_prometheus</code> enabled,
the <code>mod_prometheus</code> module will fork a new process that acts as
the Prometheus exporter, receiving and responding to all scrape requests.
This exporter listening process automatically switches to the privileges
configured by the <code>User</code> and <code>Group</code> directives, and will
also automatically <b>chroot</b> itself to a subdirectory of the
<code>PrometheusTables</code> directory, after which all root privileges are
permanently dropped.

<p>
<b>Example Configuration</b><br>
The <code>mod_prometheus</code> module uses an HTTP server for listening for
Prometheus scrape requests.  Thus it does not require any separate
<code>&lt;VirtualHost&gt;</code> sections, and does not interfere with the
normal FTP operations.

<p>
Here is an example configuration for <code>mod_prometheus</code>:
<pre>
  &lt;IfModule mod_prometheus.c&gt;
    PrometheusEngine on
    PrometheusLog /etc/proftpd/prometheus/prometheus.log

    # Configure the exporter to listen on the default port
    PrometheusExporter 0.0.0.0

    # Configure the directory that mod_prometheus will use for its database files
    PrometheusTables /var/proftpd/prometheus
  &lt;/IfModule&gt;
</pre>

<p>
<b>Logging</b><br>
The <code>mod_prometheus</code> module supports different forms of logging.  The
main module logging is done via the
<a href="#PrometheusLog"><code>PrometheusLog</code></a> directive.  For
debugging purposes, the module also uses <a href="http://www.proftpd.org/docs/howto/Tracing.html">trace logging</a>, via the module-specific channels:
<ul>
  <li>prometheus
  <li>prometheus.db
  <li>prometheus.http
  <li>prometheus.metric
  <li>prometheus.metric.db
  <li>prometheus.registry
  <li>prometheus.text
</ul>

<p>
Thus for trace logging, to aid in debugging, you would use the following in
your <code>proftpd.conf</code>:
<pre>
  TraceLog /path/to/proftpd-trace.log
  Trace prometheus:20
</pre>
This trace logging can generate large files; it is intended for debugging
use only, and should be removed from any production configuration.

<p>
<hr>
<h2><a name="Installation">Installation</a></h2>
To install <code>mod_prometheus</code>, go to the third-party module area in
the proftpd source code and unpack the <code>mod_prometheus</code> source
tarball:
<pre>
  $ cd <i>proftpd-dir</i>/contrib/
  $ tar zxvf /path/to/mod_prometheus-<i>version</i>.tar.gz
</pre>
after unpacking the latest proftpd-1.3.<i>x</i> source code.  For including
<code>mod_prometheus</code> as a statically linked module:
<pre>
  $ ./configure --with-modules=mod_prometheus:...
</pre>
To build <code>mod_prometheus</code> as a DSO module:
<pre>
  $ ./configure --enable-dso --with-shared=mod_prometheus:...
</pre>
Then follow the usual steps:
<pre>
  $ make
  $ make install
</pre>
<b>Note</b>: <code>mod_prometheus</code> uses the
<a href="http://www.sqlite.org"><code>SQLite</code></a> library; thus the
<code>sqlite3</code> development library/headers <b>must</b> be installed for
building <code>mod_prometheus</code>.

<p>
It is <b>highly recommended</b> that SQLite 3.8.5 or later be used.  Problems
have been reported with <code>mod_prometheus</code> when SQLite 3.6.20 is used;
these problems disappeared once SQLite was upgraded to a newer version.

<b>Note</b>: <code>mod_prometheus</code> uses the
<a href="https://www.gnu.org/software/libmicrohttpd/"><code>libmicrohttpd</code></a> library; thus the <code>libmicrohttpd</code> development library/headers
<b>must</b> be installed for building <code>mod_prometheus</code>.

<p>
<hr>

<font size=2><b><i>
&copy; Copyright 2021 TJ Saunders<br>
 All Rights Reserved<br>
</i></b></font>

<hr>
</body>
</html>