我的数据狗代理拒绝连接,该代理试图从其自己的 docker 容器中存在的内部应用程序收集 JMX(通过 RMI)指标。但是,jconsole 能够从存在于其自己的 docker 容器中的应用程序中收集指标。datadog-agent 存在于它自己的容器中。两个容器都存在于同一主机上的同一网络中。有任何想法吗?我查看了其他堆栈溢出问题。
- 已在自定义 jmx.yaml 文件 /etc/dd-agent/conf.d/jmx.yaml 中尝试了 IP 地址 0.0.0.0 和特定主机地址
Docker 容器 0:
* 运行输出 kafka 流指标的 my_streams_app
* 通过以下方式执行:
`docker run -d --name my_streams_app
-v /var/run/docker.sock:/var/run/docker.sock:ro
-v /proc/:/host/proc/:ro
-v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro
-e API_KEY=someapikeyhere
-e SD_JMX_ENABLE=yes -p 9998:9998 --network=my_streams_default quay.io/temp/my_streams`
- jconsole 能够获取发出的指标。
Docker 容器 1:
* 在容器内运行 datadog-agent * Datadog-agent 使用 JMX 默认 (RMI) 从上面容器 0 中存在的 my_streams_app 获取指标。
* 两个容器在同一主机(我的笔记本电脑 MAC OSX)内的同一网络上运行
* 能够从 docker 容器中的 datadog-agent 中的 netcat 到另一个容器中的 my_streams_app ip 和端口。使用 0.0.0.0 和 9998,还可以使用特定 IP 地址
* 命令从容器内运行 datadog 代理
docker run -v /var/run/docker.sock:/var/run/docker.sock:ro -v /proc/:/host/proc/:ro -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro -e LOG_LEVEL=DEBUG -e SD_BACKEND=docker --network=mystreams_default 4b1488e74733
用于通过 datadog jmx 从容器内收集指标的 jmx 配置:
实例:
- 主机:0.0.0.0 端口:9998 标签:newTag:my_streams jmx_url:“服务:jmx:rmi:///jndi/rmi://0.0.0.0:9998/jmxrmi” 名称:jmx_instance
docker_images: - my_streams_app
init_config: is_jmx: true conf: - include: domain: '"kafka.streams"' bean: '"kafka.streams":type="stream-metrics",client-id="my_test-1-StreamThread-1"'属性:commit-calls-rate:metric_type:gauge commit-time-avg:metric_type:gauge commit-time-max:metric_type:gauge poll-calls-rate:metric_type:gauge
JConsole:
* 从 docker 容器 0 中的 my_streams_app 收集指标,上面通过:
jconsole 0.0.0.0:9998
错误输出:
2017-07-05 20:48:20,236 | ERROR | App | Cannot connect to instance service:jmx:rmi:///jndi/rmi://0.0.0.0:9998/jmxrmi. java.io.IOException:
Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 0.0.0.0; nested exception is:
java.net.ConnectException: Connection refused (Connection refused)]
java.io.IOException: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 0.0.0.0; nested exception is:
java.net.ConnectException: Connection refused (Connection refused)]
at org.datadog.jmxfetch.Connection.connectWithTimeout(Connection.java:117)
at org.datadog.jmxfetch.Connection.createConnection(Connection.java:61)
at org.datadog.jmxfetch.RemoteConnection.<init>(RemoteConnection.java:56)
at org.datadog.jmxfetch.ConnectionFactory.createConnection(ConnectionFactory.java:29)
at org.datadog.jmxfetch.Instance.getConnection(Instance.java:162)
at org.datadog.jmxfetch.Instance.init(Instance.java:173)
at org.datadog.jmxfetch.App.init(App.java:511)
at org.datadog.jmxfetch.App.main(App.java:115)
Caused by: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 0.0.0.0; nested exception is:
java.net.ConnectException: Connection refused (Connection refused)]
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:370)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:268)
at org.datadog.jmxfetch.Connection$1.run(Connection.java:86)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:473)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 0.0.0.0; nested exception is:
java.net.ConnectException: Connection refused (Connection refused)]
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:142)
at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:204)
at javax.naming.InitialContext.lookup(InitialContext.java:415)
at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1928)
at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1895)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:287)
... 7 more
Caused by: java.rmi.ConnectException: Connection refused to host: 0.0.0.0; nested exception is:
java.net.ConnectException: Connection refused (Connection refused)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:341)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:138)
... 12 more
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:198)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:580)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.<init>(Socket.java:429)
at java.net.Socket.<init>(Socket.java:209)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:147)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
rmiregistry 已根据Failed to retrieve RMIServer stub启动