Querying server metadata


Although your Cloud 66 Dashboard provides a complete view of all your applications, it can be useful to query metadata directly from a server. This can be useful for automating task management and status tracking, as well as for investigative tasks like debugging. The special metadata endpoint allows you to query a server’s metadata while you are logged into it (via SSH).

How to query metadata from a server

In order to manually query a server’s metadata, you must first log into the server via SSH. Once you are logged in, you can use the following command:

curl -s -H "Accept: application/json" https://$CLOUD66_ACCOUNT_API_KEY:X@app.cloud66.com/api/tooling/metadata/$CLOUD66_APPLICATION_API_KEY

Some important things to note:

The command above will return all the available metadata for the server. However, you can also query subsets of the metadata using the names for each element and sub-element. For example this command:

curl -s -H "Accept: application/json" https://$CLOUD66_ACCOUNT_API_KEY:X@app.cloud66.com/api/tooling/metadata/$CLOUD66_APPLICATION_API_KEY/deployment/triggered_by

…will return metadata about who triggered the last deployment.

Finally, when querying for metadata, it can be useful to parse the json response. We suggest installing and using jq for this. To install jq

apt install -y jq

Examples of available metadata

1. deployment information

$ curl -s -H "Accept: application/json" https://$CLOUD66_ACCOUNT_API_KEY:X@app.cloud66.com/api/tooling/metadata/$CLOUD66_APPLICATION_API_KEY/deployment | jq

  "response": {
    "finished_at": "2020-07-07T13:40:51Z",
    "outcome": {
      "code": 1,
      "meaning": "success"
    "started_at": "2020-07-07T13:37:35Z",
    "triggered_by": "your-email@yourdomain.com",
    "triggered_via": {
      "code": 0,
      "meaning": "web"

2. Server OS information

$ curl -s -H "Accept: application/json" https://$CLOUD66_ACCOUNT_API_KEY:X@app.cloud66.com/api/tooling/metadata/$CLOUD66_APPLICATION_API_KEY/server/os | jq

  "response": {
    "distro": "ubuntu",
    "version": "18.04"

3. Find out who deployed last (or currently)

$ curl -s -H "Accept: application/json" https://$CLOUD66_ACCOUNT_API_KEY:X@app.cloud66.com/api/tooling/metadata/$CLOUD66_APPLICATION_API_KEY/deployment/triggered_by | jq -r '.response'

Using metadata in a workflow

One handy way to call this method is via a deploy hook. For example, you might want to fetch the name of the person who deployed to a server and pass it to a task tracking or audit logging system.

The deploy hook to achieve that would look something like this:

- target: any
  execute: true
  apply_during: all 
  sudo: false
  inline: |
    #!/usr/bin/env bash
    current_deployer=$(curl -s -H "Accept: application/json" https://$CLOUD66_ACCOUNT_API_KEY:X@app.cloud66.com/api/tooling/metadata/$CLOUD66_APPLICATION_API_KEY/deployment/triggered_by | jq -r '.response')
    echo "Deployed by: $current_deployer"

This hook will fire as soon as deployment starts (first_thing) and will query the triggered_by field and store the value in a variable. You can then use this variable as you need!