Files
kubevela/docs/en/developers/extensions/set-metrics.md
T
Jianbo Sun fa58501a97 remove 3rd party dependency from default installation (#946)
* remove 3rd party dependency from default installation

* fix CI
2021-01-27 18:29:42 -08:00

2.2 KiB

Monitoring Application

Note: metrics is one of the extension capabilities installed from cap center, please install it if you can't find it in vela traits.

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:
  $ 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

The full specification of metrics could show up by $ vela show metrics or be found on its reference documentation

  1. Deploy the application:
$ vela up
  1. 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

Prometheus Dashboard