Monitoring Application
If your application has exposed metrics, you can easily tell the platform how to collect the metrics data from your app with metrics
capability.
Let’s run christianhxc/gorandom:1.0
as an example app. The app will emit random latencies as metrics.
- Prepare Appfile:
$ cat <<EOF > vela.yaml
name: metricapp
services:
metricapp:
type: webservice
image: christianhxc/gorandom:1.0
port: 8080
metrics:
enabled: true
format: prometheus
path: /metrics
port: 0
scheme: http
EOF
- Deploy the application:
$ vela up
- Check status:
$ vela status metricapp
About:
Name: metricapp
Namespace: default
Created at: 2020-11-11 17:00:59.436347573 -0800 PST
Updated at: 2020-11-11 17:01:06.511064661 -0800 PST
Services:
- Name: metricapp
Type: webservice
HEALTHY Ready: 1/1
Traits:
- ✅ metrics: Monitoring port: 8080, path: /metrics, format: prometheus, schema: http.
Last Deployment:
Created at: 2020-11-11 17:00:59 -0800 PST
Updated at: 2020-11-11T17:01:06-08:00
The metrics trait will automatically discover port and label to monitor if no parameters specified. If more than one ports found, it will choose the first one by default.
(Optional) Verify that the metrics are collected on Prometheus
Expose the port of Prometheus dashboard:
kubectl --namespace monitoring port-forward `kubectl -n monitoring get pods -l prometheus=oam -o name` 9090
Then access the Prometheus dashboard via http://localhost:9090/targets