Back to Collection Items
LOCAL loHttp
LOCAL lnSuccess
LOCAL loJson
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcTime
LOCAL lcSpace
LOCAL lcStrVal
LOCAL lcCreated_at
LOCAL lcInclude_percentiles
LOCAL lcMetric_type
LOCAL lcModified_at
LOCAL lcId
LOCAL lcV_Type
LOCAL i
LOCAL lnCount_i
* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')
* Use this online tool to generate code from sample JSON: Generate Code to Create JSON
* The following JSON is sent in the request body.
* {
* "data": {
* "id": "<string>",
* "type": "manage_tags",
* "attributes": {
* "tags": [
* ],
* "metric_type": "gauge",
* "aggregations": [
* {
* "time": "count",
* "space": "max"
* },
* {
* "time": "max",
* "space": "min"
* }
* ],
* "include_percentiles": "<boolean>"
* }
* }
* }
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateString("data.id","<string>")
loJson.UpdateString("data.type","manage_tags")
loJson.UpdateNewArray("data.attributes.tags")
loJson.UpdateString("data.attributes.metric_type","gauge")
loJson.UpdateString("data.attributes.aggregations[0].time","count")
loJson.UpdateString("data.attributes.aggregations[0].space","max")
loJson.UpdateString("data.attributes.aggregations[1].time","max")
loJson.UpdateString("data.attributes.aggregations[1].space","min")
loJson.UpdateString("data.attributes.include_percentiles","<boolean>")
loHttp.SetRequestHeader("Content-Type","application/json")
loHttp.SetRequestHeader("Accept","application/json")
loResp = loHttp.PostJson3("https://api.app.ddog-gov.com/api/v2/metrics/:metric_name/tags","application/json",loJson)
IF (loHttp.LastMethodSuccess = 0) THEN
? loHttp.LastErrorText
RELEASE loHttp
RELEASE loJson
CANCEL
ENDIF
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbResponseBody = CreateObject('Chilkat.StringBuilder')
loResp.GetBodySb(loSbResponseBody)
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJResp = CreateObject('Chilkat.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0
? "Response Body:"
? loJResp.Emit()
lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
? "Response Header:"
? loResp.Header
? "Failed."
RELEASE loResp
RELEASE loHttp
RELEASE loJson
RELEASE loSbResponseBody
RELEASE loJResp
CANCEL
ENDIF
RELEASE loResp
* Sample JSON response:
* (Sample code for parsing the JSON response is shown below)
* {
* "data": {
* "attributes": {
* "aggregations": [
* {
* "time": "avg",
* "space": "avg"
* },
* {
* "time": "count",
* "space": "min"
* }
* ],
* "created_at": "<dateTime>",
* "include_percentiles": "<boolean>",
* "metric_type": "gauge",
* "modified_at": "<dateTime>",
* "tags": [
* "<string>",
* "<string>"
* ]
* },
* "id": "<string>",
* "type": "manage_tags"
* }
* }
* Sample code for parsing the JSON response...
* Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
lcCreated_at = loJResp.StringOf("data.attributes.created_at")
lcInclude_percentiles = loJResp.StringOf("data.attributes.include_percentiles")
lcMetric_type = loJResp.StringOf("data.attributes.metric_type")
lcModified_at = loJResp.StringOf("data.attributes.modified_at")
lcId = loJResp.StringOf("data.id")
lcV_Type = loJResp.StringOf("data.type")
i = 0
lnCount_i = loJResp.SizeOfArray("data.attributes.aggregations")
DO WHILE i < lnCount_i
loJResp.I = i
lcTime = loJResp.StringOf("data.attributes.aggregations[i].time")
lcSpace = loJResp.StringOf("data.attributes.aggregations[i].space")
i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("data.attributes.tags")
DO WHILE i < lnCount_i
loJResp.I = i
lcStrVal = loJResp.StringOf("data.attributes.tags[i]")
i = i + 1
ENDDO
RELEASE loHttp
RELEASE loJson
RELEASE loSbResponseBody
RELEASE loJResp
Curl Command
curl -X POST
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"data": {
"id": "<string>",
"type": "manage_tags",
"attributes": {
"tags": [],
"metric_type": "gauge",
"aggregations": [
{
"time": "count",
"space": "max"
},
{
"time": "max",
"space": "min"
}
],
"include_percentiles": "<boolean>"
}
}
}'
https://api.app.ddog-gov.com/api/v2/metrics/:metric_name/tags
Postman Collection Item JSON
{
"name": "Create a tag configuration",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"data\": {\n \"id\": \"<string>\",\n \"type\": \"manage_tags\",\n \"attributes\": {\n \"tags\": [],\n \"metric_type\": \"gauge\",\n \"aggregations\": [\n {\n \"time\": \"count\",\n \"space\": \"max\"\n },\n {\n \"time\": \"max\",\n \"space\": \"min\"\n }\n ],\n \"include_percentiles\": \"<boolean>\"\n }\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/metrics/:metric_name/tags",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"metrics",
":metric_name",
"tags"
],
"variable": [
{
"key": "metric_name",
"value": "<string>"
}
]
},
"description": "Create and define a list of queryable tag keys for an existing count/gauge/rate/distribution metric.\nOptionally, include percentile aggregations on any distribution metric or configure custom aggregations\non any count, rate, or gauge metric.\nCan only be used with application keys of users with the `Manage Tags for Metrics` permission."
},
"response": [
{
"name": "Created",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"data\": {\n \"id\": \"<string>\",\n \"type\": \"manage_tags\",\n \"attributes\": {\n \"tags\": [],\n \"metric_type\": \"gauge\",\n \"aggregations\": [\n {\n \"time\": \"count\",\n \"space\": \"max\"\n },\n {\n \"time\": \"max\",\n \"space\": \"min\"\n }\n ],\n \"include_percentiles\": \"<boolean>\"\n }\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/metrics/:metric_name/tags",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"metrics",
":metric_name",
"tags"
],
"variable": [
{
"key": "metric_name"
}
]
}
},
"status": "Created",
"code": 201,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"data\": {\n \"attributes\": {\n \"aggregations\": [\n {\n \"time\": \"avg\",\n \"space\": \"avg\"\n },\n {\n \"time\": \"count\",\n \"space\": \"min\"\n }\n ],\n \"created_at\": \"<dateTime>\",\n \"include_percentiles\": \"<boolean>\",\n \"metric_type\": \"gauge\",\n \"modified_at\": \"<dateTime>\",\n \"tags\": [\n \"<string>\",\n \"<string>\"\n ]\n },\n \"id\": \"<string>\",\n \"type\": \"manage_tags\"\n }\n}"
},
{
"name": "Bad Request",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"data\": {\n \"id\": \"<string>\",\n \"type\": \"manage_tags\",\n \"attributes\": {\n \"tags\": [],\n \"metric_type\": \"gauge\",\n \"aggregations\": [\n {\n \"time\": \"count\",\n \"space\": \"max\"\n },\n {\n \"time\": \"max\",\n \"space\": \"min\"\n }\n ],\n \"include_percentiles\": \"<boolean>\"\n }\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/metrics/:metric_name/tags",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"metrics",
":metric_name",
"tags"
],
"variable": [
{
"key": "metric_name"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"<string>\",\n \"<string>\"\n ]\n}"
},
{
"name": "Forbidden",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"data\": {\n \"id\": \"<string>\",\n \"type\": \"manage_tags\",\n \"attributes\": {\n \"tags\": [],\n \"metric_type\": \"gauge\",\n \"aggregations\": [\n {\n \"time\": \"count\",\n \"space\": \"max\"\n },\n {\n \"time\": \"max\",\n \"space\": \"min\"\n }\n ],\n \"include_percentiles\": \"<boolean>\"\n }\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/metrics/:metric_name/tags",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"metrics",
":metric_name",
"tags"
],
"variable": [
{
"key": "metric_name"
}
]
}
},
"status": "Forbidden",
"code": 403,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"<string>\",\n \"<string>\"\n ]\n}"
},
{
"name": "Conflict",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"data\": {\n \"id\": \"<string>\",\n \"type\": \"manage_tags\",\n \"attributes\": {\n \"tags\": [],\n \"metric_type\": \"gauge\",\n \"aggregations\": [\n {\n \"time\": \"count\",\n \"space\": \"max\"\n },\n {\n \"time\": \"max\",\n \"space\": \"min\"\n }\n ],\n \"include_percentiles\": \"<boolean>\"\n }\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/metrics/:metric_name/tags",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"metrics",
":metric_name",
"tags"
],
"variable": [
{
"key": "metric_name"
}
]
}
},
"status": "Conflict",
"code": 409,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"<string>\",\n \"<string>\"\n ]\n}"
},
{
"name": "Too Many Requests",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"data\": {\n \"id\": \"<string>\",\n \"type\": \"manage_tags\",\n \"attributes\": {\n \"tags\": [],\n \"metric_type\": \"gauge\",\n \"aggregations\": [\n {\n \"time\": \"count\",\n \"space\": \"max\"\n },\n {\n \"time\": \"max\",\n \"space\": \"min\"\n }\n ],\n \"include_percentiles\": \"<boolean>\"\n }\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/metrics/:metric_name/tags",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"metrics",
":metric_name",
"tags"
],
"variable": [
{
"key": "metric_name"
}
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"<string>\",\n \"<string>\"\n ]\n}"
}
]
}