Metrics
Karma collects metrics for most of its operations to provide insight into the application and hints on how to optimize it.
Configuration
Metrics can be accessed through the health-check endpoints.
The default configuation is:
'health-check':
server:
port: 9001
host: '127.0.0.1'
If the endpoints should be accessible from other hosts, you should bind to 0.0.0.0 or an external IP address of the host:
'health-check':
server:
host: '0.0.0.0'
All endpoints can be protected using access tokens. You can define one or more tokens:
'health-check':
server:
# openssl rand -base64 23 | tr -d '/+='
tokens:
- Nz1THLT4yTEZtt156DBePWDHM6Q9ibM
- kS1J60atX3CBtrK8nc1Udb2Q7aHVBcw
If no tokens are defined the endpoints are public accessible.
One of the configured token mus be included in the request either
in the Authorization header (Authorization: Bearer <token>) or as
query parameter (http://karma.server:9001/-/status?token= <token>).
For the curl examples below add: -H "Authorization: Bearer <token>"
Endpoints
Status
curl -X GET http://karma.server:9001/-/status
{
"cluster": {
"workers": {
"size": 1,
"missing": 0,
"connected": 1
}
},
"process": {
"uptime": 326.213
}
}
Prometheus Metrics
curl -X GET http://karma.server:9001/-/metrics
# HELP process_cpu_user_seconds_total Total user CPU time spent in seconds.
# TYPE process_cpu_user_seconds_total counter
process_cpu_user_seconds_total 5.163402000000001
# ... and a lot more