Accessing all instances

60 views
Skip to first unread message

Stephen Byers

unread,
Nov 24, 2014, 6:09:34 PM11/24/14
to vcap...@cloudfoundry.org
I hope this is the right place to ask this.  I would like to know if there is a way to ask the router for a list of all endpoints it is directing traffic to for a particular service name.  Specifically, if metrics are streaming from the individual nodes (like Hystrix dashboard metrics) I would like to know all of the nodes so something like Turbine could consolidate metrics into a single dashboard.  Any ideas how I could go about getting the list of the instances to achieve this?  I know it may be counter to many cloud concepts because the individual execution nodes matter in this case and I believe Turbine is being re-written to accommodate this in the future, but it is not fully there yet.

Thank you in advance for your help.

Etourneau Gwenn

unread,
Nov 24, 2014, 8:18:11 PM11/24/14
to vcap...@cloudfoundry.org
Ask to the CC ? !
listen to Nats  ? 

Or just use curl -vv http://statususer:statusp...@router.ip:8080/routes :)

James Bayer

unread,
Nov 25, 2014, 12:38:22 AM11/25/14
to vcap...@cloudfoundry.org
if it's simply a particular application you want to get instances for your org/space that you have access to, then you can make a call to the stats endpoint [1] which you can see on the apidocs site [2]. you can use the "cf curl" command for that. that only accounts for a particular app though and is only a point in time that may change. to be comprehensive you should list all of the apps for a particular route, and then all of the stats endpoints for each app together.

--
You received this message because you are subscribed to the Google Groups "Cloud Foundry Developers" group.
To view this discussion on the web visit https://groups.google.com/a/cloudfoundry.org/d/msgid/vcap-dev/2e91d775-413d-46be-86fb-25e1beb72aa3%40cloudfoundry.org.

To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+u...@cloudfoundry.org.



--
Thank you,

James Bayer

Stephen Byers

unread,
Nov 25, 2014, 10:18:43 AM11/25/14
to vcap...@cloudfoundry.org
I think #1 will work perfectly for this scenario.

Thank you!

Stephen B.

unread,
Jan 5, 2015, 5:35:29 PM1/5/15
to vcap...@cloudfoundry.org
I am trying to determine the series of API calls to retrieve the instance information.  It seems pretty straightforward except I cannot seem to figure the appropriate way to generate the authorization token.  I tried to turn on tracing for the CF CLI and mimic the behavior with curl just to make sure I understood it, but I have not yet been successful.  I am using the initial "admin" user and password and thought I could use that to generate a token from the UAA and then call the CC REST API to get the app information, but I'm struggling a bit.

James Bayer

unread,
Jan 6, 2015, 1:51:52 AM1/6/15
to vcap...@cloudfoundry.org
try following along with the interactions from the oauth-token command:
CF_TRACE=true cf oauth-token

On Mon, Jan 5, 2015 at 2:35 PM, Stephen B. <smb...@gmail.com> wrote:
I am trying to determine the series of API calls to retrieve the instance information.  It seems pretty straightforward except I cannot seem to figure the appropriate way to generate the authorization token.  I tried to turn on tracing for the CF CLI and mimic the behavior with curl just to make sure I understood it, but I have not yet been successful.  I am using the initial "admin" user and password and thought I could use that to generate a token from the UAA and then call the CC REST API to get the app information, but I'm struggling a bit.

--
You received this message because you are subscribed to the Google Groups "Cloud Foundry Developers" group.

To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+u...@cloudfoundry.org.

Daniel Mikusa

unread,
Jan 6, 2015, 8:12:37 AM1/6/15
to vcap...@cloudfoundry.org
Other options:

1.) Run `uaac` with the `-t` option.  It'll dump trace info similarly to what James suggested with `cf`.

2.) Check out the api docs here.  They walk through the different flows to get a token and show examples with uaac and curl.


Dan


Stephen B.

unread,
Jan 6, 2015, 1:36:13 PM1/6/15
to vcap...@cloudfoundry.org, dmi...@pivotal.io
I tried turning trace on and doing a "cf oauth-token", but it was always doing a token refresh because I was already logged in and the command will not work if logged out.  Alternatively, I used the "uaac" command line with trace turned on.  By observing what the uaac command did, I was able to retrieve a token by going directly to the uaa endpoint rather than the login endpoint (which is what cf cli does), using "grant_type=client_credentials", and using Basic Auth.  I took the token I received back and made a request to the CC to list all apps by sending a GET request to [API_endpoint]/v2/apps with the Authorization header set to "bearer ENCODED_TOKEN_STRING".  I always get an error code 1000, Invalid Auth Token.

Stephen B.

unread,
Jan 6, 2015, 2:50:07 PM1/6/15
to vcap...@cloudfoundry.org, dmi...@pivotal.io
A bit more information... I did validate that I am able to execute calls against the UAA with the token I received back as documented above.  I can query users (/Users), clients (/oauth/clients), etc., without any problems.  The fact that the token works when talking to the UAA makes me wonder if there is a permissions problem or if going directly to the UAA to get the token without going to the login endpoint caused some sort of problem.  I would have expected some error related to scope had it been a permissions problem, but I am quite new at this.

Stephen B.

unread,
Jan 6, 2015, 3:37:49 PM1/6/15
to vcap...@cloudfoundry.org, dmi...@pivotal.io
I'm going to answer my own question here in case someone else has this problem or if there is a better way to do it and someone wants to correct me.

The problem all along was with the permissions.  The way I resolved this was:
  1. Used the uaac client tool to add another client to the UAA.  The documentation does say clients must be registered, but I completely missed how that was done.  I executed the following command to create a client that can interact with the CC:  uaac client add cc_client --authorized_grant_types client_credentials --authorities cloud_controller.admin
  2. I made a POSTed a call to the UAA to get a token (/oauth/token) using payload "grant_type=client_credentials" and basic auth with cc_client as the username and the password I assigned upon client creation.
  3. I was then able to use the returned token to make a call to the CC api to retrieve all applications (api.[domain]/v2/apps) and, furthermore, to retrieve the individual stats (api.[domain]/v2/apps/[APP_GUID]/stats) as James had suggested above.
I'm not sure if there was a better way, but this seems to work.

Thanks for everyone's help,
Stephen
Reply all
Reply to author
Forward
0 new messages