PowerBuilder / Datadog API Collection / Tag Configuration Cardinality Estimator
Back to Collection Items
integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_QueryParams
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Estimate_type
string ls_Estimated_at
string ls_Estimated_output_series
string ls_Id
string ls_V_Type
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_QueryParams = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_QueryParams.ConnectToNewObject("Chilkat.JsonObject")
loo_QueryParams.UpdateString("filter[groups]","<string>")
loo_QueryParams.UpdateString("filter[hours_ago]","<integer>")
loo_QueryParams.UpdateString("filter[num_aggregations]","<integer>")
loo_QueryParams.UpdateString("filter[pct]","<boolean>")
loo_QueryParams.UpdateString("filter[timespan_h]","<integer>")
loo_Http.SetRequestHeader("Accept","application/json")
loo_Resp = loo_Http.QuickRequestParams("GET","https://api.app.ddog-gov.com/api/v2/metrics/:metric_name/estimate",loo_QueryParams)
if loo_Http.LastMethodSuccess = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_QueryParams
return
end if
loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")
loo_Resp.GetBodySb(loo_SbResponseBody)
loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")
loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0
Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()
li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
Write-Debug "Response Header:"
Write-Debug loo_Resp.Header
Write-Debug "Failed."
destroy loo_Resp
destroy loo_Http
destroy loo_QueryParams
destroy loo_SbResponseBody
destroy loo_JResp
return
end if
destroy loo_Resp
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "data": {
// "attributes": {
// "estimate_type": "count_or_gauge",
// "estimated_at": "<dateTime>",
// "estimated_output_series": "<long>"
// },
// "id": "<string>",
// "type": "metric_cardinality_estimate"
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
ls_Estimate_type = loo_JResp.StringOf("data.attributes.estimate_type")
ls_Estimated_at = loo_JResp.StringOf("data.attributes.estimated_at")
ls_Estimated_output_series = loo_JResp.StringOf("data.attributes.estimated_output_series")
ls_Id = loo_JResp.StringOf("data.id")
ls_V_Type = loo_JResp.StringOf("data.type")
destroy loo_Http
destroy loo_QueryParams
destroy loo_SbResponseBody
destroy loo_JResp
Curl Command
curl -G -d "filter[groups]=%3Cstring%3E"
-d "filter[hours_ago]=%3Cinteger%3E"
-d "filter[num_aggregations]=%3Cinteger%3E"
-d "filter[pct]=%3Cboolean%3E"
-d "filter[timespan_h]=%3Cinteger%3E"
-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v2/metrics/:metric_name/estimate
Postman Collection Item JSON
{
"name": "Tag Configuration Cardinality Estimator",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/metrics/:metric_name/estimate?filter[groups]=<string>&filter[hours_ago]=<integer>&filter[num_aggregations]=<integer>&filter[pct]=<boolean>&filter[timespan_h]=<integer>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"metrics",
":metric_name",
"estimate"
],
"query": [
{
"key": "filter[groups]",
"value": "<string>",
"description": "Filtered tag keys that the metric is configured to query with."
},
{
"key": "filter[hours_ago]",
"value": "<integer>",
"description": "The number of hours of look back (from now) to estimate cardinality with."
},
{
"key": "filter[num_aggregations]",
"value": "<integer>",
"description": "The number of aggregations that a `count`, `rate`, or `gauge` metric is configured to use. Max number of aggregation combos is 9."
},
{
"key": "filter[pct]",
"value": "<boolean>",
"description": "A boolean, for distribution metrics only, to estimate cardinality if the metric includes additional percentile aggregators."
},
{
"key": "filter[timespan_h]",
"value": "<integer>",
"description": "A window, in hours, from the look back to estimate cardinality with."
}
],
"variable": [
{
"key": "metric_name",
"value": "<string>"
}
]
},
"description": "Returns the estimated cardinality for a metric with a given tag, percentile and number of aggregations configuration using Metrics without Limits™."
},
"response": [
{
"name": "Success",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/metrics/:metric_name/estimate?filter[groups]=<string>&filter[hours_ago]=<integer>&filter[num_aggregations]=<integer>&filter[pct]=<boolean>&filter[timespan_h]=<integer>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"metrics",
":metric_name",
"estimate"
],
"query": [
{
"key": "filter[groups]",
"value": "<string>",
"description": "Filtered tag keys that the metric is configured to query with."
},
{
"key": "filter[hours_ago]",
"value": "<integer>",
"description": "The number of hours of look back (from now) to estimate cardinality with."
},
{
"key": "filter[num_aggregations]",
"value": "<integer>",
"description": "The number of aggregations that a `count`, `rate`, or `gauge` metric is configured to use. Max number of aggregation combos is 9."
},
{
"key": "filter[pct]",
"value": "<boolean>",
"description": "A boolean, for distribution metrics only, to estimate cardinality if the metric includes additional percentile aggregators."
},
{
"key": "filter[timespan_h]",
"value": "<integer>",
"description": "A window, in hours, from the look back to estimate cardinality with."
}
],
"variable": [
{
"key": "metric_name"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"data\": {\n \"attributes\": {\n \"estimate_type\": \"count_or_gauge\",\n \"estimated_at\": \"<dateTime>\",\n \"estimated_output_series\": \"<long>\"\n },\n \"id\": \"<string>\",\n \"type\": \"metric_cardinality_estimate\"\n }\n}"
},
{
"name": "API error response.",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/metrics/:metric_name/estimate?filter[groups]=<string>&filter[hours_ago]=<integer>&filter[num_aggregations]=<integer>&filter[pct]=<boolean>&filter[timespan_h]=<integer>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"metrics",
":metric_name",
"estimate"
],
"query": [
{
"key": "filter[groups]",
"value": "<string>",
"description": "Filtered tag keys that the metric is configured to query with."
},
{
"key": "filter[hours_ago]",
"value": "<integer>",
"description": "The number of hours of look back (from now) to estimate cardinality with."
},
{
"key": "filter[num_aggregations]",
"value": "<integer>",
"description": "The number of aggregations that a `count`, `rate`, or `gauge` metric is configured to use. Max number of aggregation combos is 9."
},
{
"key": "filter[pct]",
"value": "<boolean>",
"description": "A boolean, for distribution metrics only, to estimate cardinality if the metric includes additional percentile aggregators."
},
{
"key": "filter[timespan_h]",
"value": "<integer>",
"description": "A window, in hours, from the look back to estimate cardinality with."
}
],
"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": "API error response.",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/metrics/:metric_name/estimate?filter[groups]=<string>&filter[hours_ago]=<integer>&filter[num_aggregations]=<integer>&filter[pct]=<boolean>&filter[timespan_h]=<integer>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"metrics",
":metric_name",
"estimate"
],
"query": [
{
"key": "filter[groups]",
"value": "<string>",
"description": "Filtered tag keys that the metric is configured to query with."
},
{
"key": "filter[hours_ago]",
"value": "<integer>",
"description": "The number of hours of look back (from now) to estimate cardinality with."
},
{
"key": "filter[num_aggregations]",
"value": "<integer>",
"description": "The number of aggregations that a `count`, `rate`, or `gauge` metric is configured to use. Max number of aggregation combos is 9."
},
{
"key": "filter[pct]",
"value": "<boolean>",
"description": "A boolean, for distribution metrics only, to estimate cardinality if the metric includes additional percentile aggregators."
},
{
"key": "filter[timespan_h]",
"value": "<integer>",
"description": "A window, in hours, from the look back to estimate cardinality with."
}
],
"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": "API error response.",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/metrics/:metric_name/estimate?filter[groups]=<string>&filter[hours_ago]=<integer>&filter[num_aggregations]=<integer>&filter[pct]=<boolean>&filter[timespan_h]=<integer>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"metrics",
":metric_name",
"estimate"
],
"query": [
{
"key": "filter[groups]",
"value": "<string>",
"description": "Filtered tag keys that the metric is configured to query with."
},
{
"key": "filter[hours_ago]",
"value": "<integer>",
"description": "The number of hours of look back (from now) to estimate cardinality with."
},
{
"key": "filter[num_aggregations]",
"value": "<integer>",
"description": "The number of aggregations that a `count`, `rate`, or `gauge` metric is configured to use. Max number of aggregation combos is 9."
},
{
"key": "filter[pct]",
"value": "<boolean>",
"description": "A boolean, for distribution metrics only, to estimate cardinality if the metric includes additional percentile aggregators."
},
{
"key": "filter[timespan_h]",
"value": "<integer>",
"description": "A window, in hours, from the look back to estimate cardinality with."
}
],
"variable": [
{
"key": "metric_name"
}
]
}
},
"status": "Not Found",
"code": 404,
"_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": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/metrics/:metric_name/estimate?filter[groups]=<string>&filter[hours_ago]=<integer>&filter[num_aggregations]=<integer>&filter[pct]=<boolean>&filter[timespan_h]=<integer>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"metrics",
":metric_name",
"estimate"
],
"query": [
{
"key": "filter[groups]",
"value": "<string>",
"description": "Filtered tag keys that the metric is configured to query with."
},
{
"key": "filter[hours_ago]",
"value": "<integer>",
"description": "The number of hours of look back (from now) to estimate cardinality with."
},
{
"key": "filter[num_aggregations]",
"value": "<integer>",
"description": "The number of aggregations that a `count`, `rate`, or `gauge` metric is configured to use. Max number of aggregation combos is 9."
},
{
"key": "filter[pct]",
"value": "<boolean>",
"description": "A boolean, for distribution metrics only, to estimate cardinality if the metric includes additional percentile aggregators."
},
{
"key": "filter[timespan_h]",
"value": "<integer>",
"description": "A window, in hours, from the look back to estimate cardinality with."
}
],
"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}"
}
]
}