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.
PUT api.skyledge.com/controlrooms/{controlRoomId}/asset-types/{assetTypeId}
{
"displaySettings":{
"MAP":[
{
"tagName":"slc-gauge",
"options":{
"metric":"remainingPower",
"unhealthy":"remainingPower <= 10"
}
}
]
}
}
cURL
NodeJs
Python
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"
}
}
]
}
}'
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);
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)
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.
Last modified 8mo ago