Chilkat Online Tools

Unicode C++ / Datadog API Collection / Create an SLO object

Back to Collection Items

void ChilkatSample(void)
    {
    json.UpdateString(L"name",L"Custom Metric SLO");    json.UpdateInt(L"thresholds[0].target",95);    json.UpdateString(L"thresholds[0].timeframe",L"7d");    json.UpdateInt(L"thresholds[1].target",95);    json.UpdateString(L"thresholds[1].timeframe",L"30d");    json.UpdateInt(L"thresholds[1].warning",97);    json.UpdateString(L"type",L"metric");    json.UpdateString(L"description",L"non et");    json.UpdateString(L"groups[0]",L"env:prod");    json.UpdateString(L"groups[1]",L"role:mysql");    json.UpdateInt(L"monitor_ids[0]",19441105);    json.UpdateInt(L"monitor_ids[1]",-6429790);    json.UpdateString(L"query.numerator",L"sum:my.custom.metric{type:good}.as_count()");    json.UpdateString(L"query.denominator",L"sum:my.custom.metric{*}.as_count()");    json.UpdateString(L"tags[0]",L"env:prod");    json.UpdateString(L"tags[1]",L"app:core");    json.UpdateNumber(L"target_threshold",L"99.9");    json.UpdateString(L"timeframe",L"30d");    json.UpdateNumber(L"warning_threshold",L"99.95");    resp->GetBodySb(sbResponseBody);    jResp.LoadSb(sbResponseBody);    jResp.put_EmitCompact(false);    jResp.put_I(i);    name = jResp.stringOf(L"data[i].name");    v_type = jResp.stringOf(L"data[i].type");    created_at = jResp.IntOf(L"data[i].created_at");    v_Email = jResp.stringOf(L"data[i].creator.email");    Handle = jResp.stringOf(L"data[i].creator.handle");    Name = jResp.stringOf(L"data[i].creator.name");    description = jResp.stringOf(L"data[i].description");    id = jResp.stringOf(L"data[i].id");    modified_at = jResp.IntOf(L"data[i].modified_at");    Numerator = jResp.stringOf(L"data[i].query.numerator");    Denominator = jResp.stringOf(L"data[i].query.denominator");    target_threshold = jResp.stringOf(L"data[i].target_threshold");    timeframe = jResp.stringOf(L"data[i].timeframe");    warning_threshold = jResp.stringOf(L"data[i].warning_threshold");    j = 0;    count_j = jResp.SizeOfArray(L"data[i].thresholds");    jResp.put_J(j);    target = jResp.IntOf(L"data[i].thresholds[j].target");    timeframe = jResp.stringOf(L"data[i].thresholds[j].timeframe");    warning = jResp.IntOf(L"data[i].thresholds[j].warning");    j = j + 1;    j = 0;    count_j = jResp.SizeOfArray(L"data[i].groups");    jResp.put_J(j);    strVal = jResp.stringOf(L"data[i].groups[j]");    j = j + 1;    j = 0;    count_j = jResp.SizeOfArray(L"data[i].monitor_ids");    jResp.put_J(j);    intVal = jResp.IntOf(L"data[i].monitor_ids[j]");    j = j + 1;    j = 0;    count_j = jResp.SizeOfArray(L"data[i].monitor_tags");    jResp.put_J(j);    strVal = jResp.stringOf(L"data[i].monitor_tags[j]");    j = j + 1;    j = 0;    count_j = jResp.SizeOfArray(L"data[i].tags");    jResp.put_J(j);    strVal = jResp.stringOf(L"data[i].tags[j]");    j = j + 1;    i = i + 1;    i = 0;    count_i = jResp.SizeOfArray(L"errors");    jResp.put_I(i);    strVal = jResp.stringOf(L"errors[i]");    i = i + 1;
    }

Curl Command

curl -X POST
	-H "Content-Type: application/json"
	-H "Accept: application/json"
	-d '{
  "name": "Custom Metric SLO",
  "thresholds": [
    {
      "target": 95,
      "timeframe": "7d"
    },
    {
      "target": 95,
      "timeframe": "30d",
      "warning": 97
    }
  ],
  "type": "metric",
  "description": "non et",
  "groups": [
    "env:prod",
    "role:mysql"
  ],
  "monitor_ids": [
    19441105,
    -6429790
  ],
  "query": {
    "numerator": "sum:my.custom.metric{type:good}.as_count()",
    "denominator": "sum:my.custom.metric{*}.as_count()"
  },
  "tags": [
    "env:prod",
    "app:core"
  ],
  "target_threshold": 99.9,
  "timeframe": "30d",
  "warning_threshold": 99.95
}'
https://api.app.ddog-gov.com/api/v1/slo

