Accessing metrics and logs through code

There are situations where you'd want to access metrics about
a deployment programmatically. For example, you might want to have a continuous integration script that checks the health of a deployment.

To access the metrics through code:

  1. Ask Improbable customer support via the helpdesk (for customers with a service agreement) or the forums to set up a metrics service account for you. They'll send you a username and password to use with HTTP basic authentication.

Make sure you use HTTPS when making requests against the monitoring proxy.

  1. Craft a Prometheus query. To do this:

  2. Run your query in code. Exactly how this looks will depend on your environment, but to get you started, see this example which uses curl below.

query="spatialos_worker_connected::sum{project=\"$project\", dpl=\"$deployment\", worker_type=\"MyCSharpWorker\"}"

curl -G "" \
    --user "longshot_user:$refresh_token" \
    --data-urlencode "query=$query"

Only create alerts using documented metrics.

Be careful with the queries you write: if they're very expensive, you may experience problems with the metrics or logging servers. If you're not sure, ask customer support to review the queries.

Don't set a refresh rate more frequent than 60 seconds: if the refresh rate is too frequent, requests from your dashboard may fail due to the restrictions on metric querying.

Updated about a year ago

Accessing metrics and logs through code

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.