Back to Collection Items
' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
Dim http As New Chilkat.Http
Dim success As Boolean
' 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": "delta",
' "interval": "<string>",
' "metric": "<string>",
' "type": "total"
' },
' {
' "aggregation": "pc90",
' "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": "pc98",
' "metric": "<string>",
' "order": "desc",
' "type": "alphabetical"
' },
' "total": "<boolean>"
' },
' {
' "facet": "<string>",
' "histogram": {
' "interval": "<double>",
' "min": "<double>",
' "max": "<double>"
' },
' "limit": 10,
' "missing": "<string>",
' "sort": {
' "aggregation": "pc90",
' "metric": "<string>",
' "order": "asc",
' "type": "alphabetical"
' },
' "total": "<boolean>"
' }
' ],
' "options": {
' "time_offset": "<long>",
' "timezone": "UTC"
' }
' }
Dim json As New Chilkat.JsonObject
json.UpdateString("compute[0].aggregation","delta")
json.UpdateString("compute[0].interval","<string>")
json.UpdateString("compute[0].metric","<string>")
json.UpdateString("compute[0].type","total")
json.UpdateString("compute[1].aggregation","pc90")
json.UpdateString("compute[1].interval","<string>")
json.UpdateString("compute[1].metric","<string>")
json.UpdateString("compute[1].type","total")
json.UpdateString("filter.from","now-15m")
json.UpdateString("filter.query","*")
json.UpdateString("filter.to","now")
json.UpdateString("group_by[0].facet","<string>")
json.UpdateString("group_by[0].histogram.interval","<double>")
json.UpdateString("group_by[0].histogram.min","<double>")
json.UpdateString("group_by[0].histogram.max","<double>")
json.UpdateInt("group_by[0].limit",10)
json.UpdateString("group_by[0].missing","<string>")
json.UpdateString("group_by[0].sort.aggregation","pc98")
json.UpdateString("group_by[0].sort.metric","<string>")
json.UpdateString("group_by[0].sort.order","desc")
json.UpdateString("group_by[0].sort.type","alphabetical")
json.UpdateString("group_by[0].total","<boolean>")
json.UpdateString("group_by[1].facet","<string>")
json.UpdateString("group_by[1].histogram.interval","<double>")
json.UpdateString("group_by[1].histogram.min","<double>")
json.UpdateString("group_by[1].histogram.max","<double>")
json.UpdateInt("group_by[1].limit",10)
json.UpdateString("group_by[1].missing","<string>")
json.UpdateString("group_by[1].sort.aggregation","pc90")
json.UpdateString("group_by[1].sort.metric","<string>")
json.UpdateString("group_by[1].sort.order","asc")
json.UpdateString("group_by[1].sort.type","alphabetical")
json.UpdateString("group_by[1].total","<boolean>")
json.UpdateString("options.time_offset","<long>")
json.UpdateString("options.timezone","UTC")
http.SetRequestHeader("Content-Type","application/json")
http.SetRequestHeader("Accept","application/json")
Dim resp As Chilkat.HttpResponse = http.PostJson3("https://api.app.ddog-gov.com/api/v2/ci/tests/analytics/aggregate","application/json",json)
If (http.LastMethodSuccess = False) Then
Debug.WriteLine(http.LastErrorText)
Exit Sub
End If
Dim sbResponseBody As New Chilkat.StringBuilder
resp.GetBodySb(sbResponseBody)
Dim jResp As New Chilkat.JsonObject
jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = False
Debug.WriteLine("Response Body:")
Debug.WriteLine(jResp.Emit())
Dim respStatusCode As Integer = resp.StatusCode
Debug.WriteLine("Response Status Code = " & respStatusCode)
If (respStatusCode >= 400) Then
Debug.WriteLine("Response Header:")
Debug.WriteLine(resp.Header)
Debug.WriteLine("Failed.")
Exit Sub
End If
' Sample JSON response:
' (Sample code for parsing the JSON response is shown below)
' {
' "data": {
' "buckets": [
' {
' "by": {
' "adipisicing_68": {
' "description": "The values for each group-by."
' },
' "cupidatat7c": {
' "description": "The values for each group-by."
' }
' },
' "computes": {
' "Lorem_8": "<string>"
' }
' },
' {
' "by": {
' "inb": {
' "description": "The values for each group-by."
' },
' "inf": {
' "description": "The values for each group-by."
' }
' },
' "computes": {
' "dolore98_": "<string>"
' }
' }
' ]
' },
' "links": {
' "next": "<string>"
' },
' "meta": {
' "elapsed": "<long>",
' "page": {
' "after": "<string>"
' },
' "request_id": "<string>",
' "status": "timeout",
' "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
Dim Description As String
Dim Cupidatat7cDescription As String
Dim Lorem_8 As String
Dim InbDescription As String
Dim InfDescription As String
Dim Dolore98_ As String
Dim code As String
Dim detail As String
Dim title As String
Dim v_Next As String = jResp.StringOf("links.next")
Dim Elapsed As String = jResp.StringOf("meta.elapsed")
Dim After As String = jResp.StringOf("meta.page.after")
Dim Request_id As String = jResp.StringOf("meta.request_id")
Dim Status As String = jResp.StringOf("meta.status")
Dim i As Integer = 0
Dim count_i As Integer = jResp.SizeOfArray("data.buckets")
While i < count_i
jResp.I = i
Description = jResp.StringOf("data.buckets[i].by.adipisicing_68.description")
Cupidatat7cDescription = jResp.StringOf("data.buckets[i].by.cupidatat7c.description")
Lorem_8 = jResp.StringOf("data.buckets[i].computes.Lorem_8")
InbDescription = jResp.StringOf("data.buckets[i].by.inb.description")
InfDescription = jResp.StringOf("data.buckets[i].by.inf.description")
Dolore98_ = jResp.StringOf("data.buckets[i].computes.dolore98_")
i = i + 1
End While
i = 0
count_i = jResp.SizeOfArray("meta.warnings")
While i < count_i
jResp.I = i
code = jResp.StringOf("meta.warnings[i].code")
detail = jResp.StringOf("meta.warnings[i].detail")
title = jResp.StringOf("meta.warnings[i].title")
i = i + 1
End While
Curl Command
curl -X POST
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"compute": [
{
"aggregation": "delta",
"interval": "<string>",
"metric": "<string>",
"type": "total"
},
{
"aggregation": "pc90",
"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": "pc98",
"metric": "<string>",
"order": "desc",
"type": "alphabetical"
},
"total": "<boolean>"
},
{
"facet": "<string>",
"histogram": {
"interval": "<double>",
"min": "<double>",
"max": "<double>"
},
"limit": 10,
"missing": "<string>",
"sort": {
"aggregation": "pc90",
"metric": "<string>",
"order": "asc",
"type": "alphabetical"
},
"total": "<boolean>"
}
],
"options": {
"time_offset": "<long>",
"timezone": "UTC"
}
}'
https://api.app.ddog-gov.com/api/v2/ci/tests/analytics/aggregate
Postman Collection Item JSON
{
"name": "Aggregate tests 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\": \"delta\",\n \"interval\": \"<string>\",\n \"metric\": \"<string>\",\n \"type\": \"total\"\n },\n {\n \"aggregation\": \"pc90\",\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\": \"pc98\",\n \"metric\": \"<string>\",\n \"order\": \"desc\",\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\": \"pc90\",\n \"metric\": \"<string>\",\n \"order\": \"asc\",\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/tests/analytics/aggregate",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ci",
"tests",
"analytics",
"aggregate"
]
},
"description": "The API endpoint to aggregate CI Visibility test 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\": \"delta\",\n \"interval\": \"<string>\",\n \"metric\": \"<string>\",\n \"type\": \"total\"\n },\n {\n \"aggregation\": \"pc90\",\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\": \"pc98\",\n \"metric\": \"<string>\",\n \"order\": \"desc\",\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\": \"pc90\",\n \"metric\": \"<string>\",\n \"order\": \"asc\",\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/tests/analytics/aggregate",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ci",
"tests",
"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 \"adipisicing_68\": {\n \"description\": \"The values for each group-by.\"\n },\n \"cupidatat7c\": {\n \"description\": \"The values for each group-by.\"\n }\n },\n \"computes\": {\n \"Lorem_8\": \"<string>\"\n }\n },\n {\n \"by\": {\n \"inb\": {\n \"description\": \"The values for each group-by.\"\n },\n \"inf\": {\n \"description\": \"The values for each group-by.\"\n }\n },\n \"computes\": {\n \"dolore98_\": \"<string>\"\n }\n }\n ]\n },\n \"links\": {\n \"next\": \"<string>\"\n },\n \"meta\": {\n \"elapsed\": \"<long>\",\n \"page\": {\n \"after\": \"<string>\"\n },\n \"request_id\": \"<string>\",\n \"status\": \"timeout\",\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\": \"delta\",\n \"interval\": \"<string>\",\n \"metric\": \"<string>\",\n \"type\": \"total\"\n },\n {\n \"aggregation\": \"pc90\",\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\": \"pc98\",\n \"metric\": \"<string>\",\n \"order\": \"desc\",\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\": \"pc90\",\n \"metric\": \"<string>\",\n \"order\": \"asc\",\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/tests/analytics/aggregate",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ci",
"tests",
"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\": \"delta\",\n \"interval\": \"<string>\",\n \"metric\": \"<string>\",\n \"type\": \"total\"\n },\n {\n \"aggregation\": \"pc90\",\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\": \"pc98\",\n \"metric\": \"<string>\",\n \"order\": \"desc\",\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\": \"pc90\",\n \"metric\": \"<string>\",\n \"order\": \"asc\",\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/tests/analytics/aggregate",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ci",
"tests",
"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\": \"delta\",\n \"interval\": \"<string>\",\n \"metric\": \"<string>\",\n \"type\": \"total\"\n },\n {\n \"aggregation\": \"pc90\",\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\": \"pc98\",\n \"metric\": \"<string>\",\n \"order\": \"desc\",\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\": \"pc90\",\n \"metric\": \"<string>\",\n \"order\": \"asc\",\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/tests/analytics/aggregate",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ci",
"tests",
"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}"
}
]
}