Monitoring for Vapor
Clone or download
MrLotU Add ability to filter out non internal routes
Signed-off-by: MrLotU <>
Latest commit 81b7f96 Dec 7, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
Sources Add ability to filter out non internal routes Dec 7, 2018
.gitignore Init May 29, 2018
LICENSE Create LICENSE Jun 2, 2018
Package.swift V2 Nov 21, 2018 Add ability to filter out non internal routes Dec 7, 2018


Vapor 3 Swift 4.1

VaporMonitoring is a Vapor 3 package for monitoring and providing metrics for your Vapor application. Built on top op SwiftMetrics and SwiftPrometheus. Vapor Monitoring provides the default SwiftMetrics metrics along with request specific metrics. Metrics are exposed using Prometheus.


Vapor Monitoring can be installed using SPM

.package(url: "", from: "2.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:

let router = try VaporMonitoring.setupMonitoring(&config, &services)
services.register(router, as: Router.self)

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 MonitoredResponder and MonitoredRouter.

By default, your prometheus metrics will be served at host:port/metrics and routes that don't have a routing closure, will be ignored to avoid exploding your prometheus logs. You can however customize this.

To customize your monitoring, add this to Configure.swift

let monitoringConfg = MonitoringConfig(prometheusRoute: "customRoute", onlyBuiltinRoutes: false)
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.