Back to Collection Items
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
DECLARE @queryParams int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @queryParams OUT
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'group_states', 'tempor Ut sed velit'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'with_downtimes', 'true'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Accept', 'application/json'
DECLARE @resp int
EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://api.app.ddog-gov.com/api/v1/monitor/:monitor_id', @queryParams
EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
RETURN
END
DECLARE @sbResponseBody int
-- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @resp, 'GetBodySb', @success OUT, @sbResponseBody
DECLARE @jResp int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT
EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
EXEC sp_OASetProperty @jResp, 'EmitCompact', 0
PRINT 'Response Body:'
EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
PRINT @sTmp0
DECLARE @respStatusCode int
EXEC sp_OAGetProperty @resp, 'StatusCode', @respStatusCode OUT
PRINT 'Response Status Code = ' + @respStatusCode
IF @respStatusCode >= 400
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @resp, 'Header', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Failed.'
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
RETURN
END
EXEC @hr = sp_OADestroy @resp
-- Sample JSON response:
-- (Sample code for parsing the JSON response is shown below)
-- {
-- "type": "query alert",
-- "query": "avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100",
-- "created": "1989-12-01T14:28:43.831Z",
-- "creator": {
-- "email": "officia sunt",
-- "handle": "pariatur",
-- "name": "aute do"
-- },
-- "deleted": "2020-10-30T20:46:24.520Z",
-- "id": -50675854,
-- "matching_downtimes": [
-- {
-- "id": 1625,
-- "end": 1412792983,
-- "scope": [
-- "env:staging"
-- ],
-- "start": 1412792983
-- },
-- {
-- "id": 1625,
-- "end": 1412792983,
-- "scope": [
-- "env:staging"
-- ],
-- "start": 1412792983
-- }
-- ],
-- "message": "ullamco incididunt cupidatat",
-- "modified": "1981-03-27T05:04:03.098Z",
-- "multi": false,
-- "name": "My monitor",
-- "options": {
-- "aggregation": {
-- "group_by": "host",
-- "metric": "metrics.name",
-- "type": "count"
-- },
-- "device_ids": [
-- "mobile_small",
-- "chrome.tablet"
-- ],
-- "enable_logs_sample": false,
-- "enable_samples": false,
-- "escalation_message": "none",
-- "evaluation_delay": -52819274,
-- "group_retention_duration": "dolor Lorem qui",
-- "groupby_simple_monitor": false,
-- "include_tags": true,
-- "locked": false,
-- "min_failure_duration": 0,
-- "min_location_failed": 1,
-- "new_group_delay": -94315945,
-- "new_host_delay": 300,
-- "no_data_timeframe": -86360342,
-- "notification_preset_name": "show_all",
-- "notify_audit": false,
-- "notify_by": [
-- "labore dolore",
-- "deserunt commodo consectetur"
-- ],
-- "notify_no_data": false,
-- "on_missing_data": "resolve",
-- "renotify_interval": null,
-- "renotify_occurrences": 56355858,
-- "renotify_statuses": [
-- "warn",
-- "no data"
-- ],
-- "require_full_window": false,
-- "scheduling_options": {
-- "evaluation_window": {
-- "day_starts": "04:00",
-- "hour_starts": 0,
-- "month_starts": 1
-- }
-- },
-- "silenced": {
-- "non_6f_": 77287100
-- },
-- "synthetics_check_id": "culpa in laborum irure",
-- "threshold_windows": {
-- "recovery_window": "culpa cupidatat Lorem ut",
-- "trigger_window": "fugiat officia mollit esse quis"
-- },
-- "thresholds": {
-- "critical": -44507487.0891542,
-- "critical_recovery": 94365870.17342958,
-- "ok": 26645340.31156695,
-- "unknown": -32772943.396166816,
-- "warning": 75330874.10211122,
-- "warning_recovery": 30665996.226613894
-- },
-- "timeout_h": null,
-- "variables": [
-- {
-- "data_source": "rum",
-- "compute": {
-- "aggregation": "avg",
-- "interval": 60000,
-- "metric": "@duration"
-- },
-- "name": "query_errors",
-- "group_by": [
-- {
-- "facet": "status",
-- "limit": 10,
-- "sort": {
-- "aggregation": "avg",
-- "metric": "minim tempor i",
-- "order": "desc"
-- }
-- },
-- {
-- "facet": "status",
-- "limit": 10,
-- "sort": {
-- "aggregation": "avg",
-- "metric": "Ut fugiat officia",
-- "order": "desc"
-- }
-- }
-- ],
-- "indexes": [
-- "days-3",
-- "days-7"
-- ],
-- "search": {
-- "query": "service:query"
-- }
-- },
-- {
-- "data_source": "rum",
-- "compute": {
-- "aggregation": "avg",
-- "interval": 60000,
-- "metric": "@duration"
-- },
-- "name": "query_errors",
-- "group_by": [
-- {
-- "facet": "status",
-- "limit": 10,
-- "sort": {
-- "aggregation": "avg",
-- "metric": "do velit",
-- "order": "desc"
-- }
-- },
-- {
-- "facet": "status",
-- "limit": 10,
-- "sort": {
-- "aggregation": "avg",
-- "metric": "amet proident anim in",
-- "order": "desc"
-- }
-- }
-- ],
-- "indexes": [
-- "days-3",
-- "days-7"
-- ],
-- "search": {
-- "query": "service:query"
-- }
-- }
-- ]
-- },
-- "overall_state": "Warn",
-- "priority": 1,
-- "restricted_roles": [
-- "enim qui cillum est",
-- "quis ut"
-- ],
-- "state": {
-- "groups": {
-- "Lorem_1": {
-- "last_nodata_ts": -12653992,
-- "last_notified_ts": -66141067,
-- "last_resolved_ts": 5643925,
-- "last_triggered_ts": -6121593,
-- "name": "dolore nulla i",
-- "status": "OK"
-- },
-- "nisi_c43": {
-- "last_nodata_ts": -66061060,
-- "last_notified_ts": -86988012,
-- "last_resolved_ts": -39919633,
-- "last_triggered_ts": 13467862,
-- "name": "Ut fugiat eiusmod anim",
-- "status": "Ignored"
-- },
-- "minim_c": {
-- "last_nodata_ts": 6509669,
-- "last_notified_ts": 39348490,
-- "last_resolved_ts": 13221088,
-- "last_triggered_ts": 21889420,
-- "name": "in velit Duis",
-- "status": "Alert"
-- }
-- }
-- },
-- "tags": [
-- "ex tempor",
-- "enim veniam dolore"
-- ]
-- }
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @v_end int
DECLARE @start int
DECLARE @j int
DECLARE @count_j int
DECLARE @strVal nvarchar(4000)
DECLARE @data_source nvarchar(4000)
DECLARE @Aggregation nvarchar(4000)
DECLARE @Interval int
DECLARE @computeMetric nvarchar(4000)
DECLARE @Query nvarchar(4000)
DECLARE @facet nvarchar(4000)
DECLARE @limit int
DECLARE @sortAggregation nvarchar(4000)
DECLARE @sortMetric nvarchar(4000)
DECLARE @Order nvarchar(4000)
DECLARE @v_type nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @v_type OUT, 'type'
DECLARE @query nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @query OUT, 'query'
DECLARE @created nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @created OUT, 'created'
DECLARE @v_Email nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @v_Email OUT, 'creator.email'
DECLARE @Handle nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Handle OUT, 'creator.handle'
DECLARE @Name nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Name OUT, 'creator.name'
DECLARE @deleted nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @deleted OUT, 'deleted'
DECLARE @id int
EXEC sp_OAMethod @jResp, 'IntOf', @id OUT, 'id'
DECLARE @message nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @message OUT, 'message'
DECLARE @modified nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @modified OUT, 'modified'
DECLARE @multi int
EXEC sp_OAMethod @jResp, 'BoolOf', @multi OUT, 'multi'
DECLARE @name nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @name OUT, 'name'
DECLARE @Group_by nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Group_by OUT, 'options.aggregation.group_by'
DECLARE @Metric nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Metric OUT, 'options.aggregation.metric'
DECLARE @v_Type nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @v_Type OUT, 'options.aggregation.type'
DECLARE @Enable_logs_sample int
EXEC sp_OAMethod @jResp, 'BoolOf', @Enable_logs_sample OUT, 'options.enable_logs_sample'
DECLARE @Enable_samples int
EXEC sp_OAMethod @jResp, 'BoolOf', @Enable_samples OUT, 'options.enable_samples'
DECLARE @Escalation_message nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Escalation_message OUT, 'options.escalation_message'
DECLARE @Evaluation_delay int
EXEC sp_OAMethod @jResp, 'IntOf', @Evaluation_delay OUT, 'options.evaluation_delay'
DECLARE @Group_retention_duration nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Group_retention_duration OUT, 'options.group_retention_duration'
DECLARE @Groupby_simple_monitor int
EXEC sp_OAMethod @jResp, 'BoolOf', @Groupby_simple_monitor OUT, 'options.groupby_simple_monitor'
DECLARE @Include_tags int
EXEC sp_OAMethod @jResp, 'BoolOf', @Include_tags OUT, 'options.include_tags'
DECLARE @Locked int
EXEC sp_OAMethod @jResp, 'BoolOf', @Locked OUT, 'options.locked'
DECLARE @Min_failure_duration int
EXEC sp_OAMethod @jResp, 'IntOf', @Min_failure_duration OUT, 'options.min_failure_duration'
DECLARE @Min_location_failed int
EXEC sp_OAMethod @jResp, 'IntOf', @Min_location_failed OUT, 'options.min_location_failed'
DECLARE @New_group_delay int
EXEC sp_OAMethod @jResp, 'IntOf', @New_group_delay OUT, 'options.new_group_delay'
DECLARE @New_host_delay int
EXEC sp_OAMethod @jResp, 'IntOf', @New_host_delay OUT, 'options.new_host_delay'
DECLARE @No_data_timeframe int
EXEC sp_OAMethod @jResp, 'IntOf', @No_data_timeframe OUT, 'options.no_data_timeframe'
DECLARE @Notification_preset_name nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Notification_preset_name OUT, 'options.notification_preset_name'
DECLARE @Notify_audit int
EXEC sp_OAMethod @jResp, 'BoolOf', @Notify_audit OUT, 'options.notify_audit'
DECLARE @Notify_no_data int
EXEC sp_OAMethod @jResp, 'BoolOf', @Notify_no_data OUT, 'options.notify_no_data'
DECLARE @On_missing_data nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @On_missing_data OUT, 'options.on_missing_data'
DECLARE @Renotify_interval nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Renotify_interval OUT, 'options.renotify_interval'
DECLARE @Renotify_occurrences int
EXEC sp_OAMethod @jResp, 'IntOf', @Renotify_occurrences OUT, 'options.renotify_occurrences'
DECLARE @Require_full_window int
EXEC sp_OAMethod @jResp, 'BoolOf', @Require_full_window OUT, 'options.require_full_window'
DECLARE @Day_starts nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Day_starts OUT, 'options.scheduling_options.evaluation_window.day_starts'
DECLARE @Hour_starts int
EXEC sp_OAMethod @jResp, 'IntOf', @Hour_starts OUT, 'options.scheduling_options.evaluation_window.hour_starts'
DECLARE @Month_starts int
EXEC sp_OAMethod @jResp, 'IntOf', @Month_starts OUT, 'options.scheduling_options.evaluation_window.month_starts'
DECLARE @Non_6f_ int
EXEC sp_OAMethod @jResp, 'IntOf', @Non_6f_ OUT, 'options.silenced.non_6f_'
DECLARE @Synthetics_check_id nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Synthetics_check_id OUT, 'options.synthetics_check_id'
DECLARE @Recovery_window nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Recovery_window OUT, 'options.threshold_windows.recovery_window'
DECLARE @Trigger_window nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Trigger_window OUT, 'options.threshold_windows.trigger_window'
DECLARE @Critical nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Critical OUT, 'options.thresholds.critical'
DECLARE @Critical_recovery nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Critical_recovery OUT, 'options.thresholds.critical_recovery'
DECLARE @Ok nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Ok OUT, 'options.thresholds.ok'
DECLARE @Unknown nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Unknown OUT, 'options.thresholds.unknown'
DECLARE @Warning nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Warning OUT, 'options.thresholds.warning'
DECLARE @Warning_recovery nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Warning_recovery OUT, 'options.thresholds.warning_recovery'
DECLARE @Timeout_h nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Timeout_h OUT, 'options.timeout_h'
DECLARE @overall_state nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @overall_state OUT, 'overall_state'
DECLARE @priority int
EXEC sp_OAMethod @jResp, 'IntOf', @priority OUT, 'priority'
DECLARE @Last_nodata_ts int
EXEC sp_OAMethod @jResp, 'IntOf', @Last_nodata_ts OUT, 'state.groups.Lorem_1.last_nodata_ts'
DECLARE @Last_notified_ts int
EXEC sp_OAMethod @jResp, 'IntOf', @Last_notified_ts OUT, 'state.groups.Lorem_1.last_notified_ts'
DECLARE @Last_resolved_ts int
EXEC sp_OAMethod @jResp, 'IntOf', @Last_resolved_ts OUT, 'state.groups.Lorem_1.last_resolved_ts'
DECLARE @Last_triggered_ts int
EXEC sp_OAMethod @jResp, 'IntOf', @Last_triggered_ts OUT, 'state.groups.Lorem_1.last_triggered_ts'
DECLARE @Lorem_1Name nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Lorem_1Name OUT, 'state.groups.Lorem_1.name'
DECLARE @Status nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Status OUT, 'state.groups.Lorem_1.status'
DECLARE @Nisi_c43Last_nodata_ts int
EXEC sp_OAMethod @jResp, 'IntOf', @Nisi_c43Last_nodata_ts OUT, 'state.groups.nisi_c43.last_nodata_ts'
DECLARE @Nisi_c43Last_notified_ts int
EXEC sp_OAMethod @jResp, 'IntOf', @Nisi_c43Last_notified_ts OUT, 'state.groups.nisi_c43.last_notified_ts'
DECLARE @Nisi_c43Last_resolved_ts int
EXEC sp_OAMethod @jResp, 'IntOf', @Nisi_c43Last_resolved_ts OUT, 'state.groups.nisi_c43.last_resolved_ts'
DECLARE @Nisi_c43Last_triggered_ts int
EXEC sp_OAMethod @jResp, 'IntOf', @Nisi_c43Last_triggered_ts OUT, 'state.groups.nisi_c43.last_triggered_ts'
DECLARE @Nisi_c43Name nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Nisi_c43Name OUT, 'state.groups.nisi_c43.name'
DECLARE @Nisi_c43Status nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Nisi_c43Status OUT, 'state.groups.nisi_c43.status'
DECLARE @Minim_cLast_nodata_ts int
EXEC sp_OAMethod @jResp, 'IntOf', @Minim_cLast_nodata_ts OUT, 'state.groups.minim_c.last_nodata_ts'
DECLARE @Minim_cLast_notified_ts int
EXEC sp_OAMethod @jResp, 'IntOf', @Minim_cLast_notified_ts OUT, 'state.groups.minim_c.last_notified_ts'
DECLARE @Minim_cLast_resolved_ts int
EXEC sp_OAMethod @jResp, 'IntOf', @Minim_cLast_resolved_ts OUT, 'state.groups.minim_c.last_resolved_ts'
DECLARE @Minim_cLast_triggered_ts int
EXEC sp_OAMethod @jResp, 'IntOf', @Minim_cLast_triggered_ts OUT, 'state.groups.minim_c.last_triggered_ts'
DECLARE @Minim_cName nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Minim_cName OUT, 'state.groups.minim_c.name'
DECLARE @Minim_cStatus nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Minim_cStatus OUT, 'state.groups.minim_c.status'
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'matching_downtimes'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'IntOf', @id OUT, 'matching_downtimes[i].id'
EXEC sp_OAMethod @jResp, 'IntOf', @v_end OUT, 'matching_downtimes[i].end'
EXEC sp_OAMethod @jResp, 'IntOf', @start OUT, 'matching_downtimes[i].start'
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'matching_downtimes[i].scope'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'matching_downtimes[i].scope[j]'
SELECT @j = @j + 1
END
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'options.device_ids'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'options.device_ids[i]'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'options.notify_by'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'options.notify_by[i]'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'options.renotify_statuses'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'options.renotify_statuses[i]'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'options.variables'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @data_source OUT, 'options.variables[i].data_source'
EXEC sp_OAMethod @jResp, 'StringOf', @Aggregation OUT, 'options.variables[i].compute.aggregation'
EXEC sp_OAMethod @jResp, 'IntOf', @Interval OUT, 'options.variables[i].compute.interval'
EXEC sp_OAMethod @jResp, 'StringOf', @computeMetric OUT, 'options.variables[i].compute.metric'
EXEC sp_OAMethod @jResp, 'StringOf', @name OUT, 'options.variables[i].name'
EXEC sp_OAMethod @jResp, 'StringOf', @Query OUT, 'options.variables[i].search.query'
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'options.variables[i].group_by'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @facet OUT, 'options.variables[i].group_by[j].facet'
EXEC sp_OAMethod @jResp, 'IntOf', @limit OUT, 'options.variables[i].group_by[j].limit'
EXEC sp_OAMethod @jResp, 'StringOf', @sortAggregation OUT, 'options.variables[i].group_by[j].sort.aggregation'
EXEC sp_OAMethod @jResp, 'StringOf', @sortMetric OUT, 'options.variables[i].group_by[j].sort.metric'
EXEC sp_OAMethod @jResp, 'StringOf', @Order OUT, 'options.variables[i].group_by[j].sort.order'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'options.variables[i].indexes'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'options.variables[i].indexes[j]'
SELECT @j = @j + 1
END
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'restricted_roles'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'restricted_roles[i]'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'tags'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'tags[i]'
SELECT @i = @i + 1
END
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO
Curl Command
curl -G -d "group_states=tempor%20Ut%20sed%20velit"
-d "with_downtimes=true"
-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v1/monitor/:monitor_id
Postman Collection Item JSON
{
"name": "Get a monitor's details",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v1/monitor/:monitor_id?group_states=tempor Ut sed velit&with_downtimes=true",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"monitor",
":monitor_id"
],
"query": [
{
"key": "group_states",
"value": "tempor Ut sed velit",
"description": "When specified, shows additional information about the group states. Choose one or more from `all`, `alert`, `warn`, and `no data`."
},
{
"key": "with_downtimes",
"value": "true",
"description": "If this argument is set to true, then the returned data includes all current active downtimes for the monitor."
}
],
"variable": [
{
"key": "monitor_id",
"value": "666486743"
}
]
},
"description": "Get details about the specified monitor from your organization."
},
"response": [
{
"name": "OK",
"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/v1/monitor/:monitor_id?group_states=tempor Ut sed velit&with_downtimes=true",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"monitor",
":monitor_id"
],
"query": [
{
"key": "group_states",
"value": "tempor Ut sed velit",
"description": "When specified, shows additional information about the group states. Choose one or more from `all`, `alert`, `warn`, and `no data`."
},
{
"key": "with_downtimes",
"value": "true",
"description": "If this argument is set to true, then the returned data includes all current active downtimes for the monitor."
}
],
"variable": [
{
"key": "monitor_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"type\": \"query alert\",\n \"query\": \"avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100\",\n \"created\": \"1989-12-01T14:28:43.831Z\",\n \"creator\": {\n \"email\": \"officia sunt\",\n \"handle\": \"pariatur\",\n \"name\": \"aute do\"\n },\n \"deleted\": \"2020-10-30T20:46:24.520Z\",\n \"id\": -50675854,\n \"matching_downtimes\": [\n {\n \"id\": 1625,\n \"end\": 1412792983,\n \"scope\": [\n \"env:staging\"\n ],\n \"start\": 1412792983\n },\n {\n \"id\": 1625,\n \"end\": 1412792983,\n \"scope\": [\n \"env:staging\"\n ],\n \"start\": 1412792983\n }\n ],\n \"message\": \"ullamco incididunt cupidatat\",\n \"modified\": \"1981-03-27T05:04:03.098Z\",\n \"multi\": false,\n \"name\": \"My monitor\",\n \"options\": {\n \"aggregation\": {\n \"group_by\": \"host\",\n \"metric\": \"metrics.name\",\n \"type\": \"count\"\n },\n \"device_ids\": [\n \"mobile_small\",\n \"chrome.tablet\"\n ],\n \"enable_logs_sample\": false,\n \"enable_samples\": false,\n \"escalation_message\": \"none\",\n \"evaluation_delay\": -52819274,\n \"group_retention_duration\": \"dolor Lorem qui\",\n \"groupby_simple_monitor\": false,\n \"include_tags\": true,\n \"locked\": false,\n \"min_failure_duration\": 0,\n \"min_location_failed\": 1,\n \"new_group_delay\": -94315945,\n \"new_host_delay\": 300,\n \"no_data_timeframe\": -86360342,\n \"notification_preset_name\": \"show_all\",\n \"notify_audit\": false,\n \"notify_by\": [\n \"labore dolore\",\n \"deserunt commodo consectetur\"\n ],\n \"notify_no_data\": false,\n \"on_missing_data\": \"resolve\",\n \"renotify_interval\": null,\n \"renotify_occurrences\": 56355858,\n \"renotify_statuses\": [\n \"warn\",\n \"no data\"\n ],\n \"require_full_window\": false,\n \"scheduling_options\": {\n \"evaluation_window\": {\n \"day_starts\": \"04:00\",\n \"hour_starts\": 0,\n \"month_starts\": 1\n }\n },\n \"silenced\": {\n \"non_6f_\": 77287100\n },\n \"synthetics_check_id\": \"culpa in laborum irure\",\n \"threshold_windows\": {\n \"recovery_window\": \"culpa cupidatat Lorem ut\",\n \"trigger_window\": \"fugiat officia mollit esse quis\"\n },\n \"thresholds\": {\n \"critical\": -44507487.0891542,\n \"critical_recovery\": 94365870.17342958,\n \"ok\": 26645340.31156695,\n \"unknown\": -32772943.396166816,\n \"warning\": 75330874.10211122,\n \"warning_recovery\": 30665996.226613894\n },\n \"timeout_h\": null,\n \"variables\": [\n {\n \"data_source\": \"rum\",\n \"compute\": {\n \"aggregation\": \"avg\",\n \"interval\": 60000,\n \"metric\": \"@duration\"\n },\n \"name\": \"query_errors\",\n \"group_by\": [\n {\n \"facet\": \"status\",\n \"limit\": 10,\n \"sort\": {\n \"aggregation\": \"avg\",\n \"metric\": \"minim tempor i\",\n \"order\": \"desc\"\n }\n },\n {\n \"facet\": \"status\",\n \"limit\": 10,\n \"sort\": {\n \"aggregation\": \"avg\",\n \"metric\": \"Ut fugiat officia\",\n \"order\": \"desc\"\n }\n }\n ],\n \"indexes\": [\n \"days-3\",\n \"days-7\"\n ],\n \"search\": {\n \"query\": \"service:query\"\n }\n },\n {\n \"data_source\": \"rum\",\n \"compute\": {\n \"aggregation\": \"avg\",\n \"interval\": 60000,\n \"metric\": \"@duration\"\n },\n \"name\": \"query_errors\",\n \"group_by\": [\n {\n \"facet\": \"status\",\n \"limit\": 10,\n \"sort\": {\n \"aggregation\": \"avg\",\n \"metric\": \"do velit\",\n \"order\": \"desc\"\n }\n },\n {\n \"facet\": \"status\",\n \"limit\": 10,\n \"sort\": {\n \"aggregation\": \"avg\",\n \"metric\": \"amet proident anim in\",\n \"order\": \"desc\"\n }\n }\n ],\n \"indexes\": [\n \"days-3\",\n \"days-7\"\n ],\n \"search\": {\n \"query\": \"service:query\"\n }\n }\n ]\n },\n \"overall_state\": \"Warn\",\n \"priority\": 1,\n \"restricted_roles\": [\n \"enim qui cillum est\",\n \"quis ut\"\n ],\n \"state\": {\n \"groups\": {\n \"Lorem_1\": {\n \"last_nodata_ts\": -12653992,\n \"last_notified_ts\": -66141067,\n \"last_resolved_ts\": 5643925,\n \"last_triggered_ts\": -6121593,\n \"name\": \"dolore nulla i\",\n \"status\": \"OK\"\n },\n \"nisi_c43\": {\n \"last_nodata_ts\": -66061060,\n \"last_notified_ts\": -86988012,\n \"last_resolved_ts\": -39919633,\n \"last_triggered_ts\": 13467862,\n \"name\": \"Ut fugiat eiusmod anim\",\n \"status\": \"Ignored\"\n },\n \"minim_c\": {\n \"last_nodata_ts\": 6509669,\n \"last_notified_ts\": 39348490,\n \"last_resolved_ts\": 13221088,\n \"last_triggered_ts\": 21889420,\n \"name\": \"in velit Duis\",\n \"status\": \"Alert\"\n }\n }\n },\n \"tags\": [\n \"ex tempor\",\n \"enim veniam dolore\"\n ]\n}"
},
{
"name": "Bad Request",
"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/v1/monitor/:monitor_id?group_states=tempor Ut sed velit&with_downtimes=true",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"monitor",
":monitor_id"
],
"query": [
{
"key": "group_states",
"value": "tempor Ut sed velit",
"description": "When specified, shows additional information about the group states. Choose one or more from `all`, `alert`, `warn`, and `no data`."
},
{
"key": "with_downtimes",
"value": "true",
"description": "If this argument is set to true, then the returned data includes all current active downtimes for the monitor."
}
],
"variable": [
{
"key": "monitor_id"
}
]
}
},
"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": "Authentication error",
"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/v1/monitor/:monitor_id?group_states=tempor Ut sed velit&with_downtimes=true",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"monitor",
":monitor_id"
],
"query": [
{
"key": "group_states",
"value": "tempor Ut sed velit",
"description": "When specified, shows additional information about the group states. Choose one or more from `all`, `alert`, `warn`, and `no data`."
},
{
"key": "with_downtimes",
"value": "true",
"description": "If this argument is set to true, then the returned data includes all current active downtimes for the monitor."
}
],
"variable": [
{
"key": "monitor_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": "Monitor Not Found error",
"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/v1/monitor/:monitor_id?group_states=tempor Ut sed velit&with_downtimes=true",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"monitor",
":monitor_id"
],
"query": [
{
"key": "group_states",
"value": "tempor Ut sed velit",
"description": "When specified, shows additional information about the group states. Choose one or more from `all`, `alert`, `warn`, and `no data`."
},
{
"key": "with_downtimes",
"value": "true",
"description": "If this argument is set to true, then the returned data includes all current active downtimes for the monitor."
}
],
"variable": [
{
"key": "monitor_id"
}
]
}
},
"status": "Not Found",
"code": 404,
"_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": "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/v1/monitor/:monitor_id?group_states=tempor Ut sed velit&with_downtimes=true",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"monitor",
":monitor_id"
],
"query": [
{
"key": "group_states",
"value": "tempor Ut sed velit",
"description": "When specified, shows additional information about the group states. Choose one or more from `all`, `alert`, `warn`, and `no data`."
},
{
"key": "with_downtimes",
"value": "true",
"description": "If this argument is set to true, then the returned data includes all current active downtimes for the monitor."
}
],
"variable": [
{
"key": "monitor_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}"
}
]
}