VaporMonitoring is a Vapor 3 package for monitoring and providing metrics for your Vapor application. Built on top op SwiftMetrics. Vapor Monitoring provides the default SwiftMetrics metrics along with request specific metrics. Metrics can be viewed using the provided dashboard or using Prometheus.
Vapor Monitoring can be installed using SPM
.package(url: "https://github.com/vapor-community/VaporMonitoring.git", from: "1.0.0")
Vapor Monitoring is easy to use, it requires only a few lines of code.
Vapor Monitoring requires a few things to work correclty, a
MonitoredRouter and a
MonitoredResponder are the most important ones.
To set up your monitoring, in your
Configure.swift file, add the following:
// If you don't use middleware use this: let router = try VaporMonitoring.setupMonitoring(&config, &services) services.register(router, as: Router.self) // If you use middleware use the following instead: let middlewareConfig = MiddlewareConfig() let router = try VaporMonitoring.setupMonitoring(&config, &services, &middlewareConfig) services.register(router, as: Router.self) // Add your own middleware here services.register(middlewareConfig)
What this does is load VaporMonitoring with the default configuration. This includes adding all required services to your apps services & setting some configuration prefferences to use the
By default, your dashboard will be served at
host:port/metrics and your prometheus metrics will be served at
host:port/prometheus-metrics. You can however customize this, as well as turning the dashboard/prometheus dashboard on or off. This also creates a HTTPServer running a WebSocketServer to power the dashboard.
To customize your monitoring, add this to
let monitoringConfg = MonitoringConfig(dashboard: false, prometheus: true, dashboardRoute: "", prometheusRoute: "customRoute") let router = try VaporMonitoring.setupMonitoring(&config, &services, monitoringConfg) services.register(router, as: Router.self)
In this case, you'd have your prometheus metrics at
host:port/customRoute and no dashboard would be provided.
Help us keep the lights on
1.0.0 - Jun 20, 2018
Vapor Monitoring V1.0.0, the first full release!
Vapor Monitoring now longer blocks any other Vapor functionality so you can use it with any project!
0.1.0 - Jun 19, 2018
First stable release of VaporMonitoring! 🎉
0.0.2 - Jun 4, 2018
Fixes a bug with