Back to Collection Items
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
Local $bSuccess
; Use this online tool to generate code from sample JSON: Generate Code to Create JSON
; The following JSON is sent in the request body.
; {
; "name": "",
; "filter": {
; "query": "source:python"
; },
; "id": "consequat elit non",
; "is_enabled": true,
; "is_read_only": true,
; "processors": [
; {
; "source": "message",
; "grok": {
; "match_rules": "rule_name_1 foo\nrule_name_2 bar\n",
; "support_rules": "rule_name_1 foo\nrule_name_2 bar\n"
; },
; "type": "grok-parser",
; "is_enabled": false,
; "name": "nostrud Excepteur",
; "samples": [
; "sit ea ullamco",
; "sunt est laboris"
; ]
; },
; {
; "source": "message",
; "grok": {
; "match_rules": "rule_name_1 foo\nrule_name_2 bar\n",
; "support_rules": "rule_name_1 foo\nrule_name_2 bar\n"
; },
; "type": "grok-parser",
; "is_enabled": false,
; "name": "exercitation do Ut",
; "samples": [
; "ut",
; "nulla tempor amet"
; ]
; }
; ],
; "type": "pipeline"
; }
$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.UpdateString("name","")
$oJson.UpdateString("filter.query","source:python")
$oJson.UpdateString("id","consequat elit non")
$oJson.UpdateBool("is_enabled",True)
$oJson.UpdateBool("is_read_only",True)
$oJson.UpdateString("processors[0].source","message")
$oJson.UpdateString("processors[0].grok.match_rules","rule_name_1 foo" & @LF & "rule_name_2 bar" & @LF)
$oJson.UpdateString("processors[0].grok.support_rules","rule_name_1 foo" & @LF & "rule_name_2 bar" & @LF)
$oJson.UpdateString("processors[0].type","grok-parser")
$oJson.UpdateBool("processors[0].is_enabled",False)
$oJson.UpdateString("processors[0].name","nostrud Excepteur")
$oJson.UpdateString("processors[0].samples[0]","sit ea ullamco")
$oJson.UpdateString("processors[0].samples[1]","sunt est laboris")
$oJson.UpdateString("processors[1].source","message")
$oJson.UpdateString("processors[1].grok.match_rules","rule_name_1 foo" & @LF & "rule_name_2 bar" & @LF)
$oJson.UpdateString("processors[1].grok.support_rules","rule_name_1 foo" & @LF & "rule_name_2 bar" & @LF)
$oJson.UpdateString("processors[1].type","grok-parser")
$oJson.UpdateBool("processors[1].is_enabled",False)
$oJson.UpdateString("processors[1].name","exercitation do Ut")
$oJson.UpdateString("processors[1].samples[0]","ut")
$oJson.UpdateString("processors[1].samples[1]","nulla tempor amet")
$oJson.UpdateString("type","pipeline")
$oHttp.SetRequestHeader "Content-Type","application/json"
$oHttp.SetRequestHeader "Accept","application/json"
$oSbRequestBody = ObjCreate("Chilkat.StringBuilder")
$oJson.EmitSb($oSbRequestBody)
Local $oResp = $oHttp.PTextSb("PUT","https://api.app.ddog-gov.com/api/v1/logs/config/pipelines/:pipeline_id",$oSbRequestBody,"utf-8","application/json",False,False)
If ($oHttp.LastMethodSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
$oSbResponseBody = ObjCreate("Chilkat.StringBuilder")
$oResp.GetBodySb($oSbResponseBody)
$oJResp = ObjCreate("Chilkat.JsonObject")
$oJResp.LoadSb($oSbResponseBody)
$oJResp.EmitCompact = False
ConsoleWrite("Response Body:" & @CRLF)
ConsoleWrite($oJResp.Emit() & @CRLF)
Local $iRespStatusCode = $oResp.StatusCode
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode >= 400) Then
ConsoleWrite("Response Header:" & @CRLF)
ConsoleWrite($oResp.Header & @CRLF)
ConsoleWrite("Failed." & @CRLF)
Exit
EndIf
; Sample JSON response:
; (Sample code for parsing the JSON response is shown below)
; {
; "name": "",
; "filter": {
; "query": "source:python"
; },
; "id": "consequat elit non",
; "is_enabled": true,
; "is_read_only": true,
; "processors": [
; {
; "source": "message",
; "grok": {
; "match_rules": "rule_name_1 foo\nrule_name_2 bar\n",
; "support_rules": "rule_name_1 foo\nrule_name_2 bar\n"
; },
; "type": "grok-parser",
; "is_enabled": false,
; "name": "nostrud Excepteur",
; "samples": [
; "sit ea ullamco",
; "sunt est laboris"
; ]
; },
; {
; "source": "message",
; "grok": {
; "match_rules": "rule_name_1 foo\nrule_name_2 bar\n",
; "support_rules": "rule_name_1 foo\nrule_name_2 bar\n"
; },
; "type": "grok-parser",
; "is_enabled": false,
; "name": "exercitation do Ut",
; "samples": [
; "ut",
; "nulla tempor amet"
; ]
; }
; ],
; "type": "pipeline"
; }
; Sample code for parsing the JSON response...
; Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
Local $source
Local $sMatch_rules
Local $sSupport_rules
Local $iJ
Local $iCount_j
Local $strVal
Local $sName = $oJResp.StringOf("name")
Local $sQuery = $oJResp.StringOf("filter.query")
Local $sId = $oJResp.StringOf("id")
Local $bIs_enabled = $oJResp.BoolOf("is_enabled")
Local $bIs_read_only = $oJResp.BoolOf("is_read_only")
Local $sV_type = $oJResp.StringOf("type")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("processors")
While $i < $iCount_i
$oJResp.I = $i
$source = $oJResp.StringOf("processors[i].source")
$sMatch_rules = $oJResp.StringOf("processors[i].grok.match_rules")
$sSupport_rules = $oJResp.StringOf("processors[i].grok.support_rules")
$sV_type = $oJResp.StringOf("processors[i].type")
$bIs_enabled = $oJResp.BoolOf("processors[i].is_enabled")
$sName = $oJResp.StringOf("processors[i].name")
$iJ = 0
$iCount_j = $oJResp.SizeOfArray("processors[i].samples")
While $iJ < $iCount_j
$oJResp.J = $iJ
$strVal = $oJResp.StringOf("processors[i].samples[j]")
$iJ = $iJ + 1
Wend
$i = $i + 1
Wend
Curl Command
curl -X PUT
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"name": "",
"filter": {
"query": "source:python"
},
"id": "consequat elit non",
"is_enabled": true,
"is_read_only": true,
"processors": [
{
"source": "message",
"grok": {
"match_rules": "rule_name_1 foo\nrule_name_2 bar\n",
"support_rules": "rule_name_1 foo\nrule_name_2 bar\n"
},
"type": "grok-parser",
"is_enabled": false,
"name": "nostrud Excepteur",
"samples": [
"sit ea ullamco",
"sunt est laboris"
]
},
{
"source": "message",
"grok": {
"match_rules": "rule_name_1 foo\nrule_name_2 bar\n",
"support_rules": "rule_name_1 foo\nrule_name_2 bar\n"
},
"type": "grok-parser",
"is_enabled": false,
"name": "exercitation do Ut",
"samples": [
"ut",
"nulla tempor amet"
]
}
],
"type": "pipeline"
}'
https://api.app.ddog-gov.com/api/v1/logs/config/pipelines/:pipeline_id
Postman Collection Item JSON
{
"name": "Update a pipeline",
"request": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"name\": \"\",\n \"filter\": {\n \"query\": \"source:python\"\n },\n \"id\": \"consequat elit non\",\n \"is_enabled\": true,\n \"is_read_only\": true,\n \"processors\": [\n {\n \"source\": \"message\",\n \"grok\": {\n \"match_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\",\n \"support_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\"\n },\n \"type\": \"grok-parser\",\n \"is_enabled\": false,\n \"name\": \"nostrud Excepteur\",\n \"samples\": [\n \"sit ea ullamco\",\n \"sunt est laboris\"\n ]\n },\n {\n \"source\": \"message\",\n \"grok\": {\n \"match_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\",\n \"support_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\"\n },\n \"type\": \"grok-parser\",\n \"is_enabled\": false,\n \"name\": \"exercitation do Ut\",\n \"samples\": [\n \"ut\",\n \"nulla tempor amet\"\n ]\n }\n ],\n \"type\": \"pipeline\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/logs/config/pipelines/:pipeline_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"logs",
"config",
"pipelines",
":pipeline_id"
],
"variable": [
{
"key": "pipeline_id",
"value": "tempor Ut sed velit"
}
]
},
"description": "Update a given pipeline configuration to change it’s processors or their order.\n\n**Note**: Using this method updates your pipeline configuration by **replacing**\nyour current configuration with the new one sent to your Datadog organization."
},
"response": [
{
"name": "OK",
"originalRequest": {
"method": "PUT",
"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 \"name\": \"\",\n \"filter\": {\n \"query\": \"source:python\"\n },\n \"id\": \"consequat elit non\",\n \"is_enabled\": true,\n \"is_read_only\": true,\n \"processors\": [\n {\n \"source\": \"message\",\n \"grok\": {\n \"match_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\",\n \"support_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\"\n },\n \"type\": \"grok-parser\",\n \"is_enabled\": false,\n \"name\": \"nostrud Excepteur\",\n \"samples\": [\n \"sit ea ullamco\",\n \"sunt est laboris\"\n ]\n },\n {\n \"source\": \"message\",\n \"grok\": {\n \"match_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\",\n \"support_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\"\n },\n \"type\": \"grok-parser\",\n \"is_enabled\": false,\n \"name\": \"exercitation do Ut\",\n \"samples\": [\n \"ut\",\n \"nulla tempor amet\"\n ]\n }\n ],\n \"type\": \"pipeline\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/logs/config/pipelines/:pipeline_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"logs",
"config",
"pipelines",
":pipeline_id"
],
"variable": [
{
"key": "pipeline_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"name\": \"\",\n \"filter\": {\n \"query\": \"source:python\"\n },\n \"id\": \"consequat elit non\",\n \"is_enabled\": true,\n \"is_read_only\": true,\n \"processors\": [\n {\n \"source\": \"message\",\n \"grok\": {\n \"match_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\",\n \"support_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\"\n },\n \"type\": \"grok-parser\",\n \"is_enabled\": false,\n \"name\": \"nostrud Excepteur\",\n \"samples\": [\n \"sit ea ullamco\",\n \"sunt est laboris\"\n ]\n },\n {\n \"source\": \"message\",\n \"grok\": {\n \"match_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\",\n \"support_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\"\n },\n \"type\": \"grok-parser\",\n \"is_enabled\": false,\n \"name\": \"exercitation do Ut\",\n \"samples\": [\n \"ut\",\n \"nulla tempor amet\"\n ]\n }\n ],\n \"type\": \"pipeline\"\n}"
},
{
"name": "Bad Request",
"originalRequest": {
"method": "PUT",
"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 \"name\": \"\",\n \"filter\": {\n \"query\": \"source:python\"\n },\n \"id\": \"consequat elit non\",\n \"is_enabled\": true,\n \"is_read_only\": true,\n \"processors\": [\n {\n \"source\": \"message\",\n \"grok\": {\n \"match_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\",\n \"support_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\"\n },\n \"type\": \"grok-parser\",\n \"is_enabled\": false,\n \"name\": \"nostrud Excepteur\",\n \"samples\": [\n \"sit ea ullamco\",\n \"sunt est laboris\"\n ]\n },\n {\n \"source\": \"message\",\n \"grok\": {\n \"match_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\",\n \"support_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\"\n },\n \"type\": \"grok-parser\",\n \"is_enabled\": false,\n \"name\": \"exercitation do Ut\",\n \"samples\": [\n \"ut\",\n \"nulla tempor amet\"\n ]\n }\n ],\n \"type\": \"pipeline\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/logs/config/pipelines/:pipeline_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"logs",
"config",
"pipelines",
":pipeline_id"
],
"variable": [
{
"key": "pipeline_id"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "null"
},
{
"name": "Forbidden",
"originalRequest": {
"method": "PUT",
"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 \"name\": \"\",\n \"filter\": {\n \"query\": \"source:python\"\n },\n \"id\": \"consequat elit non\",\n \"is_enabled\": true,\n \"is_read_only\": true,\n \"processors\": [\n {\n \"source\": \"message\",\n \"grok\": {\n \"match_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\",\n \"support_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\"\n },\n \"type\": \"grok-parser\",\n \"is_enabled\": false,\n \"name\": \"nostrud Excepteur\",\n \"samples\": [\n \"sit ea ullamco\",\n \"sunt est laboris\"\n ]\n },\n {\n \"source\": \"message\",\n \"grok\": {\n \"match_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\",\n \"support_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\"\n },\n \"type\": \"grok-parser\",\n \"is_enabled\": false,\n \"name\": \"exercitation do Ut\",\n \"samples\": [\n \"ut\",\n \"nulla tempor amet\"\n ]\n }\n ],\n \"type\": \"pipeline\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/logs/config/pipelines/:pipeline_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"logs",
"config",
"pipelines",
":pipeline_id"
],
"variable": [
{
"key": "pipeline_id"
}
]
}
},
"status": "Forbidden",
"code": 403,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"Bad Request\",\n \"Bad Request\"\n ]\n}"
},
{
"name": "Too many requests",
"originalRequest": {
"method": "PUT",
"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 \"name\": \"\",\n \"filter\": {\n \"query\": \"source:python\"\n },\n \"id\": \"consequat elit non\",\n \"is_enabled\": true,\n \"is_read_only\": true,\n \"processors\": [\n {\n \"source\": \"message\",\n \"grok\": {\n \"match_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\",\n \"support_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\"\n },\n \"type\": \"grok-parser\",\n \"is_enabled\": false,\n \"name\": \"nostrud Excepteur\",\n \"samples\": [\n \"sit ea ullamco\",\n \"sunt est laboris\"\n ]\n },\n {\n \"source\": \"message\",\n \"grok\": {\n \"match_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\",\n \"support_rules\": \"rule_name_1 foo\\nrule_name_2 bar\\n\"\n },\n \"type\": \"grok-parser\",\n \"is_enabled\": false,\n \"name\": \"exercitation do Ut\",\n \"samples\": [\n \"ut\",\n \"nulla tempor amet\"\n ]\n }\n ],\n \"type\": \"pipeline\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/logs/config/pipelines/:pipeline_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"logs",
"config",
"pipelines",
":pipeline_id"
],
"variable": [
{
"key": "pipeline_id"
}
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"Bad Request\",\n \"Bad Request\"\n ]\n}"
}
]
}