fbpx
POSThttps://api.spotinst.io/spectrum/metrics/alert?accountId={ACCOUNT_ID}

Creates an Alert

URL Parameters

Parameter Type Description
ACCOUNT_ID String

Account ID from Spotinst console

Example: act-12345
Request - Example1

Headers
{
    "Content-Type": "application/json",
    "Authorization": "Bearer ${TOKEN}"
}
Body
Copied!
Downloaded!
{
  "alert": {
    "enabled": true,
    "name": "Spotinst - High CPU load",
    "description": "One or more of the instances have high CPU utilization",
    "documentation": "",
    "namespace": "spotinst/compute",
    "metricName": "cpu_load",
    "dimensions": [
      {
        "name": "instance_id",
        "value": "i-123456"
      }
    ],
    "statistic": "sum",
    "period": "1m",
    "consecutivePeriods": 1,
    "conditions": {
      "critical": {
        "threshold": 80,
        "operator": "gt"
      }
    },
    "actionsEnabled": true,
    "actions": {
      "unknownActionIds": [],
      "okActionIds": [],
      "warningActionIds": [],
      "errorActionIds": [],
      "criticalActionIds": [
        "ac-164d6979ecbb"
      ]
    }
  }
}
Request - Example2

Headers
{
    "Content-Type": "application/json",
    "Authorization": "Bearer ${TOKEN}"
}
Body
Copied!
Downloaded!
{
  "enabled": true,
  "name": "http_status_endpoint_4xx",
  "description": "Check the balancer for http 4xx errors",
  "documentation": "Steps for error solving, what to do when we're having alerts",
  "namespace": "balancer",
  "metricName": "http_status_endpoint_4xx",
  "dimensions": [
    {
      "name": "balancer_id",
      "value": "lb-12ab17e94f21"
    }
  ],
  "period": "1h",
  "consecutivePeriods": 2,
  "statistics": "count",
  "conditions": {
    "warning": {
      "threshold": 2000,
      "operator": "gt"
    },
    "error": {
      "threshold": 3000,
      "operator": "ge"
    },
    "critical": {
      "threshold": 5000,
      "operator": "gt"
    }
  },
  "actionsEnabled": true,
  "actions": {
    "unknownActionIds": [],
    "okActionIds": [
      "ac-1234abc5ab67"
    ],
    "warningActionIds": [
      "ac-1234abc5ab67"
    ],
    "errorActionIds": [
      "ac-1234abc5ab67"
    ],
    "criticalActionIds": [
      "ac-1234abc5ab67",
      "ac-629e55d24546",
      "ac-f2a00bbc36bc"
    ]
  }
}

Body Attributes


  • alert.enabled * String
    threshold or operator
  • alert.name * String
    a name of your choice
  • alert.description * String
    a description of your choice
  • alert.documentation * String
    document a verbose description
  • alert.namespace * String
    metric namespace
  • alert.metricName * String
    metric name
  • alert.dimensions * Array
    array of dimensions
  • alert.dimensions.name * String
    name
  • alert.dimensions.value * String
    filter value
  • alert.statistic * String
    Accepted values:
    ‘sum’
    ‘maximum’
    ‘minimum’
    ‘average’
    ‘count’
  • alert.consecutivePeriods * Integer
    consecutive checks before triggering the alert
  • alert.conditions Object
    Contains the conditions attributes
  • alert.conditions.critical Object
    Contains threshold and operator attributes
  • alert.conditions.critical.threshold Integer
    Alert threshold
  • alert.conditions.critical.operator String
    Allowed values:
    ‘gt’
    ‘lt’
    ‘eq’
    ‘ge’
    ‘le’
    ‘ne’
  • alert.conditions.error String
    Contains threshold and operator attributes
  • alert.conditions.warning String
    Contains threshold and operator attributes
  • alert.conditions.ok String
    Contains threshold and operator attributes
  • alert.conditions.unknown String
    Contains threshold and operator attributes
  • alert.actionsEnabled Boolean
  • alert.actions * Object
    Contains the actions attributes
  • alert.actions.unknownActionIds * Array
    array containing 0 or more actions for this severity level
  • alert.actions.okActionIds * Array
    array containing 0 or more actions for this severity level
  • alert.actions.warningActionId * Array
    array containing 0 or more actions for this severity level
  • alert.actions.errorActionId * Array
    array containing 0 or more actions for this severity level
  • alert.actions.criticalActionId Array
    array containing 0 or more actions for this severity level
Response - 200

Headers
{
  "Content-Type": "application/json"
}
Body
Copied!
Downloaded!
{
  "request": {
    "id": "c0e12178-6b0d-42f0-8a6e-701d8a55de5c",
    "url": "/spectrum/metrics/alert?accountId={AccountId}",
    "method": "POST",
    "timestamp": "2017-08-20T16:37:34.225Z"
  },
  "response": {
    "status": {
      "code": 200,
      "message": "OK"
    },
    "kind": "spotinst:lb:alert",
    "items": [
      {
        "id": "al-d185c7706b22",
        "status": "UNKNOWN",
        "enabled": true,
        "name": "Spotinst - High CPU load",
        "namespace": "spotinst/compute",
        "metricName": "cpu_load",
        "period": "1m",
        "consecutivePeriods": 1,
        "statistic": "sum",
        "conditions": {
          "error": null,
          "warning": null,
          "critical": {
            "threshold": 80,
            "operator": "gt"
          }
        },
        "dimensions": [
          {
            "name": "instance_id",
            "value": "i-123456"
          }
        ],
        "description": "One or more of the instances have high CPU utilization",
        "documentation": "",
        "actionsEnabled": true,
        "actions": {
          "okActionIds": [],
          "warningActionIds": [],
          "errorActionIds": [],
          "criticalActionIds": [
            "ac-664d6979ccbb"
          ],
          "unknownActionIds": []
        },
        "updatedAt": "2017-08-20T16:37:34.213Z",
        "createdAt": "2017-08-20T16:37:34.213Z"
      }
    ],
    "count": 1
  }
}