如何启动JMX接收器?

问题描述 投票:0回答:1

我是新来的,我想启动一个jmx接收器到otel,但是通过docker启动时出现问题。

  • opentelemetry-jmx-metrics.jar 版本:1.33.0 从 github 发布页面下载
  • otel/opentelemetry-collector-contrib 版本:0.95.0
  • docker命令:

docker run -v $(pwd)/otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml -v $(pwd)/opentelemetry-jmx-metrics.jar:/usr/local/opentelemetry-jmx-metrics.jar otel/opentelemetry-collector-contrib:latest

  • otel-collector-config.yaml:
receivers:
  jmx:
    jar_path: /usr/local/opentelemetry-jmx-metrics.jar
    endpoint: 192.168.x.x:1616
    target_system: jvm
    collection_interval: 10s
    username: admin
    password: xxxxx
    resource_attributes:
      host_name: jmx-activemq

processors:
  batch:
 
exporters:
  otlp:
    endpoint: 192.168.x.x:11800
    tls:
      insecure: true
service:
  pipelines:
    metrics:
      receivers:
      - jmx
      processors:
      - batch
      exporters:
      - otlp

  • 错误信息:
cs.jar otel/opentelemetry-collector-contrib:latest
Error: invalid configuration: receivers::jmx: invalid `jar_path`: jar hash does not match known versions
2024/03/04 09:01:35 collector server run finished with error: invalid configuration: receivers::jmx: invalid `jar_path`: jar hash does not match known versions

我不知道我这是怎么了?有什么帮助吗?

正确启动。

jmx open-telemetry-collector
1个回答
0
投票

opentelemetry-jmx-metrics.jar
的版本与你的
otelcol-contrib
版本相当绑定,如果你有比docker镜像更新的JAR,你会遇到这个失败(镜像是在JAR存在之前构建的,所以有没有其哈希值的概念)。

我的解决方案(事实证明有点痛苦)是创建一个自定义 Docker 映像,在其中直接控制两个版本。

FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y \
    openjdk-11-jre-headless \
    wget \
    ca-certificates

# Download the correct JMX metrics jar
RUN wget https://github.com/open-telemetry/opentelemetry-java-contrib/releases/download/v1.32.0/opentelemetry-jmx-metrics.jar \
    -O /opt/opentelemetry-java-contrib-jmx-metrics.jar

# Download and extract the OpenTelemetry Collector
RUN wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.109.0/otelcol-contrib_0.109.0_linux_amd64.tar.gz \
    && tar -xvzf otelcol-contrib_0.109.0_linux_amd64.tar.gz \
    && mv otelcol-contrib /usr/local/bin/otelcontribcol

# Set JAVA_HOME environment variable
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk

# Copy configuration file into the container
COPY ./local/path/to/config.yaml /etc/otelcol-contrib/config.yaml

EXPOSE 4318

CMD ["/usr/local/bin/otelcontribcol", "--config", "/etc/otelcol-contrib/config.yaml"]
© www.soinside.com 2019 - 2024. All rights reserved.