LATEST VERSION: 1.6 - RELEASE NOTES
PCF Metrics v1.6

Monitor Configuration

This topic describes how to configure event and metric monitors for your applications using PCF Metrics’ Beta monitors-api endpoint.

Note: You must have the appropriate permissions to view or manage application monitors in PCF Metrics.

View Monitors

You can use the following cURL and API commands to view event and metric monitors.

cURL

To view monitors using cURL, run the following command:

curl -H "Authorization: $(cf oauth-token)" -vvv -G "https://monitors-api.sys.DOMAIN/api/v1/$(cf app APP_NAME --guid)/monitors/" | jq

Where:

  • DOMAIN is your domain

  • APP_NAME is the name of your app

API

To view monitors via API, run the following command:

GET https://monitors-api.sys.DOMAIN/api/v1/APP_GUID/monitors/

Where:

  • DOMAIN is your domain

  • APP_GUID is the GUID of your app

Delete Monitors

You can use the following cURL and API commands to delete event and metric monitors.

cURL

To delete monitors using cURL, run the following command:

curl -H "Authorization: $(cf oauth-token)" -vvv -G "https://monitors-api.sys.DOMAIN/api/v1/$(cf app APP_NAME --guid)/monitors/MONITOR_GUID" -X DELETE

Where:

  • DOMAIN is your domain

  • APP_NAME is the name of your app

  • MONITOR_GUID is the GUID of your app

API

To delete monitors via API, run the following command:

DELETE https://monitors-api.sys.DOMAIN/api/v1/APP_GUID/monitors/MONITOR_GUID

Where:

  • DOMAIN is your domain

  • APP_GUID is the GUID of your app

  • MONITOR_GUID is the GUID of your app

Create Monitors

You can use the following cURL and API commands to create event and metric monitors.

The following attributes are optional and can be omitted from your commands if not needed:

  • warning_threshold
  • critical_webhook_url
  • critical_json_payload
  • warning_webhook_url
  • warning_json_payload

cURL

To create monitors using cURL, run the following command:

curl -H "Authorization: $(cf oauth-token)" "https://monitors-api.sys.DOMAIN/api/v1/$(cf app APP_NAME --guid)/monitors" -d '{ "metric_name": "cf.system.latency","metric_type": "gauge","metric_unit": "milliseconds","name": "monitor_name","snooze_time_in_minutes": 1,"threshold_comparator": "<=","critical_threshold": 100.0,"warning_threshold": 70.0,"critical_webhook_url": "critical_webhook_url","critical_json_payload": "critical_json_payload","warning_webhook_url": "warning_webhook_url","warning_json_payload": "warning_json_payload" }'

Where:

  • DOMAIN is your domain

  • APP_NAME is the name of your app

API

To create monitors via API, run the following command:

POST https://monitors-api.sys.DOMAIN/api/v1/APP_GUID/monitors/

Where:

  • DOMAIN is your domain

  • APP_GUID is the GUID of your app

And BODY:

{
    "name": "Lathrop CPU",
    "metric_name": "cf.system.cpu",
    "metric_type": "gauge",
    "metric_unit": "percentage",
    "snooze_time_in_minutes": 15,
    "threshold_comparator": ">=",
    "critical_threshold": 10,
    "warning_threshold": 5,
    "critical_webhook_url": "",
    "critical_json_payload": "",
    "warning_webhook_url": "",
    "warning_json_payload": ""
}

View Triggered Monitors

You can use the following cURL and API commands to view triggered event and metric monitors.

cURL

To view triggered monitors using cURL, run the following command:

curl -H "Authorization: $(cf oauth-token)" -vvv -G "https://monitors-api.sys.DOMAIN/api/v1/$(cf app APP_NAME --guid)/triggered_monitors/" | jq

Where:

  • DOMAIN is your domain

  • APP_NAME is the name of your app

API

To view triggered monitors via API, run the following command:

GET https://monitors-api.sys.DOMAIN/api/v1/APP_GUID/triggered_monitors/

Where:

  • DOMAIN is your domain

  • APP_GUID is the GUID of your app

Configure Monitors via YAML

In addition to configuring monitors directly via API, you can also automate monitors configuration via YAML file.

To automate monitor configuration via YAML file, create a YAML file using the YAML File Format Examples below, then run the following command:

curl -H "Authorization: $(cf oauth-token)" -H "Content-Type: application/yaml" --data-binary "@/PATH-TO-FILE.yml" -k "https://monitors-api.sys.DOMAIN/api/v1/$(cf app APP_NAME --guid)/monitors/" -vvv -X PUT

Where:

  • DOMAIN is your domain

  • APP_NAME is the name of your app

YAML File Format Examples

The examples below show the correct format for automating monitor configuration via YAML file.

The following attributes are optional and can be omitted from your YAML file if not needed:

  • warning_threshold
  • critical_webhook_url
  • critical_json_payload
  • warning_webhook_url
  • warning_json_payload

YAML Format for Metric Monitors

The following is an example YAML file for configuring a metric monitor.

---
- metric_name: cf.system.latency
  metric_type: gauge
  metric_unit: milliseconds
  name: Latency
  snooze_time_in_minutes: 1
  threshold_comparator: ">="
  critical_threshold: 60
  warning_threshold: 50
  critical_webhook_url: critical_webhook_url
  critical_json_payload: critical_json_payload
  warning_webhook_url: warning_webhook_url
  warning_json_payload: warning_json_payload

YAML Format for Event Monitors

The following is an example YAML file for configuring an event monitor.

---
- metric_name: cf.system.events.start
  metric_type: event
  metric_unit: per minute
  name: App Start
  snooze_time_in_minutes: 1
  threshold_comparator: ">="
  critical_threshold: 1
  warning_threshold: 0
  critical_webhook_url: critical_webhook_url
  critical_json_payload: critical_json_payload
  warning_webhook_url: warning_webhook_url
  warning_json_payload: warning_json_payload

YAML Format for Multiple Monitors

The following is an example YAML file for configuring multiple monitors.

---
- metric_name: cf.system.latency
  metric_type: gauge
  metric_unit: milliseconds
  name: Latency
  snooze_time_in_minutes: 1
  threshold_comparator: ">="
  critical_threshold: 60
  warning_threshold: 50
- metric_name: cf.system.cpu
  metric_type: gauge
  metric_unit: percentage
  name: CPU
  snooze_time_in_minutes: 1
  threshold_comparator: ">="
  critical_threshold: 60
  warning_threshold: 50
- metric_name: cf.system.events.start
  metric_type: event
  metric_unit: per minute
  name: App Start
  snooze_time_in_minutes: 1
  threshold_comparator: ">="
  critical_threshold: 1
  warning_threshold: 0
- metric_name: cf.system.memory
  metric_type: gauge
  metric_unit: percentage
  name: Lathrop Memory
  snooze_time_in_minutes: 5
  threshold_comparator: ">="
  critical_threshold: 10
  warning_threshold: 5
Create a pull request or raise an issue on the source for this page in GitHub