Back to Collection Items
integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Json
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Description
string ls_Qui72Description
string ls_Dolore4
string ls_Proident9aDescription
string ls_Lorem62
string ls_Ut5
string ls_Code
string ls_Detail
string ls_Title
string ls_V_Next
string ls_Elapsed
string ls_Request_id
string ls_Status
integer i
integer li_Count_i
// 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
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "compute": [
// {
// "aggregation": "pc95",
// "interval": "<string>",
// "metric": "<string>",
// "type": "total"
// },
// {
// "aggregation": "avg",
// "interval": "<string>",
// "metric": "<string>",
// "type": "total"
// }
// ],
// "filter": {
// "from": "now-15m",
// "query": "*",
// "to": "now"
// },
// "group_by": [
// {
// "facet": "<string>",
// "histogram": {
// "interval": "<double>",
// "min": "<double>",
// "max": "<double>"
// },
// "limit": 10,
// "missing": "<string>",
// "sort": {
// "aggregation": "delta",
// "metric": "<string>",
// "order": "asc",
// "type": "alphabetical"
// },
// "total": "<boolean>"
// },
// {
// "facet": "<string>",
// "histogram": {
// "interval": "<double>",
// "min": "<double>",
// "max": "<double>"
// },
// "limit": 10,
// "missing": "<string>",
// "sort": {
// "aggregation": "pc99",
// "metric": "<string>",
// "order": "desc",
// "type": "alphabetical"
// },
// "total": "<boolean>"
// }
// ],
// "options": {
// "time_offset": "<long>",
// "timezone": "UTC"
// }
// }
loo_Json = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
loo_Json.UpdateString("compute[0].aggregation","pc95")
loo_Json.UpdateString("compute[0].interval","<string>")
loo_Json.UpdateString("compute[0].metric","<string>")
loo_Json.UpdateString("compute[0].type","total")
loo_Json.UpdateString("compute[1].aggregation","avg")
loo_Json.UpdateString("compute[1].interval","<string>")
loo_Json.UpdateString("compute[1].metric","<string>")
loo_Json.UpdateString("compute[1].type","total")
loo_Json.UpdateString("filter.from","now-15m")
loo_Json.UpdateString("filter.query","*")
loo_Json.UpdateString("filter.to","now")
loo_Json.UpdateString("group_by[0].facet","<string>")
loo_Json.UpdateString("group_by[0].histogram.interval","<double>")
loo_Json.UpdateString("group_by[0].histogram.min","<double>")
loo_Json.UpdateString("group_by[0].histogram.max","<double>")
loo_Json.UpdateInt("group_by[0].limit",10)
loo_Json.UpdateString("group_by[0].missing","<string>")
loo_Json.UpdateString("group_by[0].sort.aggregation","delta")
loo_Json.UpdateString("group_by[0].sort.metric","<string>")
loo_Json.UpdateString("group_by[0].sort.order","asc")
loo_Json.UpdateString("group_by[0].sort.type","alphabetical")
loo_Json.UpdateString("group_by[0].total","<boolean>")
loo_Json.UpdateString("group_by[1].facet","<string>")
loo_Json.UpdateString("group_by[1].histogram.interval","<double>")
loo_Json.UpdateString("group_by[1].histogram.min","<double>")
loo_Json.UpdateString("group_by[1].histogram.max","<double>")
loo_Json.UpdateInt("group_by[1].limit",10)
loo_Json.UpdateString("group_by[1].missing","<string>")
loo_Json.UpdateString("group_by[1].sort.aggregation","pc99")
loo_Json.UpdateString("group_by[1].sort.metric","<string>")
loo_Json.UpdateString("group_by[1].sort.order","desc")
loo_Json.UpdateString("group_by[1].sort.type","alphabetical")
loo_Json.UpdateString("group_by[1].total","<boolean>")
loo_Json.UpdateString("options.time_offset","<long>")
loo_Json.UpdateString("options.timezone","UTC")
loo_Http.SetRequestHeader("Content-Type","application/json")
loo_Http.SetRequestHeader("Accept","application/json")
loo_Resp = loo_Http.PostJson3("https://api.app.ddog-gov.com/api/v2/ci/pipelines/analytics/aggregate","application/json",loo_Json)
if loo_Http.LastMethodSuccess = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_Json
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_Json
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": {
// "buckets": [
// {
// "by": {
// "reprehenderit461": {
// "description": "The values for each group-by."
// },
// "qui72": {
// "description": "The values for each group-by."
// }
// },
// "computes": {
// "dolore4": "<string>"
// }
// },
// {
// "by": {
// "proident9a": {
// "description": "The values for each group-by."
// }
// },
// "computes": {
// "Lorem62": "<string>",
// "ut5": "<string>"
// }
// }
// ]
// },
// "links": {
// "next": "<string>"
// },
// "meta": {
// "elapsed": "<long>",
// "request_id": "<string>",
// "status": "done",
// "warnings": [
// {
// "code": "<string>",
// "detail": "<string>",
// "title": "<string>"
// },
// {
// "code": "<string>",
// "detail": "<string>",
// "title": "<string>"
// }
// ]
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
ls_V_Next = loo_JResp.StringOf("links.next")
ls_Elapsed = loo_JResp.StringOf("meta.elapsed")
ls_Request_id = loo_JResp.StringOf("meta.request_id")
ls_Status = loo_JResp.StringOf("meta.status")
i = 0
li_Count_i = loo_JResp.SizeOfArray("data.buckets")
do while i < li_Count_i
loo_JResp.I = i
ls_Description = loo_JResp.StringOf("data.buckets[i].by.reprehenderit461.description")
ls_Qui72Description = loo_JResp.StringOf("data.buckets[i].by.qui72.description")
ls_Dolore4 = loo_JResp.StringOf("data.buckets[i].computes.dolore4")
ls_Proident9aDescription = loo_JResp.StringOf("data.buckets[i].by.proident9a.description")
ls_Lorem62 = loo_JResp.StringOf("data.buckets[i].computes.Lorem62")
ls_Ut5 = loo_JResp.StringOf("data.buckets[i].computes.ut5")
i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("meta.warnings")
do while i < li_Count_i
loo_JResp.I = i
ls_Code = loo_JResp.StringOf("meta.warnings[i].code")
ls_Detail = loo_JResp.StringOf("meta.warnings[i].detail")
ls_Title = loo_JResp.StringOf("meta.warnings[i].title")
i = i + 1
loop
destroy loo_Http
destroy loo_Json
destroy loo_SbResponseBody
destroy loo_JResp
Curl Command
curl -X POST
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"compute": [
{
"aggregation": "pc95",
"interval": "<string>",
"metric": "<string>",
"type": "total"
},
{
"aggregation": "avg",
"interval": "<string>",
"metric": "<string>",
"type": "total"
}
],
"filter": {
"from": "now-15m",
"query": "*",
"to": "now"
},
"group_by": [
{
"facet": "<string>",
"histogram": {
"interval": "<double>",
"min": "<double>",
"max": "<double>"
},
"limit": 10,
"missing": "<string>",
"sort": {
"aggregation": "delta",
"metric": "<string>",
"order": "asc",
"type": "alphabetical"
},
"total": "<boolean>"
},
{
"facet": "<string>",
"histogram": {
"interval": "<double>",
"min": "<double>",
"max": "<double>"
},
"limit": 10,
"missing": "<string>",
"sort": {
"aggregation": "pc99",
"metric": "<string>",
"order": "desc",
"type": "alphabetical"
},
"total": "<boolean>"
}
],
"options": {
"time_offset": "<long>",
"timezone": "UTC"
}
}'
https://api.app.ddog-gov.com/api/v2/ci/pipelines/analytics/aggregate
Postman Collection Item JSON
{
"name": "Aggregate pipelines events",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"compute\": [\n {\n \"aggregation\": \"pc95\",\n \"interval\": \"<string>\",\n \"metric\": \"<string>\",\n \"type\": \"total\"\n },\n {\n \"aggregation\": \"avg\",\n \"interval\": \"<string>\",\n \"metric\": \"<string>\",\n \"type\": \"total\"\n }\n ],\n \"filter\": {\n \"from\": \"now-15m\",\n \"query\": \"*\",\n \"to\": \"now\"\n },\n \"group_by\": [\n {\n \"facet\": \"<string>\",\n \"histogram\": {\n \"interval\": \"<double>\",\n \"min\": \"<double>\",\n \"max\": \"<double>\"\n },\n \"limit\": 10,\n \"missing\": \"<string>\",\n \"sort\": {\n \"aggregation\": \"delta\",\n \"metric\": \"<string>\",\n \"order\": \"asc\",\n \"type\": \"alphabetical\"\n },\n \"total\": \"<boolean>\"\n },\n {\n \"facet\": \"<string>\",\n \"histogram\": {\n \"interval\": \"<double>\",\n \"min\": \"<double>\",\n \"max\": \"<double>\"\n },\n \"limit\": 10,\n \"missing\": \"<string>\",\n \"sort\": {\n \"aggregation\": \"pc99\",\n \"metric\": \"<string>\",\n \"order\": \"desc\",\n \"type\": \"alphabetical\"\n },\n \"total\": \"<boolean>\"\n }\n ],\n \"options\": {\n \"time_offset\": \"<long>\",\n \"timezone\": \"UTC\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/ci/pipelines/analytics/aggregate",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ci",
"pipelines",
"analytics",
"aggregate"
]
},
"description": "Use this API endpoint to aggregate CI Visibility pipeline events into buckets of computed metrics and timeseries."
},
"response": [
{
"name": "OK",
"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 \"compute\": [\n {\n \"aggregation\": \"pc95\",\n \"interval\": \"<string>\",\n \"metric\": \"<string>\",\n \"type\": \"total\"\n },\n {\n \"aggregation\": \"avg\",\n \"interval\": \"<string>\",\n \"metric\": \"<string>\",\n \"type\": \"total\"\n }\n ],\n \"filter\": {\n \"from\": \"now-15m\",\n \"query\": \"*\",\n \"to\": \"now\"\n },\n \"group_by\": [\n {\n \"facet\": \"<string>\",\n \"histogram\": {\n \"interval\": \"<double>\",\n \"min\": \"<double>\",\n \"max\": \"<double>\"\n },\n \"limit\": 10,\n \"missing\": \"<string>\",\n \"sort\": {\n \"aggregation\": \"delta\",\n \"metric\": \"<string>\",\n \"order\": \"asc\",\n \"type\": \"alphabetical\"\n },\n \"total\": \"<boolean>\"\n },\n {\n \"facet\": \"<string>\",\n \"histogram\": {\n \"interval\": \"<double>\",\n \"min\": \"<double>\",\n \"max\": \"<double>\"\n },\n \"limit\": 10,\n \"missing\": \"<string>\",\n \"sort\": {\n \"aggregation\": \"pc99\",\n \"metric\": \"<string>\",\n \"order\": \"desc\",\n \"type\": \"alphabetical\"\n },\n \"total\": \"<boolean>\"\n }\n ],\n \"options\": {\n \"time_offset\": \"<long>\",\n \"timezone\": \"UTC\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/ci/pipelines/analytics/aggregate",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ci",
"pipelines",
"analytics",
"aggregate"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"data\": {\n \"buckets\": [\n {\n \"by\": {\n \"reprehenderit461\": {\n \"description\": \"The values for each group-by.\"\n },\n \"qui72\": {\n \"description\": \"The values for each group-by.\"\n }\n },\n \"computes\": {\n \"dolore4\": \"<string>\"\n }\n },\n {\n \"by\": {\n \"proident9a\": {\n \"description\": \"The values for each group-by.\"\n }\n },\n \"computes\": {\n \"Lorem62\": \"<string>\",\n \"ut5\": \"<string>\"\n }\n }\n ]\n },\n \"links\": {\n \"next\": \"<string>\"\n },\n \"meta\": {\n \"elapsed\": \"<long>\",\n \"request_id\": \"<string>\",\n \"status\": \"done\",\n \"warnings\": [\n {\n \"code\": \"<string>\",\n \"detail\": \"<string>\",\n \"title\": \"<string>\"\n },\n {\n \"code\": \"<string>\",\n \"detail\": \"<string>\",\n \"title\": \"<string>\"\n }\n ]\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 \"compute\": [\n {\n \"aggregation\": \"pc95\",\n \"interval\": \"<string>\",\n \"metric\": \"<string>\",\n \"type\": \"total\"\n },\n {\n \"aggregation\": \"avg\",\n \"interval\": \"<string>\",\n \"metric\": \"<string>\",\n \"type\": \"total\"\n }\n ],\n \"filter\": {\n \"from\": \"now-15m\",\n \"query\": \"*\",\n \"to\": \"now\"\n },\n \"group_by\": [\n {\n \"facet\": \"<string>\",\n \"histogram\": {\n \"interval\": \"<double>\",\n \"min\": \"<double>\",\n \"max\": \"<double>\"\n },\n \"limit\": 10,\n \"missing\": \"<string>\",\n \"sort\": {\n \"aggregation\": \"delta\",\n \"metric\": \"<string>\",\n \"order\": \"asc\",\n \"type\": \"alphabetical\"\n },\n \"total\": \"<boolean>\"\n },\n {\n \"facet\": \"<string>\",\n \"histogram\": {\n \"interval\": \"<double>\",\n \"min\": \"<double>\",\n \"max\": \"<double>\"\n },\n \"limit\": 10,\n \"missing\": \"<string>\",\n \"sort\": {\n \"aggregation\": \"pc99\",\n \"metric\": \"<string>\",\n \"order\": \"desc\",\n \"type\": \"alphabetical\"\n },\n \"total\": \"<boolean>\"\n }\n ],\n \"options\": {\n \"time_offset\": \"<long>\",\n \"timezone\": \"UTC\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/ci/pipelines/analytics/aggregate",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ci",
"pipelines",
"analytics",
"aggregate"
]
}
},
"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": "Not Authorized",
"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 \"compute\": [\n {\n \"aggregation\": \"pc95\",\n \"interval\": \"<string>\",\n \"metric\": \"<string>\",\n \"type\": \"total\"\n },\n {\n \"aggregation\": \"avg\",\n \"interval\": \"<string>\",\n \"metric\": \"<string>\",\n \"type\": \"total\"\n }\n ],\n \"filter\": {\n \"from\": \"now-15m\",\n \"query\": \"*\",\n \"to\": \"now\"\n },\n \"group_by\": [\n {\n \"facet\": \"<string>\",\n \"histogram\": {\n \"interval\": \"<double>\",\n \"min\": \"<double>\",\n \"max\": \"<double>\"\n },\n \"limit\": 10,\n \"missing\": \"<string>\",\n \"sort\": {\n \"aggregation\": \"delta\",\n \"metric\": \"<string>\",\n \"order\": \"asc\",\n \"type\": \"alphabetical\"\n },\n \"total\": \"<boolean>\"\n },\n {\n \"facet\": \"<string>\",\n \"histogram\": {\n \"interval\": \"<double>\",\n \"min\": \"<double>\",\n \"max\": \"<double>\"\n },\n \"limit\": 10,\n \"missing\": \"<string>\",\n \"sort\": {\n \"aggregation\": \"pc99\",\n \"metric\": \"<string>\",\n \"order\": \"desc\",\n \"type\": \"alphabetical\"\n },\n \"total\": \"<boolean>\"\n }\n ],\n \"options\": {\n \"time_offset\": \"<long>\",\n \"timezone\": \"UTC\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/ci/pipelines/analytics/aggregate",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ci",
"pipelines",
"analytics",
"aggregate"
]
}
},
"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": "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 \"compute\": [\n {\n \"aggregation\": \"pc95\",\n \"interval\": \"<string>\",\n \"metric\": \"<string>\",\n \"type\": \"total\"\n },\n {\n \"aggregation\": \"avg\",\n \"interval\": \"<string>\",\n \"metric\": \"<string>\",\n \"type\": \"total\"\n }\n ],\n \"filter\": {\n \"from\": \"now-15m\",\n \"query\": \"*\",\n \"to\": \"now\"\n },\n \"group_by\": [\n {\n \"facet\": \"<string>\",\n \"histogram\": {\n \"interval\": \"<double>\",\n \"min\": \"<double>\",\n \"max\": \"<double>\"\n },\n \"limit\": 10,\n \"missing\": \"<string>\",\n \"sort\": {\n \"aggregation\": \"delta\",\n \"metric\": \"<string>\",\n \"order\": \"asc\",\n \"type\": \"alphabetical\"\n },\n \"total\": \"<boolean>\"\n },\n {\n \"facet\": \"<string>\",\n \"histogram\": {\n \"interval\": \"<double>\",\n \"min\": \"<double>\",\n \"max\": \"<double>\"\n },\n \"limit\": 10,\n \"missing\": \"<string>\",\n \"sort\": {\n \"aggregation\": \"pc99\",\n \"metric\": \"<string>\",\n \"order\": \"desc\",\n \"type\": \"alphabetical\"\n },\n \"total\": \"<boolean>\"\n }\n ],\n \"options\": {\n \"time_offset\": \"<long>\",\n \"timezone\": \"UTC\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/ci/pipelines/analytics/aggregate",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ci",
"pipelines",
"analytics",
"aggregate"
]
}
},
"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}"
}
]
}