标签:actor cat services 添加 nap OLE version one use
以下演示一个简单的使用jmxexporter 暴露nexus jmx 指标为prometheus metrics,同时也集成了一个简单的jmxtrans 输出数据到
graphite
version: "3"
services:
graphite:
image: graphiteapp/graphite-statsd
ports:
- "80:80"
- "2003-2004:2003-2004"
- "2023-2024:2023-2024"
- "8125:8125/udp"
- "8126:8126"
jmx-exporter:
image: dalongrong/jmx-expoter
build:
context: ./
dockerfile: Dockerfile-jmx
ports:
- "9999:9999"
jmxtrans:
image: dalongrong/jmxtrans
build:
context: ./
dockerfile: Dockerfile-jmxtrans
nexus:
image: sonatype/nexus3:3.17.0
container_name: nexus
ports:
- "8081:8081"
- "8099:8099"
- "8044:8044"
volumes:
- "./nexus-data:/nexus-data"
- "./nexus/nexus.vmoptions:/opt/sonatype/nexus/bin/nexus.vmoptions"
- "./nexus/org.apache.karaf.features.cfg:/opt/sonatype/nexus/etc/karaf/org.apache.karaf.features.cfg"
- "./nexus/org.apache.karaf.management.cfg:/opt/sonatype/nexus/etc/karaf/org.apache.karaf.management.cfg"
FROM openjdk:8u222-jdk
LABEL AUTHOR="dalongrong"
LABEL EMAIL="1141591465@qq.com"
WORKDIR /
COPY jmx_prometheus_httpserver-0.12.1-SNAPSHOT-jar-with-dependencies.jar /jmx_prometheus_httpserver-0.12.1-SNAPSHOT-jar-with-dependencies.jar
COPY docker-entrypiont-jmx-exporter.sh /docker-entrypiont.sh
COPY jmx-exporter.yaml /jmx-exporter.yaml
RUN chmod +x /docker-entrypiont.sh
EXPOSE 9999
ENTRYPOINT [ "/docker-entrypiont.sh" ]
docker-entrypiont-jmx-exporter.sh
#!/bin/sh
java -jar /jmx_prometheus_httpserver-0.12.1-SNAPSHOT-jar-with-dependencies.jar 0.0.0.0:9999 /jmx-exporter.yaml
FROM openjdk:8u222-jdk
LABEL AUTHOR="dalongrong"
LABEL EMAIL="1141591465@qq.com"
WORKDIR /
COPY jmxtrans-270-all.jar /jmxtrans-270-all.jar
COPY docker-entrypiont-jmx.sh /docker-entrypiont.sh
COPY jmxtrans.json /jmxtrans.json
RUN chmod +x /docker-entrypiont.sh
ENTRYPOINT [ "/docker-entrypiont.sh" ]
docker-entrypiont-jmx.sh
#!/bin/sh
java -jar /jmxtrans-270-all.jar -f /jmxtrans.json
jmxtrans.json 是一个简单的jmx query 配置,可以按照实际需要配置
{
"servers": [{
"port": "8044",
"host": "nexus",
"username" : "admin",
"password" : "dalong123",
"numQueryThreads" : 4,
"queries": [
{
"obj": "java.lang:type=Memory",
"resultAlias":"Memory",
"attr" : [ "HeapMemoryUsage", "NonHeapMemoryUsage" ],
"outputWriters": [{
"@class": "com.googlecode.jmxtrans.model.output.GraphiteWriterFactory",
"port": 2003,
"host": "graphite",
"rootPrefix":"webapi",
"typeNames" : ["name"],
"flushStrategy" :"always",
"poolSize" : 10
}]
}
,
{
"obj": "java.lang:type=ClassLoading",
"resultAlias":"ClassLoading",
"attr": ["TotalLoadedClassCount","LoadedClassCount","UnloadedClassCount"],
"outputWriters": [{
"@class": "com.googlecode.jmxtrans.model.output.GraphiteWriterFactory",
"port": 2003,
"rootPrefix":"webapi",
"typeNames" : ["name"],
"flushStrategy" :"always",
"poolSize" : 10,
"host": "graphite"
}]
}
]
}]
}
-XX:+UnlockDiagnosticVMOptions
-XX:+UnsyncloadClass
-XX:+LogVMOutput
-XX:LogFile=../sonatype-work/nexus3/log/jvm.log
-XX:-OmitStackTraceInFastThrow
-Djava.net.preferIPv4Stack=true
-Dkaraf.home=.
-Dkaraf.base=.
-Dkaraf.etc=etc/karaf
-Djava.util.logging.config.file=etc/karaf/java.util.logging.properties
-Dkaraf.data=../sonatype-work/nexus3
-Djava.io.tmpdir=../sonatype-work/nexus3/tmp
-Dkaraf.startLocalConsole=false
-Djava.rmi.server.hostname=nexus
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote=true
-Dcom.sun.management.jmxremote.port=8044
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.rmi.port=8044
-Dcom.sun.management.jmxremote.local.only=false
org.apache.karaf.features.cfg以及org.apache.karaf.management.cfg 配置参考官方介绍
git clone https://github.com/prometheus/jmx_exporter.git
cd jmx_exporter
mvn clean package
docker-compose build
docker-compose up -d
https://github.com/rongfengliang/jmx-exporter-jmxtrans-nexus-docker-compose
https://github.com/prometheus/jmx_exporter
https://github.com/jmxtrans/jmxtrans
https://support.sonatype.com/hc/en-us/articles/218501277-Configuring-Nexus-Repository-Manager-3-To-Allow-JMX-Connections
使用jmx-exporter&&jmxtrans && nexus jmx 暴露nexus 系统指标信息
标签:actor cat services 添加 nap OLE version one use
原文地址:https://www.cnblogs.com/rongfengliang/p/11225782.html