---
title: "Create a Opentelemetry plugin"
method: POST
path: "/{workspace}/plugins#Opentelemetry"
tags: ["Plugins"]
---

# Create a Opentelemetry plugin

`POST /{workspace}/plugins#Opentelemetry`

Create a Opentelemetry plugin

## Request body

- OpentelemetryPlugin — A Plugin entity represents a plugin configuration that will be executed during the HTTP request/response lifecycle. It is how you can add functionalities to Services that run behind Kong, like Authentication or Rate Limiting for example. You can find more information about how to install and what values each plugin takes by visiting the [Kong Hub](https://docs.konghq.com/hub/). When adding a Plugin Configuration to a Service, every request made by a client to that Service will run said Plugin. If a Plugin needs to be tuned to different values for some specific Consumers, you can do so by creating a separate plugin instance that specifies both the Service and the Consumer, through the `service` and `consumer` fields.
  - `condition` string, nullable — An expression used for conditional control over plugin execution. If the expression evaluates to `true` during the request flow, the plugin is executed; otherwise, it is skipped.
  - `created_at` integer, nullable — Unix epoch when the resource was created.
  - `enabled` boolean, nullable — Whether the plugin is applied.
  - `id` string, nullable — A string representing a UUID (universally unique identifier).
  - `instance_name` string, nullable — A unique string representing a UTF-8 encoded name.
  - `name` 'opentelemetry', required — The name of the Plugin that's going to be added. Currently, the Plugin must be installed in every Kong instance separately.
  - `ordering` object, nullable
    - `after` object
      - `access` string[]
    - `before` object
      - `access` string[]
  - `partials` object[] — A list of partials to be used by the plugin.
    - `id` string — A string representing a UUID (universally unique identifier).
    - `name` string — A unique string representing a UTF-8 encoded name.
    - `path` string
  - `tags` string[], nullable — An optional set of strings associated with the Plugin for grouping and filtering.
  - `updated_at` integer, nullable — Unix epoch when the resource was last updated.
  - `config` object
    - `access_logs` object — Configuration for exporting access logs to an OTLP/HTTP endpoint. If `endpoint` is set, Kong will export access logs (e.g. request/response, route/service, latency, etc.) to the specified endpoint.
      - `custom_attributes_by_lua` object — A key-value map that dynamically modifies access log fields using Lua code.
      - `endpoint` string — An HTTP URL endpoint where access logs (e.g. request/response, route/service, latency, etc.) are exported.
    - `batch_flush_delay` integer — The delay, in seconds, between two consecutive batches.
    - `batch_span_count` integer — The number of spans to be sent in a single batch.
    - `connect_timeout` integer — An integer representing a timeout in milliseconds. Must be between 0 and 2^31-2.
    - `header_type` 'aws' | 'b3' | 'b3-single' | 'datadog' | 'gcp' | 'ignore' | 'instana' | 'jaeger' | 'ot' | 'preserve' | 'w3c'
    - `headers` object — The custom headers to be added in the HTTP request sent to the OTLP server. This setting is useful for adding the authentication headers (token) for the APM backend.
    - `http_response_header_for_traceid` string
    - `logs_endpoint` string — An HTTP URL endpoint where internal logs are exported.
    - `metrics` object — Configuration for exporting metrics to an OTLP/HTTP endpoint. If `endpoint` is set, Kong will export metrics to the specified endpoint at the interval defined by `push_interval`.
      - `enable_ai_metrics` boolean — A boolean value that determines if AI metrics should be collected. If enabled, `gen_ai.*`, `mcp.*`, `kong.gen_ai.*`, `kong.gen_ai.a2a.*` and `kong.mcp.*` metrics will be exported. To enable latency metrics for AI metrics, `enable_latency_metrics` must also be set to `true`. To enable `error.type` attribute for AI metrics, `enable_request_metrics` must also be set to `true`.
      - `enable_bandwidth_metrics` boolean — A boolean value that determines if bandwidth metrics should be collected. If enabled, `http.server.request.size` and `http.server.response.size` metrics will be exported.
      - `enable_consumer_attribute` boolean — A boolean value that determines if `http.server.request.count`, `http.server.request.size` and `http.server.response.size` metrics should fill in the consumer attribute when available.
      - `enable_latency_metrics` boolean — A boolean value that determines if latency metrics should be collected. If enabled, `kong.latency.total`, `kong.latency.internal` and `kong.latency.upstream` metrics will be exported.
      - `enable_request_metrics` boolean — A boolean value that determines if request count metrics should be collected. If enabled, `http.server.request.count` metrics will be exported.
      - `enable_upstream_health_metrics` boolean — A boolean value that determines if upstream health metrics should be collected. If enabled, `kong.upstream.target.status` metrics will be exported.
      - `endpoint` string — An HTTP URL endpoint where metrics are exported.
      - `push_interval` number — The interval in seconds at which metrics are pushed to the OTLP server. This setting is only applicable when `endpoint` is set.
    - `propagation` object
      - `clear` string[] — Header names to clear after context extraction. This allows to extract the context from a certain header and then remove it from the request, useful when extraction and injection are performed on different header formats and the original header should not be sent to the upstream. If left empty, no headers are cleared.
      - `default_format` 'aws' | 'b3' | 'b3-single' | 'datadog' | 'gcp' | 'instana' | 'jaeger' | 'ot' | 'w3c' — The default header format to use when extractors did not match any format in the incoming headers and `inject` is configured with the value: `preserve`. This can happen when no tracing header was found in the request, or the incoming tracing header formats were not included in `extract`.
      - `extract` string[] — Header formats used to extract tracing context from incoming requests. If multiple values are specified, the first one found will be used for extraction. If left empty, Kong will not extract any tracing context information from incoming requests and generate a trace with no parent and a new trace ID.
      - `inject` string[] — Header formats used to inject tracing context. The value `preserve` will use the same header format as the incoming request. If multiple values are specified, all of them will be used during injection. If left empty, Kong will not inject any tracing context information in outgoing requests.
    - `queue` object
      - `concurrency_limit` -1 | 1 — The number of of queue delivery timers. -1 indicates unlimited.
      - `initial_retry_delay` number — Time in seconds before the initial retry is made for a failing batch.
      - `max_batch_size` integer — Maximum number of entries that can be processed at a time.
      - `max_bytes` integer — Maximum number of bytes that can be waiting on a queue, requires string content.
      - `max_coalescing_delay` number — Maximum number of (fractional) seconds to elapse after the first entry was queued before the queue starts calling the handler.
      - `max_entries` integer — Maximum number of entries that can be waiting on the queue.
      - `max_retry_delay` number — Maximum time in seconds between retries, caps exponential backoff.
      - `max_retry_time` number — Time in seconds before the queue gives up calling a failed handler for a batch.
    - `read_timeout` integer — An integer representing a timeout in milliseconds. Must be between 0 and 2^31-2.
    - `resource_attributes` object — A key-value map of resource attributes to be sent with the telemetry data. The keys and values can be either static or dynamic using Kong variables (e.g. `${kong.service.name}`) for the values. For dynamic values, Lua string template syntax is used and the values will be rendered at runtime.
    - `sampling_rate` number — Tracing sampling rate for configuring the probability-based sampler. When set, this value supersedes the global `tracing_sampling_rate` setting from kong.conf.
    - `sampling_strategy` 'parent_drop_probability_fallback' | 'parent_probability_fallback' — The sampling strategy to use for OTLP `traces`. Set `parent_drop_probability_fallback` if you want parent-based sampling when the parent span contains a `false` sampled flag, and fallback to probability-based sampling otherwise. Set `parent_probability_fallback` if you want parent-based sampling when the parent span contains a valid sampled flag (`true` or `false`), and fallback to probability-based sampling otherwise.
    - `send_timeout` integer — An integer representing a timeout in milliseconds. Must be between 0 and 2^31-2.
    - `traces_endpoint` string — A string representing a URL, such as https://example.com/path/to/resource?q=search.
  - `consumer` object — If set, the plugin will activate only for requests where the specified has been authenticated. (Note that some plugins can not be restricted to consumers this way.). Leave unset for the plugin to activate regardless of the authenticated Consumer.
    - `id` string
  - `protocols` string[] — A set of strings representing protocols.
  - `route` object — If set, the plugin will only activate when receiving requests via the specified route. Leave unset for the plugin to activate regardless of the route being used.
    - `id` string
  - `service` object — If set, the plugin will only activate when receiving requests via one of the routes belonging to the specified Service. Leave unset for the plugin to activate regardless of the Service being matched.
    - `id` string

## Response `201`

Created Opentelemetry plugin

- OpentelemetryPlugin — A Plugin entity represents a plugin configuration that will be executed during the HTTP request/response lifecycle. It is how you can add functionalities to Services that run behind Kong, like Authentication or Rate Limiting for example. You can find more information about how to install and what values each plugin takes by visiting the [Kong Hub](https://docs.konghq.com/hub/). When adding a Plugin Configuration to a Service, every request made by a client to that Service will run said Plugin. If a Plugin needs to be tuned to different values for some specific Consumers, you can do so by creating a separate plugin instance that specifies both the Service and the Consumer, through the `service` and `consumer` fields.
  - `condition` string, nullable — An expression used for conditional control over plugin execution. If the expression evaluates to `true` during the request flow, the plugin is executed; otherwise, it is skipped.
  - `created_at` integer, nullable — Unix epoch when the resource was created.
  - `enabled` boolean, nullable — Whether the plugin is applied.
  - `id` string, nullable — A string representing a UUID (universally unique identifier).
  - `instance_name` string, nullable — A unique string representing a UTF-8 encoded name.
  - `name` 'opentelemetry', required — The name of the Plugin that's going to be added. Currently, the Plugin must be installed in every Kong instance separately.
  - `ordering` object, nullable
    - `after` object
      - `access` string[]
    - `before` object
      - `access` string[]
  - `partials` object[] — A list of partials to be used by the plugin.
    - `id` string — A string representing a UUID (universally unique identifier).
    - `name` string — A unique string representing a UTF-8 encoded name.
    - `path` string
  - `tags` string[], nullable — An optional set of strings associated with the Plugin for grouping and filtering.
  - `updated_at` integer, nullable — Unix epoch when the resource was last updated.
  - `config` object
    - `access_logs` object — Configuration for exporting access logs to an OTLP/HTTP endpoint. If `endpoint` is set, Kong will export access logs (e.g. request/response, route/service, latency, etc.) to the specified endpoint.
      - `custom_attributes_by_lua` object — A key-value map that dynamically modifies access log fields using Lua code.
      - `endpoint` string — An HTTP URL endpoint where access logs (e.g. request/response, route/service, latency, etc.) are exported.
    - `batch_flush_delay` integer — The delay, in seconds, between two consecutive batches.
    - `batch_span_count` integer — The number of spans to be sent in a single batch.
    - `connect_timeout` integer — An integer representing a timeout in milliseconds. Must be between 0 and 2^31-2.
    - `header_type` 'aws' | 'b3' | 'b3-single' | 'datadog' | 'gcp' | 'ignore' | 'instana' | 'jaeger' | 'ot' | 'preserve' | 'w3c'
    - `headers` object — The custom headers to be added in the HTTP request sent to the OTLP server. This setting is useful for adding the authentication headers (token) for the APM backend.
    - `http_response_header_for_traceid` string
    - `logs_endpoint` string — An HTTP URL endpoint where internal logs are exported.
    - `metrics` object — Configuration for exporting metrics to an OTLP/HTTP endpoint. If `endpoint` is set, Kong will export metrics to the specified endpoint at the interval defined by `push_interval`.
      - `enable_ai_metrics` boolean — A boolean value that determines if AI metrics should be collected. If enabled, `gen_ai.*`, `mcp.*`, `kong.gen_ai.*`, `kong.gen_ai.a2a.*` and `kong.mcp.*` metrics will be exported. To enable latency metrics for AI metrics, `enable_latency_metrics` must also be set to `true`. To enable `error.type` attribute for AI metrics, `enable_request_metrics` must also be set to `true`.
      - `enable_bandwidth_metrics` boolean — A boolean value that determines if bandwidth metrics should be collected. If enabled, `http.server.request.size` and `http.server.response.size` metrics will be exported.
      - `enable_consumer_attribute` boolean — A boolean value that determines if `http.server.request.count`, `http.server.request.size` and `http.server.response.size` metrics should fill in the consumer attribute when available.
      - `enable_latency_metrics` boolean — A boolean value that determines if latency metrics should be collected. If enabled, `kong.latency.total`, `kong.latency.internal` and `kong.latency.upstream` metrics will be exported.
      - `enable_request_metrics` boolean — A boolean value that determines if request count metrics should be collected. If enabled, `http.server.request.count` metrics will be exported.
      - `enable_upstream_health_metrics` boolean — A boolean value that determines if upstream health metrics should be collected. If enabled, `kong.upstream.target.status` metrics will be exported.
      - `endpoint` string — An HTTP URL endpoint where metrics are exported.
      - `push_interval` number — The interval in seconds at which metrics are pushed to the OTLP server. This setting is only applicable when `endpoint` is set.
    - `propagation` object
      - `clear` string[] — Header names to clear after context extraction. This allows to extract the context from a certain header and then remove it from the request, useful when extraction and injection are performed on different header formats and the original header should not be sent to the upstream. If left empty, no headers are cleared.
      - `default_format` 'aws' | 'b3' | 'b3-single' | 'datadog' | 'gcp' | 'instana' | 'jaeger' | 'ot' | 'w3c' — The default header format to use when extractors did not match any format in the incoming headers and `inject` is configured with the value: `preserve`. This can happen when no tracing header was found in the request, or the incoming tracing header formats were not included in `extract`.
      - `extract` string[] — Header formats used to extract tracing context from incoming requests. If multiple values are specified, the first one found will be used for extraction. If left empty, Kong will not extract any tracing context information from incoming requests and generate a trace with no parent and a new trace ID.
      - `inject` string[] — Header formats used to inject tracing context. The value `preserve` will use the same header format as the incoming request. If multiple values are specified, all of them will be used during injection. If left empty, Kong will not inject any tracing context information in outgoing requests.
    - `queue` object
      - `concurrency_limit` -1 | 1 — The number of of queue delivery timers. -1 indicates unlimited.
      - `initial_retry_delay` number — Time in seconds before the initial retry is made for a failing batch.
      - `max_batch_size` integer — Maximum number of entries that can be processed at a time.
      - `max_bytes` integer — Maximum number of bytes that can be waiting on a queue, requires string content.
      - `max_coalescing_delay` number — Maximum number of (fractional) seconds to elapse after the first entry was queued before the queue starts calling the handler.
      - `max_entries` integer — Maximum number of entries that can be waiting on the queue.
      - `max_retry_delay` number — Maximum time in seconds between retries, caps exponential backoff.
      - `max_retry_time` number — Time in seconds before the queue gives up calling a failed handler for a batch.
    - `read_timeout` integer — An integer representing a timeout in milliseconds. Must be between 0 and 2^31-2.
    - `resource_attributes` object — A key-value map of resource attributes to be sent with the telemetry data. The keys and values can be either static or dynamic using Kong variables (e.g. `${kong.service.name}`) for the values. For dynamic values, Lua string template syntax is used and the values will be rendered at runtime.
    - `sampling_rate` number — Tracing sampling rate for configuring the probability-based sampler. When set, this value supersedes the global `tracing_sampling_rate` setting from kong.conf.
    - `sampling_strategy` 'parent_drop_probability_fallback' | 'parent_probability_fallback' — The sampling strategy to use for OTLP `traces`. Set `parent_drop_probability_fallback` if you want parent-based sampling when the parent span contains a `false` sampled flag, and fallback to probability-based sampling otherwise. Set `parent_probability_fallback` if you want parent-based sampling when the parent span contains a valid sampled flag (`true` or `false`), and fallback to probability-based sampling otherwise.
    - `send_timeout` integer — An integer representing a timeout in milliseconds. Must be between 0 and 2^31-2.
    - `traces_endpoint` string — A string representing a URL, such as https://example.com/path/to/resource?q=search.
  - `consumer` object — If set, the plugin will activate only for requests where the specified has been authenticated. (Note that some plugins can not be restricted to consumers this way.). Leave unset for the plugin to activate regardless of the authenticated Consumer.
    - `id` string
  - `protocols` string[] — A set of strings representing protocols.
  - `route` object — If set, the plugin will only activate when receiving requests via the specified route. Leave unset for the plugin to activate regardless of the route being used.
    - `id` string
  - `service` object — If set, the plugin will only activate when receiving requests via one of the routes belonging to the specified Service. Leave unset for the plugin to activate regardless of the Service being matched.
    - `id` string

## Other responses

- `401` — Unauthorized

---

[API](https://skmtc.net/kong/apis/kong-enterprise-admin-api.md) · [All operations](https://skmtc.net/kong/apis/kong-enterprise-admin-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/kong/kong-enterprise-admin-api/revisions/28b1f8a59cdc/schema)
