Events API v2 - POST an event

Ingests a custom event to Dynatrace.

The request consumes an application/json payload.

Important

The ingestion of custom events consumes Davis Data Units (DDUs) from the events pool.

Early Adopter

This request is an Early Adopter release and may be changed in non-compatible way.

POST
  • Managed https://{your-domain}/e/{your-environment-id}/api/v2/events/ingest
  • SaaS https://{your-environment-id}.live.dynatrace.com/api/v2/events/ingest
  • Environment ActiveGate https://{your-activegate-domain}/e/{your-environment-id}/api/v2/events/ingest

Authentication

To execute this request, you need the Ingest events (events.ingest) permission assigned to your API token. To learn how to obtain and use it, see Tokens and authentication.

Parameters

Parameter Type Description In Required
body EventIngest

The JSON body of the request. Contains properties of the new event.

body optional

Body format

The EventIngest object

The configuration of an event to be ingested.

Element Type Description Required
eventType string

The type of the event.

required
title string

The title of the event.

required
startTime integer

The start time of the event, in UTC milliseconds.

If not set, the current timestamp is used.

optional
endTime integer

The end time of the event, in UTC milliseconds.

If not set, the start time plus timeout is used.

optional
timeout integer

The timeout of the event, in minutes.

If not set, 15 is used.

optional
entitySelector string

The entity selector, defining a set of Dynatrace entities to be associated with the event.

Only entities that have been active within the last 24 hours can be selected.

If not set, the event is associated with the environment (dt.entity.environment) entity.

optional
properties object

A map of event properties.

Keys with prefix dt.* are reserved and may be used to set event properties with predefined semantics within the Dynatrace product. All other keys are interpreted as user-defined event properties.

Values of Dynatrace-reserved properties (identified by a key with prefix dt.*) must fulfill the requirements of the respective property.

optional

Response

Response codes

Code Description
201

Success. The event has been ingested.

Response body

A successful request doesn't return any content.

Examples

In this example, the request sends a Marked for termination event to hosts that are planned to be removed. Such hosts are identified by the cloud-burst-hosts host group. The event automatically applies to all hosts that are part of the group. The purpose for termination and automation job number are provided as additional information.

The API token is passed in the Authorization header.

Curl

curl --request POST \
  --url https://mySampleEnv.live.dynatrace.com/api/v2/events/ingest \
  --header 'Authorization: Api-Token dt0c01.abc123.abcdefjhij1234567890' \
  --data '{
    "eventType": "MARKED_FOR_TERMINATION",
    "title": "Planned host downscale",
    "entitySelector": "type(HOST),fromRelationship.isInstanceOf(type(HOST_GROUP),entityName(cloud-burst-hosts))",
    "properties": {
        "job.number": "21234346"
    }
}'

Request URL

https://mySampleEnv.live.dynatrace.com/api/v2/events/ingest

Request body

{
    "eventType": "MARKED_FOR_TERMINATION",
    "title": "Planned host downscale",
    "entitySelector": "type(HOST),fromRelationship.isInstanceOf(type(HOST_GROUP),entityName(cloud-burst-hosts))",
    "properties": {
        "job.number": "21234346"
    }
}

Response body

{
  "reportCount": 2,
  "eventIngestResults": [
    {
      "correlationId": "41f5d263011a6c9a",
      "status": "OK"
    },
    {
      "correlationId": "80eae4d163cc5760",
      "status": "OK"
    }
  ]
}

Response code

201