Compare commits
No commits in common. "7cbb65afcb88d20bd6e26d5e2d46be20078f7719" and "44251fa2f78bda24997952f267c1616a9affb3cc" have entirely different histories.
7cbb65afcb
...
44251fa2f7
6 changed files with 427 additions and 530 deletions
|
@ -6,13 +6,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
## [v0.3.0] - 2021-04-19
|
|
||||||
### Added
|
|
||||||
- added healthcheck endpoint
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
- updated dependencies
|
|
||||||
|
|
||||||
## [v0.2.3] - 2020-04-08
|
## [v0.2.3] - 2020-04-08
|
||||||
### Fixed
|
### Fixed
|
||||||
- fix interval timings concurrent pings
|
- fix interval timings concurrent pings
|
||||||
|
|
917
Cargo.lock
generated
917
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "peshming"
|
name = "peshming"
|
||||||
version = "0.3.0"
|
version = "0.2.3"
|
||||||
authors = ["Jan Christian Grünhage <jan.christian@gruenhage.xyz>"]
|
authors = ["Jan Christian Grünhage <jan.christian@gruenhage.xyz>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "Pings configured hosts in a configurable intervals and exposes metrics for prometheus."
|
description = "Pings configured hosts in a configurable intervals and exposes metrics for prometheus."
|
||||||
|
|
|
@ -28,8 +28,3 @@ ARGS:
|
||||||
|
|
||||||
```
|
```
|
||||||
For configuration options, see the included sample config file.
|
For configuration options, see the included sample config file.
|
||||||
|
|
||||||
### Endpoints:
|
|
||||||
There's two endpoints available:
|
|
||||||
- `/metrics`, which serves the metrics
|
|
||||||
- `/health`, which should always return a 200 status code
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ pub(crate) fn setup_clap() -> clap::ArgMatches<'static> {
|
||||||
(about: crate_description!())
|
(about: crate_description!())
|
||||||
(@arg config: +required "Set config file")
|
(@arg config: +required "Set config file")
|
||||||
(@arg v: -v --verbose ... "Be verbose (you can add this up to 4 times for more logs).
|
(@arg v: -v --verbose ... "Be verbose (you can add this up to 4 times for more logs).
|
||||||
By default, only errors are logged, so no output is a good thing.")
|
By default, only errors are logged, so no output is a good thing.")
|
||||||
)
|
)
|
||||||
.get_matches()
|
.get_matches()
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,15 +49,7 @@ lazy_static! {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn serve_req(req: Request<Body>) -> std::result::Result<Response<Body>, hyper::Error> {
|
async fn serve_req(_req: Request<Body>) -> std::result::Result<Response<Body>, hyper::Error> {
|
||||||
match req.uri().path() {
|
|
||||||
"/metrics" => serve_metrics().await,
|
|
||||||
"/health" => serve_health_check().await,
|
|
||||||
_ => serve_not_found().await,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn serve_metrics() -> std::result::Result<Response<Body>, hyper::Error> {
|
|
||||||
let encoder = TextEncoder::new();
|
let encoder = TextEncoder::new();
|
||||||
|
|
||||||
HTTP_COUNTER.inc();
|
HTTP_COUNTER.inc();
|
||||||
|
@ -79,20 +71,6 @@ async fn serve_metrics() -> std::result::Result<Response<Body>, hyper::Error> {
|
||||||
Ok(response)
|
Ok(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn serve_health_check() -> std::result::Result<Response<Body>, hyper::Error> {
|
|
||||||
Ok(Response::builder()
|
|
||||||
.status(200)
|
|
||||||
.body(Body::from(vec![]))
|
|
||||||
.unwrap())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn serve_not_found() -> std::result::Result<Response<Body>, hyper::Error> {
|
|
||||||
Ok(Response::builder()
|
|
||||||
.status(404)
|
|
||||||
.body(Body::from(vec![]))
|
|
||||||
.unwrap())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) async fn start_serving_metrics(config: Config) -> std::result::Result<(), hyper::Error> {
|
pub(crate) async fn start_serving_metrics(config: Config) -> std::result::Result<(), hyper::Error> {
|
||||||
let serve_future = Server::bind(&config.listener).serve(make_service_fn(|_| async {
|
let serve_future = Server::bind(&config.listener).serve(make_service_fn(|_| async {
|
||||||
Ok::<_, hyper::Error>(service_fn(serve_req))
|
Ok::<_, hyper::Error>(service_fn(serve_req))
|
||||||
|
|
Loading…
Reference in a new issue