Azkaban JMX监控 jmx exporter实用技能

Azkaban JMX监控

最近在排查Azkaban的问题,发现Azkaban自身做了JMX指标的,本文直接提供Docker版本的Azkaban JMXExporter教程。

这里在Github上找到了三个项目:
https://github.com/sinsengumi/azkaban-jmx-exporter
https://github.com/WillCup/jmx_exporter
https://github.com/runningdata/jmxexporters

通过这三个项目,可以做出一个Azkaban的JmxExporter的Docker版本。

构建镜像:

※这里 build-arg十分重要,如果服务器上是通过代理访问网络的,那么git代理是走HTTPS_PROXY,maven这里通过JVM参数的配置。

#!/bin/sh
docker build -t slankka/azkaban_exporter:v3 --rm=true \
 --build-arg HTTPS_PROXY=$https_proxy \
 --build-arg HTTP_PROXY=$http_proxy \
 --build-arg MAVEN_OPTS="-Dmaven.wagon.rto=3000 -Dhttps.proxyHost=<slankka-host> -Dhttps.proxyPort=<slankka-port> -Dhttp.proxyHost=<slankka-host> -Dhttp.proxyPort=<slankka-port>" \
 .

Entrypoint.sh

这里直接使用runningdata/jmxexporters提供的entrypoint,本文这里增加JVM_OPTS作为环境变量(重要)。

Tips

※也可直接从环境变量中获取这些参数。
※这里jmx_prometheus_httpserver.jar的参数定义,在https://github.com/WillCup/jmx_exporter。

#! /bin/bash
if [ $# != 4 ]; then
    echo "Usage entrypoint.sh <hostPort> <http_port> <srv_type> <instance_name>"
exit 0
fi

HOST_PORT=$1
HTTP_PORT=$2
SRV_TYPE=$3
INSTANCE_NAME=$4

METRIC_FILE=/${SRV_TYPE}.yml

echo "hostPort: ${HOST_PORT}" >> ${METRIC_FILE}
echo "instanceName: ${INSTANCE_NAME}" >> ${METRIC_FILE}
echo "http port is ${HTTP_PORT}, target host port is ${HOST_PORT}"
java ${JVM_OPTS} -jar /jmx_prometheus_httpserver.jar ${HTTP_PORT} ${METRIC_FILE}

部署

Azkaban的web和executor 均提供了JMX的端口,HOST_PORT就是Azakaban的IP加上JMX PORT。

posted @ 2021-12-22 11:17  一杯半盏  阅读(674)  评论(0编辑  收藏  举报