我有一个Sping Boot REST应用程序,它只是打印Hello world
。这工作正常,现在我正在尝试向我的应用程序添加可观察性,所以我安装了一个Kind Kuberntes集群并部署了开放遥测收集器。OpenTelemetry收集器在kind集群中运行,我的Spring Boot应用程序在我的主机上运行。当我的Spring Boot应用程序启动时,它打印以下错误消息:
[OkHttp http://otel-collector-collector.opentelemetry-operator-system.svc.cluster.local:5555/...]
ERROR io.opentelemetry.exporter.internal.grpc.OkHttpGrpcExporter -
Failed to export metrics. The request could not be executed.
Full error message: otel-collector-collector.opentelemetry-operator-
system.svc.cluster.local: nodename nor servname provided, or not known
我有一个Shell文件,它运行我的应用程序:
mvn clean package -Dmaven.test.skip=true
AGENT_FILE=opentelemetry-javaagent-all.jar
if [ ! -f "${AGENT_FILE}" ]; then
curl -L https://github.com/aws-observability/aws-otel-java-
instrumentation/releases/download/v1.19.2/aws-opentelemetry-agent.jar --output
${AGENT_FILE}
fi
export OTEL_TRACES_EXPORTER=otlp
export OTEL_METRICS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector-collector.opentelemetry-
operator-system.svc.cluster.local:5555
export OTEL_RESOURCE_ATTRIBUTES=service.name=hello-app,service.version=1.0
export OTEL_TRACES_SAMPLER=always_on
export OTEL_IMR_EXPORT_INTERVAL=1000
export OTEL_METRIC_EXPORT_INTERVAL=1000
java -javaagent:./${AGENT_FILE} -jar target/hello-app-1.0.jar
我通过操作员安装了OTel收集器:
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.10.0/cert-manager.yaml
kubectl apply -f https://github.com/open-telemetry/opentelemetry-operator/releases/latest/download/opentelemetry-operator.yaml
我的OpenTelemetry采集器配置文件为:
apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
name: otel-collector
namespace: opentelemetry-operator-system
labels:
app: opentelemetry
component: otel-collector
spec:
mode: deployment
config: |
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:5555
processors:
batch:
timeout: 1s
send_batch_size: 1024
exporters:
prometheus:
endpoint: 0.0.0.0:6666
otlp:
endpoint: http://tempo.monitoring:3100
tls:
insecure: true
service:
pipelines:
metrics:
receivers: [otlp]
processors: [batch]
exporters: [prometheus]
traces:
receivers: [otlp]
processors: [batch]
exporters: [otlp]
telemetry:
logs:
level: debug
1条答案
按热度按时间hiz5n14c1#
您的Sping Boot 正在您的主机上运行,而您的OpenTelemetry收集器正在Kubernetes集群中运行,因此错误消息告诉我们的是应用程序无法解析FQDN
otel-collector-collector.opentelemetry-operator-system.svc.cluster.local
。一种方法是将流量从服务转发到主机:
...然后将其用作
OTEL_EXPORTER_OTLP_ENDPOINT
的值: