Currently in Beta - View old docs

Monitor the status of your Server

Depending on how you created your Kitura server you may already have metrics enabled.

Swift Metrics

What is Swift Metrics?

SwiftMetrics instruments the Swift runtime for performance monitoring. The monitoring data is provided back to the user either programatically via an API or visually with the included embedded dashboard.

SwiftMetrics provides the following built-in data collection sources:

Source Description
Environment Machine and runtime environment information
CPU Process and system CPU
Memory Process and system memory usage
HTTP HTTP metric information

Step 1: Adding Swift Metrics to your project

Import Swift Metrics to your project

import SwiftMetrics

You also need to import the Swift Metrics Dashboard

import SwiftMetricsDash

Step 2: Initilize Swift Metrics

Create an instance of Swift Metrics:

let sm = try SwiftMetrics()

Use this Swift Metrics instance to initilize the dashboard:

let smd = try SwiftMetricsDash(swiftMetricsInstance : sm)

By default, SwiftMetricsDash will start its own Kitura server and serve the page up under localhost:/swiftmetrics-dash

Step 3: Add Swift Metrics to your router instance

You can pass an existing Router object to SwiftMetricsDash from which to serve the page up on.

SwiftMetricsDash will then use whatever server you are using in your existing application:

let _ = try SwiftMetricsDash(swiftMetricsInstance: sm, endpoint: router)

Next steps

Coming Soon!

Back to top