NAV
shell

Basics

Authentication

You must pass a token to the metrics endpoint. This token is a credential passed to the app when it is bound to the service. Get the access token from the VCAP_SERVICES environment variable.

"VCAP_SERVICES": {
  "metrics-forwarder": [
   {
    "credentials": {
     "access_key": "[access_token]",
     "hostname": "[endpoint]"
    },
    "label": "metrics-forwarder",
    "name": "[service_instance_name]",
    "plan": "[plan]",
    "provider": null,
    "syslog_drain_url": null,
    "tags": [],
    "volume_mounts": []
   }
  ]
 }

Metrics

Post

Send custom metrics to be emitted

curl "https://example.com/v1/metrics" \ 
    -X POST \ 
    -H "Authorization: [token]" \ 
    -d '{
        "applications": [
        {
            "id": "[app_guid]",
            "instances": [
            {
                "id": "[instance_guid]",
                "index": "[index]",
                "metrics": [
                {
                    "name": "[metric_name]",
                    "type": "gauge",
                    "value": [metric_value],
                    "timestamp": [timestamp],
                    "unit": "[metric_unit]",
                    "tags": {
                        "[tag_key]": "[tag_value]"
                    }
                }]
            }]
        }]
      }'
Example Response
HTTP/1.1 202 ACCEPTED

HTTP Request

POST /v1/metrics

Custom Metrics
Parameter Type Description
applications list of a single application The application the metrics belong to
Application
Parameter Type Description
id string GUID of the application
instances list of instance The instances the metrics belong to
Instance
Parameter Type Description
id string GUID of the instance
index string The index of the application instance as reported by cloud controller
metrics list of metric The metrics that are to be emitted
Metric
Parameter Type Description Examples
name string Name of the metric (recommended: lowercase, separated by .) test.metric
type string Type of metric (Only gauge is supported) gauge
value float64 Value of the metric 12.21
timestamp int64 Timestamp in milliseconds (Not in the future and not older than 2 weeks) 1495210954564
unit string Unit that the metric’s value is in seconds
tags map of key:value pairs The tags to send with the metric {"user":"internal", "timezone":"America/New_York"}