0

I want to use Marathon's Rest API to get the hostname of a particular application.

curl -XGET http://IP:8080/v2/apps/app_name/tasks gives a list of details including hostname. However I want the output to be only the hostname. Does something exist for this?

208rishabh
  • 96
  • 11

1 Answers1

0

I am not intimately familiar with Marathon API, but I won't be surprised if the answer is no. Did you consider using a JSON processor for extracting the values you need? For instance, to get the list of all hosts the tasks are running on, one can do something like:

curl -XGET http://IP:8080/v2/apps/app_name/tasks | jq .tasks[].host

And if you are interested in a particular task, something like:

curl -XGET http://IP:8080/v2/apps/app_name/tasks | jq .tasks[0].host
hartem
  • 411
  • 2
  • 8
  • I am using Mesos-DNS for this. It is really cool. Solves my problem. The above solution is fine if the host on which the app is running doesnt change. However, in case it fails, Marathon might schedule it on a different host. – 208rishabh Oct 05 '15 at 05:40