Postman Collection Item JSON

{
  "name": "Create an SLO object",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      },
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n  \"name\": \"Custom Metric SLO\",\n  \"thresholds\": [\n    {\n      \"target\": 95,\n      \"timeframe\": \"7d\"\n    },\n    {\n      \"target\": 95,\n      \"timeframe\": \"30d\",\n      \"warning\": 97\n    }\n  ],\n  \"type\": \"metric\",\n  \"description\": \"non et\",\n  \"groups\": [\n    \"env:prod\",\n    \"role:mysql\"\n  ],\n  \"monitor_ids\": [\n    19441105,\n    -6429790\n  ],\n  \"query\": {\n    \"numerator\": \"sum:my.custom.metric{type:good}.as_count()\",\n    \"denominator\": \"sum:my.custom.metric{*}.as_count()\"\n  },\n  \"tags\": [\n    \"env:prod\",\n    \"app:core\"\n  ],\n  \"target_threshold\": 99.9,\n  \"timeframe\": \"30d\",\n  \"warning_threshold\": 99.95\n}",
      "options": {
        "raw": {
          "headerFamily": "json",
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{baseUrl}}/api/v1/slo",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v1",
        "slo"
      ]
    },
    "description": "Create a service level objective object."
  },
  "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  \"name\": \"Custom Metric SLO\",\n  \"thresholds\": [\n    {\n      \"target\": 95,\n      \"timeframe\": \"7d\"\n    },\n    {\n      \"target\": 95,\n      \"timeframe\": \"30d\",\n      \"warning\": 97\n    }\n  ],\n  \"type\": \"metric\",\n  \"description\": \"non et\",\n  \"groups\": [\n    \"env:prod\",\n    \"role:mysql\"\n  ],\n  \"monitor_ids\": [\n    19441105,\n    -6429790\n  ],\n  \"query\": {\n    \"numerator\": \"sum:my.custom.metric{type:good}.as_count()\",\n    \"denominator\": \"sum:my.custom.metric{*}.as_count()\"\n  },\n  \"tags\": [\n    \"env:prod\",\n    \"app:core\"\n  ],\n  \"target_threshold\": 99.9,\n  \"timeframe\": \"30d\",\n  \"warning_threshold\": 99.95\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/slo",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "slo"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"data\": [\n    {\n      \"name\": \"Custom Metric SLO\",\n      \"thresholds\": [\n        {\n          \"target\": 95,\n          \"timeframe\": \"7d\"\n        },\n        {\n          \"target\": 95,\n          \"timeframe\": \"30d\",\n          \"warning\": 97\n        }\n      ],\n      \"type\": \"metric\",\n      \"created_at\": -94400396,\n      \"creator\": {\n        \"email\": \"esse ullamco\",\n        \"handle\": \"pariatur irure sit non\",\n        \"name\": \"in proident laborum\"\n      },\n      \"description\": \"est proident magna reprehenderit\",\n      \"groups\": [\n        \"env:prod\",\n        \"role:mysql\"\n      ],\n      \"id\": \"ipsum laboris consequat\",\n      \"modified_at\": -34908193,\n      \"monitor_ids\": [\n        35412081,\n        -51315393\n      ],\n      \"monitor_tags\": [\n        \"voluptate adipisicing fugiat elit\",\n        \"reprehenderit et nostrud pariatur Excepteur\"\n      ],\n      \"query\": {\n        \"numerator\": \"sum:my.custom.metric{type:good}.as_count()\",\n        \"denominator\": \"sum:my.custom.metric{*}.as_count()\"\n      },\n      \"tags\": [\n        \"env:prod\",\n        \"app:core\"\n      ],\n      \"target_threshold\": 99.9,\n      \"timeframe\": \"30d\",\n      \"warning_threshold\": 99.95\n    },\n    {\n      \"name\": \"Custom Metric SLO\",\n      \"thresholds\": [\n        {\n          \"target\": 95,\n          \"timeframe\": \"7d\"\n        },\n        {\n          \"target\": 95,\n          \"timeframe\": \"30d\",\n          \"warning\": 97\n        }\n      ],\n      \"type\": \"metric\",\n      \"created_at\": -83055437,\n      \"creator\": {\n        \"email\": \"exercitation\",\n        \"handle\": \"commodo aute incididunt ut\",\n        \"name\": \"Lorem dolor irure\"\n      },\n      \"description\": \"do nostrud ex sit\",\n      \"groups\": [\n        \"env:prod\",\n        \"role:mysql\"\n      ],\n      \"id\": \"ut elit commodo\",\n      \"modified_at\": -65512371,\n      \"monitor_ids\": [\n        70922825,\n        -10561601\n      ],\n      \"monitor_tags\": [\n        \"laborum aliqua proident\",\n        \"ullamco cillum ea consectetur\"\n      ],\n      \"query\": {\n        \"numerator\": \"sum:my.custom.metric{type:good}.as_count()\",\n        \"denominator\": \"sum:my.custom.metric{*}.as_count()\"\n      },\n      \"tags\": [\n        \"env:prod\",\n        \"app:core\"\n      ],\n      \"target_threshold\": 99.9,\n      \"timeframe\": \"30d\",\n      \"warning_threshold\": 99.95\n    }\n  ],\n  \"errors\": [\n    \"deserunt in fugiat\",\n    \"proident\"\n  ],\n  \"metadata\": {\n    \"page\": {\n      \"total_count\": 69715777,\n      \"total_filtered_count\": -16033264\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  \"name\": \"Custom Metric SLO\",\n  \"thresholds\": [\n    {\n      \"target\": 95,\n      \"timeframe\": \"7d\"\n    },\n    {\n      \"target\": 95,\n      \"timeframe\": \"30d\",\n      \"warning\": 97\n    }\n  ],\n  \"type\": \"metric\",\n  \"description\": \"non et\",\n  \"groups\": [\n    \"env:prod\",\n    \"role:mysql\"\n  ],\n  \"monitor_ids\": [\n    19441105,\n    -6429790\n  ],\n  \"query\": {\n    \"numerator\": \"sum:my.custom.metric{type:good}.as_count()\",\n    \"denominator\": \"sum:my.custom.metric{*}.as_count()\"\n  },\n  \"tags\": [\n    \"env:prod\",\n    \"app:core\"\n  ],\n  \"target_threshold\": 99.9,\n  \"timeframe\": \"30d\",\n  \"warning_threshold\": 99.95\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/slo",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "slo"
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"Bad Request\",\n    \"Bad Request\"\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  \"name\": \"Custom Metric SLO\",\n  \"thresholds\": [\n    {\n      \"target\": 95,\n      \"timeframe\": \"7d\"\n    },\n    {\n      \"target\": 95,\n      \"timeframe\": \"30d\",\n      \"warning\": 97\n    }\n  ],\n  \"type\": \"metric\",\n  \"description\": \"non et\",\n  \"groups\": [\n    \"env:prod\",\n    \"role:mysql\"\n  ],\n  \"monitor_ids\": [\n    19441105,\n    -6429790\n  ],\n  \"query\": {\n    \"numerator\": \"sum:my.custom.metric{type:good}.as_count()\",\n    \"denominator\": \"sum:my.custom.metric{*}.as_count()\"\n  },\n  \"tags\": [\n    \"env:prod\",\n    \"app:core\"\n  ],\n  \"target_threshold\": 99.9,\n  \"timeframe\": \"30d\",\n  \"warning_threshold\": 99.95\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/slo",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "slo"
          ]
        }
      },
      "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": "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  \"name\": \"Custom Metric SLO\",\n  \"thresholds\": [\n    {\n      \"target\": 95,\n      \"timeframe\": \"7d\"\n    },\n    {\n      \"target\": 95,\n      \"timeframe\": \"30d\",\n      \"warning\": 97\n    }\n  ],\n  \"type\": \"metric\",\n  \"description\": \"non et\",\n  \"groups\": [\n    \"env:prod\",\n    \"role:mysql\"\n  ],\n  \"monitor_ids\": [\n    19441105,\n    -6429790\n  ],\n  \"query\": {\n    \"numerator\": \"sum:my.custom.metric{type:good}.as_count()\",\n    \"denominator\": \"sum:my.custom.metric{*}.as_count()\"\n  },\n  \"tags\": [\n    \"env:prod\",\n    \"app:core\"\n  ],\n  \"target_threshold\": 99.9,\n  \"timeframe\": \"30d\",\n  \"warning_threshold\": 99.95\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/slo",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "slo"
          ]
        }
      },
      "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}"
    }
  ]
}