Managed inputs APM intake event API

Warning

This API is exclusively for APM agent developers. The vast majority of users should have no reason to interact with this API.

Managed inputs expose endpoints for:

Managed inputs expose an API endpoint to query general server information. This lightweight endpoint is useful as a server up/down health check.

Send an HTTP GET request to the server information endpoint:

https://{hostname}:{port}/
		

This endpoint always returns an HTTP 200.

Requests to this endpoint must be authenticated.

Example managed inputs information request:

curl -X GET http://127.0.0.1:8200/ \
  -H "Authorization: ApiKey api_key"

{
  "version": "8.9.0"
}
		
Note

Most users do not need to interact directly with the events intake API.

The events intake API is what we call the internal protocol that APM agents use to talk to managed inputs. Agents communicate with the Server by sending events — captured pieces of information — in an HTTP request. Events can be:

  • Transactions
  • Spans
  • Errors
  • Metrics

Each event is sent as its own line in the HTTP request body. This is known as newline delimited JSON (NDJSON).

With NDJSON, agents can open an HTTP POST request and use chunked encoding to stream events to managed inputs as soon as they are recorded in the agent. This makes it simple for agents to serialize each event to a stream of newline delimited JSON. Managed inputs also treat the HTTP body as a compressed stream and thus reads and handles each event independently.

Refer to Learn about data types to learn more about the different types of events.

Managed inputs expose the following endpoints for Elastic APM agent data intake:

Name Endpoint
APM agent event intake /intake/v2/events

Send an HTTP POST request to the intake/v2/events endpoint:

https://{hostname}:{port}/intake/v2/events
		

Managed inputs always process batches asynchronously. On success, the server will respond with a 202 Accepted status code and no body.

Keep in mind that events can succeed and fail independently of each other. Only if all events succeed does the server respond with a 202.

Errors are returned as a flat list of messages alongside the number of accepted events. The HTTP status code reflects the error (for example, 400 for a validation or decoding error).

An example error response might look something like this:

{
  "accepted": 0,
  "errors": [
    "validation error: 'metadata' required"
  ]
}
		

If you’re developing an agent, these errors can be useful for debugging.

Managed inputs use a collection of JSON Schemas for validating requests to the intake API.

Every new connection to managed inputs starts with a metadata stanza. This provides general metadata concerning the other objects in the stream.

Rather than send this metadata information from the agent multiple times, managed inputs hang on to this information and apply it to other objects in the stream as necessary.

Tip

Metadata is stored under context when viewing documents in Elasticsearch.

Managed inputs use JSON Schema to validate requests. The specification for metadata is defined on GitHub and included below.

APM agents automatically read Kubernetes data and send it to managed inputs. In most instances, agents are able to read this data from inside the container. If this is not the case, or if you wish to override this data, you can set environment variables for the agents to read. These environment variable are set via the Kubernetes Downward API. Here’s how you would add the environment variables to your Kubernetes pod spec:

- name: KUBERNETES_NODE_NAME
   valueFrom:
     fieldRef:
       fieldPath: spec.nodeName
 - name: KUBERNETES_POD_NAME
   valueFrom:
     fieldRef:
       fieldPath: metadata.name
 - name: KUBERNETES_NAMESPACE
   valueFrom:
     fieldRef:
       fieldPath: metadata.namespace
 - name: KUBERNETES_POD_UID
   valueFrom:
     fieldRef:
       fieldPath: metadata.uid
		

The table below maps these environment variables to the APM metadata event field:

Environment variable Metadata field name
KUBERNETES_NODE_NAME system.kubernetes.node.name
KUBERNETES_POD_NAME system.kubernetes.pod.name
KUBERNETES_NAMESPACE system.kubernetes.namespace
KUBERNETES_POD_UID system.kubernetes.pod.uid

Transactions are events corresponding to an incoming request or similar task occurring in a monitored service.

Managed inputs use JSON Schema to validate requests. The specification for transactions is defined on GitHub and included below.

Spans are events captured by an agent occurring in a monitored service.

Managed inputs use JSON Schema to validate requests. The specification for spans is defined on GitHub and included below.

An error or a logged error message captured by an agent occurring in a monitored service.

Managed inputs use a JSON Schema to validate requests. The specification for errors is defined on GitHub and included below.

Metrics contain application metric data captured by an APM agent.

Managed inputs use JSON Schema to validate requests. The specification for metrics is defined on GitHub and included below.

Elastic supports receiving traces, metrics, and logs over the OpenTelemetry Protocol (OTLP). OTLP is the default transfer protocol for OpenTelemetry and is supported natively by managed inputs.

Managed inputs support two OTLP communication protocols on the same port:

  • OTLP/HTTP (protobuf)
  • OTLP/gRPC
Name Endpoint
OTLP metrics intake /opentelemetry.proto.collector.metrics.v1.MetricsService/Export
OTLP trace intake /opentelemetry.proto.collector.trace.v1.TraceService/Export
OTLP logs intake /opentelemetry.proto.collector.logs.v1.LogsService/Export
Name Endpoint
OTLP metrics intake /v1/metrics
OTLP trace intake /v1/traces
OTLP logs intake /v1/logs
Tip

See our OpenTelemetry docs to learn how to send data to managed inputs from an OpenTelemetry agent OpenTelemetry collector.