Sentinel Dashboard server not able to pull metrics from clients running in docker env

vecaoik1  于 2021-11-29  发布在  Java
关注(0)|答案(6)|浏览(280)

Issue Description

My docker containers are running in mesos cluster and they are sending metrics to dashboard using the docker container host. Sentinel dashboard server isn't able to pull metrics from clients

My query is :
I don't have a control where my docker containers will run in the mesos cluster.
How shall I set the value of this variable -Dcsp.sentinel.heartbeat.client.ip = xxx so that all my docker clients should be able to send metrics?

Describe what happened (or what feature you want)

Describe what you expected to happen

I expect sentinel dashboard server to collect metrics from all sentinel clients

How to reproduce it (as minimally and precisely as possible)

Tell us your environment

Anything else we need to know?

f5emj3cl

f5emj3cl1#

@sczyh30 Can you please help out here ? And help me understand how to figure out what value needs to be set for the variable csp.sentinel.heartbeat.client.ip??

42fyovps

42fyovps2#

if your sentinel dashboard can receive your client heartbeat, then the problem may be you sentinel dashboard send fetch command but you client cannot receive it, the network is unavailable,please check:

  • is your sentinel dashboard can access you client ip
  • if the client ip address is accessable then check if the client port is accessable , please check if you expose sentinel.transport.port in your dockerfile
fnvucqvd

fnvucqvd3#

Yes, that's exactly my point. How will the sentinel dashboard will collect metrics from client?

Client is registering to the dashboard with host and ip, that's only accessible within the host that docker container is running.
Marathon maps the port exposed by docker via different port? Eg port 8719 will be exposed by marathon with some random port available on the host
How can the client register to sentinel dashboard with the port which marathon will expose?

2nc8po8w

2nc8po8w4#

according to Requiring a specific host port you can setting "requirePorts": true in your app definition, but it is not recommended

mmvthczy

mmvthczy5#

I get what you are saying, but since we have multiple containers running in the same VM, not sure if the marathon will be able to start the container with the required port.

Do you have any other recommendations or any other suggestions which I can follow?

ff29svar

ff29svar6#

I finally worked it out using the environment variables which are set inside the docker env.
Docker env maps the outside port to variables like PORT_8719 and PORT_8080. I used the value of these variables to register the clients with sentinel dashboard

If this use case seems to be good enough for you, I can send one pull request for supporting docker containers

Below is the snapshot of the code, I have used in my heartbeat

String host =  System.getenv("HOST");
            String port =  System.getenv("PORT_8719");

            Field field = getClass().getSuperclass()
                    .getDeclaredField("heartBeat");
            field.setAccessible(true);
            HeartbeatMessage heartBeat = (HeartbeatMessage) field.get(this);
            heartBeat.registerInformation("hostname", host);
            heartBeat.registerInformation("port", port);

相关问题