You are browsing documentation for an outdated plugin version.
Basic configuration examples
A plugin which is not associated to any service, route, consumer, or consumer group is
considered global, and will be run on every request.
- In self-managed Kong Gateway Enterprise, the plugin applies to every entity in a given workspace.
- In self-managed Kong Gateway (OSS), the plugin applies to your entire environment.
- In Konnect, the plugin applies to every entity in a given control plane.
Read the
Plugin Reference and the Plugin Precedence
sections for more information.
The following examples provide some typical configurations for enabling
the OpenTelemetry
plugin globally.
Kong Admin API
Konnect API
Kubernetes
Declarative (YAML)
Konnect Terraform
Make the following request:
curl -X POST http://localhost:8001/plugins/ \
--header "accept: application/json" \
--header "Content-Type: application/json" \
--data '
{
"name": "opentelemetry",
"config": {
"endpoint": "http://opentelemetry.collector:4318/v1/traces",
"headers": {
"X-Auth-Token": "secret-token"
}
}
}
'
Make the following request, substituting your own access token, region, and control plane ID:
curl -X POST \
https://{us|eu}.api.konghq.com/v2/control-planes/{controlPlaneId}/core-entities/plugins/ \
--header "accept: application/json" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer TOKEN" \
--data '{"name":"opentelemetry","config":{"endpoint":"http://opentelemetry.collector:4318/v1/traces","headers":{"X-Auth-Token":"secret-token"}}}'
See the Konnect API reference to learn about region-specific URLs and personal access tokens.
Create a KongClusterPlugin
resource and label it as global:
apiVersion: configuration.konghq.com/v1
kind: KongClusterPlugin
metadata:
name: <global-opentelemetry>
annotations:
kubernetes.io/ingress.class: kong
labels:
global: "true"
config:
endpoint: http://opentelemetry.collector:4318/v1/traces
headers:
X-Auth-Token: secret-token
plugin: opentelemetry
Add a plugins
entry in the declarative
configuration file:
plugins:
- name: opentelemetry
config:
endpoint: http://opentelemetry.collector:4318/v1/traces
headers:
X-Auth-Token: secret-token
Prerequisite: Configure your Personal Access Token
terraform {
required_providers {
konnect = {
source = "kong/konnect"
}
}
}
provider "konnect" {
personal_access_token = "kpat_YOUR_TOKEN"
server_url = "https://us.api.konghq.com/"
}
Add the following to your Terraform configuration to create a Konnect Gateway Plugin:
resource "konnect_gateway_plugin_opentelemetry" "my_opentelemetry" {
enabled = true
config = {
endpoint = "http://opentelemetry.collector:4318/v1/traces"
headers = {
X-Auth-Token = "secret-token"
}
}
control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id
}