Commit Graph

5 Commits (dc0c987358a47407a0c9697b374a3b3bd2f7ab03)

Author SHA1 Message Date
Dustin dc0c987358 burp: error: impl Display and Error
The `burp::error::Error` struct needs to implement the
`std::error::Error` trait (which requires that it also implement
`std::fmt::Display`) so that it can be used in dynamic dispatch
situations.  Notably, the `prometheus_exporter_base::render_prometheus`
function requires a closure that returns `Result<String, Box<dyn
std::error::Error>>`, so in order to use the `?` (early return)
operator on on the `metrics::get_metrics` function call, our error must
implement that trait.
2022-02-12 15:15:29 -06:00
Dustin c7feaa041a metrics: Add Prometheus metrics for BURP stats
The `metrics` module encapsulates the functionality for generating
Prometheus metrics from BURP stats.  Given a `BurpClient` instance, the
`get_metrics` function calls the necessary RPC methods to fetch the
latest backup statistics for each known BURP client.  It then generates
metrics in Prometheus plain text exposition format, using the excellent
[prometheus_exporter_base] crate.  The result is returned as a string,
which can then be used to produce an HTTP response to a Prometheus
scrape request.  The *prometheus_exporter_base* crate also provides a
simple HTTP server, based on [Hyper], which we will eventually use to
serve this response.

[prometheus_exporter_base]: https://github.com/MindFlavor/prometheus_exporter_base/
[Hyper]: https://hyper.rs/
2022-02-12 15:15:29 -06:00
Dustin 96849e6367 burp: Add client/backup info retrieval methods
The `get_clients`, `get_client`, `get_backup`, `get_backup_log`, and
`get_backup_stats` methods fetch information from the BURP server using
its JSON stats interface.  These will be used to populate the metrics we
want to export to Prometheus.
2022-02-10 19:17:33 -06:00
Dustin cfdb33d4a3 burp: Begin BURP stats client implementation
The `burp` module contains an implementation of a BURP stats client.  It
uses *tokio* for asynchronous network communication with the BURP stats
TCP socket.  The `ClientConnector` struct follows the builder pattern
for specifying connection options, ultimately producing a `Client`
struct that manages communication over the socket.

BURP uses mutual TLS authentication for all its communication.  The
client authenticates the server by verifying its certificate using a
trusted CA certificate.  This certificate is not usually trusted
system-wide, but specifically by BURP clients.  The server also
authenticates the client using a certificate.  The official BURP client
uses a normal PEM-encoded X.509 certificate and PKCS #8 key, however,
the *native-tls* library does not support loading these.  As such, the
certificate and private key must be encapsulated in a PKCS #12
container.
2022-02-08 21:35:00 -06:00
Dustin 727aaa6b8f Initial commit 2022-02-06 12:56:24 -06:00