> For the complete documentation index, see [llms.txt](https://docs.skyledge.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.skyledge.com/getting-started/developer-guide/creating-and-tracking-a-metric.md). Agents can also search and read this documentation through its [MCP server](https://docs.skyledge.com/~gitbook/mcp).

# Creating and Tracking a Metric

We’d like to see how much potion our Heroes have left, we can easily specify a gauge indicator alongside our assets.

### Create and Track a Metric

#### **Add Gauge to Hero Asset**

```
PUT api.skyledge.com/controlrooms/{controlRoomId}/asset-types/{assetTypeId}

{  
   "displaySettings":{  
      "MAP":[  
         {  
            "tagName":"slc-gauge",
            "options":{  
               "metric":"remainingPower",
               "unhealthy":"remainingPower <= 10"
            }
         }
      ]
   }
}

```

{% tabs %}
{% tab title="cURL" %}

```
curl --location --request POST 'https://api.skyledge.com/asset-types/ASSET_TYPE_ID/assets' \
--header 'X-Authorization: API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{  
   "displaySettings":{  
      "MAP":[  
         {  
            "tagName":"slc-gauge",
            "options":{  
               "metric":"remainingPower",
               "unhealthy":"remainingPower <= 10"
            }
         }
      ]
   }
}'
```

{% endtab %}

{% tab title="NodeJs" %}

```
import { Configuration, AssetRequest, AssetsApi } from '@skyledge/sdk';

const configuration = new Configuration({
  apiKey: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX',
  basePath: 'https://api.skyledge.com',
});

const data: AssetRequest = {
  displaySettings: {
    MAP: [
      {
        tagName: 'slc-gauge',
        options: {
          metric: 'remainingPower',
          unhealthy: 'remainingPower <= 10',
        },
      },
    ],
  },
} as any;

const assetIdentifier = ASSET_IDENTIFIER;

const assetApi = new AssetsApi(configuration);

const addMetric2Asset = await assetApi.updateAssetUsingAssetIdentifier(
  assetIdentifier,
  data,
);

console.log(addMetric2Asset.status);

```

{% endtab %}

{% tab title="Python" %}

```
import requests
import json

url = "https://api.skyledge.com/asset-types/ASSET_TYPE_ID/assets"

payload = json.dumps({
  "displaySettings": {
    "MAP": [
      {
        "tagName": "slc-gauge",
        "options": {
          "metric": "remainingPower",
          "unhealthy": "remainingPower <= 10"
        }
      }
    ]
  }
})
headers = {
  'X-Authorization': 'API_KEY',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}
{% endtabs %}

Notice that remainingPower refers to the metric we specified in Step 5. We can also create rules to indicate when the gauge indicator should enter an “unhealthy” warning state.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.skyledge.com/getting-started/developer-guide/creating-and-tracking-a-metric.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
