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.

  1. Prepare Appfile:
  1. $ cat <<EOF > vela.yaml
  2. name: metricapp
  3. services:
  4. metricapp:
  5. type: webservice
  6. image: christianhxc/gorandom:1.0
  7. port: 8080
  8. metrics:
  9. enabled: true
  10. format: prometheus
  11. path: /metrics
  12. port: 0
  13. scheme: http
  14. EOF
  1. Deploy the application:
  1. $ vela up
  1. Check status:
  1. $ vela status metricapp
  2. About:
  3. Name: metricapp
  4. Namespace: default
  5. Created at: 2020-11-11 17:00:59.436347573 -0800 PST
  6. Updated at: 2020-11-11 17:01:06.511064661 -0800 PST
  7. Services:
  8. - Name: metricapp
  9. Type: webservice
  10. HEALTHY Ready: 1/1
  11. Traits:
  12. - metrics: Monitoring port: 8080, path: /metrics, format: prometheus, schema: http.
  13. Last Deployment:
  14. Created at: 2020-11-11 17:00:59 -0800 PST
  15. 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:

  1. 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

Prometheus Dashboard