Datadog Event API Documentation - v2.3.0
    Preparing search index...

    Function CreateEvent

    • Creates one or more events in Datadog using the Events API.

      This function sends the provided event requests to the Datadog API and returns the results. It requires the DATADOG_API_KEY and DATADOG_APP_KEY environment variables to be set.

      Parameters

      • params: CreateEventParams

        Parameters for creating events

        • OptionalaggregationKey?: string

          Optional aggregation key to group events together

        • requests: RequestEventParams[]

          Array of event requests to send to Datadog

      Returns Promise<CreateEventResult[]>

      Promise resolving to an array of results, one for each event request

      Error if DATADOG_API_KEY or DATADOG_APP_KEY environment variables are not set

      // Create multiple events
      const results = await CreateEvent({
      requests: [
      {
      title: "Deployment started",
      text: "Starting deployment of service XYZ to production",
      tags: ["environment:production", "service:xyz"],
      alertType: "info",
      priority: "normal"
      },
      {
      title: "High CPU Usage Alert",
      text: "CPU usage exceeded 90% for 5 minutes",
      tags: ["environment:production", "resource:cpu"],
      alertType: "warning",
      priority: "normal"
      }
      ],
      aggregationKey: "deployment-123"
      })

      // Access event URLs from the results
      results.forEach(result => {
      console.log(`Event created: ${result.eventUrl}`)
      })