Datadog - Create Event

Octopus.Script exported 2014-07-08 by bobjwalker belongs to ‘Datadog’ category.

Datadog is cloud monitoring service which allows you to push arbitrary events into via an api. This task allows you to create an event to correlate with other data.

Parameters

When steps based on the template are included in a project’s deployment process, the parameters below can be set.

Datadog Api Key

ApiKey

The api key used to authenticate with Datadog.

Title

EventTitle

The title for the event to publish.

Body

EventBody

The text to provide more information about the event.

Alert Type

AlertType = info

The alert type out of the following options: “error”, “warning”, “info” or “success”.

Priority

Priority = normal

The priority out of the following: “normal” or “low”.

Tags

Tags

A comma separated list of tags to identify the event.

Datadog Endpoint

DatadogEndpoint = https://app.datadoghq.com

The endpoint for datadog, for most (if not all) instances this should just be “https://app.datadoghq.com

Script body

Steps based on this template will execute the following PowerShell script.

# Lets handle our own errors here
$ErrorActionPreference = "continue"

$apiKey = $OctopusParameters['ApiKey']
$title = $OctopusParameters['EventTitle']
$body = $OctopusParameters['EventBody']
$alertType = $OctopusParameters['AlertType']
$priority = $OctopusParameters['Priority']
$tags = $OctopusParameters['Tags']
$endpoint = $OctopusParameters['DatadogEndpoint']
$eventsApiEndpoint = "/api/v1/events"

# Write out some debug information
Write-Host "Event Title: $title"
Write-Host "Event Body: $body"
Write-Host "Alert Type: $alertType"
Write-Host "Priority: $priority"
Write-Host "Tags: $tags"
Write-Host "Datadog Endpoint: $endpoint$eventsApiEndpoint"

# Create the url from basic information
$url = "$endpoint$eventsApiEndpoint`?api_key=$apiKey"
$tagString = [system.String]::Join("`",`"", $tags.Split(","))

$json = @"
{
      "title": "$title",
      "text": "$body",
      "priority": "$priority",
      "tags": ["$tagString"],
      "alert_type": "$alertType"
  }
"@

# Make the response and handle exceptions **Requires PS 3.0 + 
try {
    $response = Invoke-WebRequest -Uri $url -Method POST -Body ($json | ConvertFrom-Json | ConvertTo-Json) -ContentType "Application/json" -UseBasicParsing
}catch{
    Write-Error "Error: $_"
    EXIT 0
}

# Some Error handling here
if($response.StatusCode -ne 202){
    Write-Error "There was an error listing response content below to debug"
    $response.RawContent
}else{
    Write-Host "Sent Successfully"
}

# We usually don't want to fail a deployment because of this
EXIT 0

Provided under the Apache License version 2.0.

Report an issue

To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.

{
  "Id": "40af3b8d-83b0-499e-99ed-e4b1093a7633",
  "Name": "Datadog - Create Event",
  "Description": "Datadog is cloud monitoring service which allows you to push arbitrary events into via an api.  This task allows you to create an event to correlate with other data.",
  "Version": 3,
  "ExportedAt": "2014-07-08T02:19:06.141+00:00",
  "ActionType": "Octopus.Script",
  "Author": "bobjwalker",
  "Parameters": [
    {
      "Name": "ApiKey",
      "Label": "Datadog Api Key",
      "HelpText": "The api key used to authenticate with Datadog.",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "EventTitle",
      "Label": "Title",
      "HelpText": "The title for the event to publish.",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "EventBody",
      "Label": "Body",
      "HelpText": "The text to provide more information about the event.",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "AlertType",
      "Label": "Alert Type",
      "HelpText": "The alert type out of the following options: \"error\", \"warning\", \"info\" or \"success\".",
      "DefaultValue": "info",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "Priority",
      "Label": "Priority",
      "HelpText": "The priority out of the following: \"normal\" or \"low\".",
      "DefaultValue": "normal",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "Tags",
      "Label": "Tags",
      "HelpText": "A comma separated list of tags to identify the event.",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "DatadogEndpoint",
      "Label": "Datadog Endpoint",
      "HelpText": "The endpoint for datadog, for most (if not all) instances this should just be \"https://app.datadoghq.com\"",
      "DefaultValue": "https://app.datadoghq.com",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    }
  ],
  "Properties": {
    "Octopus.Action.Script.ScriptBody": "# Lets handle our own errors here\n$ErrorActionPreference = \"continue\"\n\n$apiKey = $OctopusParameters['ApiKey']\n$title = $OctopusParameters['EventTitle']\n$body = $OctopusParameters['EventBody']\n$alertType = $OctopusParameters['AlertType']\n$priority = $OctopusParameters['Priority']\n$tags = $OctopusParameters['Tags']\n$endpoint = $OctopusParameters['DatadogEndpoint']\n$eventsApiEndpoint = \"/api/v1/events\"\n\n# Write out some debug information\nWrite-Host \"Event Title: $title\"\nWrite-Host \"Event Body: $body\"\nWrite-Host \"Alert Type: $alertType\"\nWrite-Host \"Priority: $priority\"\nWrite-Host \"Tags: $tags\"\nWrite-Host \"Datadog Endpoint: $endpoint$eventsApiEndpoint\"\n\n# Create the url from basic information\n$url = \"$endpoint$eventsApiEndpoint`?api_key=$apiKey\"\n$tagString = [system.String]::Join(\"`\",`\"\", $tags.Split(\",\"))\n\n$json = @\"\n{\n      \"title\": \"$title\",\n      \"text\": \"$body\",\n      \"priority\": \"$priority\",\n      \"tags\": [\"$tagString\"],\n      \"alert_type\": \"$alertType\"\n  }\n\"@\n\n# Make the response and handle exceptions **Requires PS 3.0 + \ntry {\n    $response = Invoke-WebRequest -Uri $url -Method POST -Body ($json | ConvertFrom-Json | ConvertTo-Json) -ContentType \"Application/json\" -UseBasicParsing\n}catch{\n    Write-Error \"Error: $_\"\n    EXIT 0\n}\n\n# Some Error handling here\nif($response.StatusCode -ne 202){\n    Write-Error \"There was an error listing response content below to debug\"\n    $response.RawContent\n}else{\n    Write-Host \"Sent Successfully\"\n}\n\n# We usually don't want to fail a deployment because of this\nEXIT 0",
    "Octopus.Action.Script.Syntax": "PowerShell"
  },
  "Category": "Datadog",
  "HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/datadog-create-event.json",
  "Website": "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