Resource: honeycombio_trigger

Creates a trigger. For more information about triggers, check out Alert with Triggers.

Example Usage

Basic Example

variable "dataset" {
  type = string
}

data "honeycombio_query_specification" "example" {
  calculation {
    op     = "AVG"
    column = "duration_ms"
  }

  filter {
    column = "trace.parent_id"
    op     = "does-not-exist"
  }

  time_range = 1800
}

resource "honeycombio_query" "example" {
  dataset    = var.dataset
  query_json = data.honeycombio_query_specification.example.json
}

resource "honeycombio_trigger" "example" {
  name        = "Requests are slower than usual"
  description = "Average duration of all requests for the last 10 minutes."

  query_id = honeycombio_query.example.id
  dataset  = var.dataset

  frequency = 600 // in seconds, 10 minutes

  alert_type = "on_change" // on_change is default, on_true can refers to the "Alert on True" checkbox in the UI

  threshold {
    op    = ">"
    value = 1000
  }

  # zero or more recipients
  recipient {
    type   = "email"
    target = "hello@example.com"
  }

  recipient {
    type   = "marker"
    target = "Trigger - requests are slow"
  }
}

Example with PagerDuty Recipient and Severity

variable "dataset" {
  type = string
}

data "honeycombio_recipient" "pd-prod" {
  type = "pagerduty"

  detail_filter {
    name  = "integration_name"
    value = "Prod On-Call"
  }
}

data "honeycombio_query_specification" "example" {
  calculation {
    op     = "AVG"
    column = "duration_ms"
  }

  filter {
    column = "trace.parent_id"
    op     = "does-not-exist"
  }
}

resource "honeycombio_query" "example" {
  dataset    = var.dataset
  query_json = data.honeycombio_query_specification.example.json
}

resource "honeycombio_trigger" "example" {
  name        = "Requests are slower than usual"
  description = "Average duration of all requests for the last 10 minutes."

  query_id = honeycombio_query.example.id
  dataset  = var.dataset

  frequency = 600 // in seconds, 10 minutes

  threshold {
    op             = ">"
    value          = 1000
    exceeded_limit = 3
  }

  recipient {
    id = data.honeycombio_recipient.pd-prod.id

    notification_details {
      pagerduty_severity = "warning"
    }
  }

  evaluation_schedule {
    start_time = "13:00"
    end_time   = "21:00"

    days_of_week = [
      "monday",
      "wednesday",
      "friday"
    ]
  }
}

Argument Reference

The following arguments are supported:

Each trigger configuration must contain exactly one threshold block, which accepts the following arguments:

Each trigger configuration may provide an evaluation_schedule block, which accepts the following arguments:

Each trigger configuration may have zero or more recipient blocks, which each accept the following arguments. A trigger recipient block can either refer to an existing recipient (a recipient that is already present in another trigger) or a new recipient. When specifying an existing recipient, only id may be set. If you pass in a recipient without its ID and only include the type and target, Honeycomb will make a best effort to match to an existing recipient. To retrieve the ID of an existing recipient, refer to the honeycombio_recipient data source.

Type Target
email an email address
marker name of the marker
pagerduty _N/A_
slack name of the channel
webhook name of the webhook

Attribute Reference

In addition to all arguments above, the following attributes are exported:

Import

Triggers can be imported using a combination of the dataset name and their ID, e.g.

$ terraform import honeycombio_trigger.my_trigger my-dataset/AeZzSoWws9G

You can find the ID in the URL bar when visiting the trigger from the UI.