Get SpatialOS

Sites

Menu
These are the docs for 13.5, an old version of SpatialOS. 13.6 is the newest →

Accessing metrics 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. Obtain the refresh token for a service account with access to metrics for your project. See the the information on authentication for more details.

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

  2. Craft a Prometheus query. To do this:

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

project="your_project"
deployment="your_deployment"

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

curl -G "https://monitoring.service.improbable.io/@proxyhost/metrics.monitoring.spatial.improbable.io/api/v1/query" \
    --user "longshot_user:$refresh_token" \
    --data-urlencode "query=$query"

Search results

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums