Hitting Mesos direct - advantageous/lokate-mesos GitHub Wiki

We are going to use the Marathon API due to the volume of data we would have to download and parse to do discovery direct with Mesos.

Instead of querying Marathon, we could query Mesos direct.

To get the IP address of a framework task

$ curl master.mesos:5050/frameworks | jq .frameworks[].tasks[].statuses[].container_status.network_infos[].ip_address | more

...
"10.16.204.95"
"10.16.204.94"
"10.16.204.93"
"10.16.204.92"
"10.16.204.94"
"10.16.204.93"
"10.16.204.96"
"10.16.204.96"
"10.16.204.95"
"10.16.204.94"
"10.16.204.93"
"10.16.204.94"
"10.16.204.96"
"10.16.204.95"
"10.16.204.92"
"10.16.204.96"
"10.16.205.15"
"10.16.204.94"

You can get the ports from task resources for frameworks like cassandra

$ curl master.mesos:5050/frameworks | jq .frameworks[].tasks[].resources.ports   | more
...
"[1025-1026]"
"[1025-1026]"
"[1025-1026]"
"[7000-7001, 7199-7199, 9042-9042, 9160-9160]"
"[7000-7001, 7199-7199, 9042-9042, 9160-9160]"
"[7000-7001, 7199-7199, 9042-9042, 9160-9160]"
"[5601-5601]"
"[14929-14930]"
"[28099-28100]"
"[14125-14126]"
"[15729-15730]"
"[10103-10103, 10514-10514]"
"[12100-12103]"
"[10103-10103, 10514-10514]"
"[31105-31105]"
"[10103-10103, 10514-10514]"
"[5601-5601]"
"[9090-9091, 10000-10100]"
"[5601-5601]"
"[5358-5359]"
"[19771-19772]"
"[17112-17113]"
"[22511-22511]"
"[80-80, 443-443, 9090-9091, 10000-10100]"
"[9000-9000]"

You can get ports from frameworks/tasks/discovery which would work better for most tasks

$ curl master.mesos:5050/frameworks | jq .frameworks[].tasks[].discovery.ports.ports[].number  | more
1025
1026
1025
1026
1025
1026
5601
14929
14930
28099
28100
14125
14126
15729
15730
10514
10103
12100
12101
12102
12103
10514
10103
31105
10514
10103
5601
9090
9091

Downside is that this is a lot of data to process. (In our case about 5x the data we would need to process with Marathon). The upside it would work not just with marathon but all known mesos frameworks/tasks.

Another downside is we loose some of the metadata from marathon like port names.