API - Can I see what a machine is doing at the moment?

Hi,

Through the REST API, I’d like to be able to see what a given machine is currently up to.
My wishlist is: Is it currently idle? Is it deploying? If it’s deploying, what is it deploying at the moment and what’s it’s ETA?

I’ve found something like this in the API:

http://my-octopus-server/api/machines/Machines-123

However it only gives me general information about it, what I want to know is what a given machine is up to, deployment wise, at the moment.

I’ve found that I can get to /deployments, take the top deployment, follow the link to /task, and that gives me status information including the box it’s deploying to. That’s good; but it’s too many operations for me to get, say, the top 20 deployments and follow each link just to see if one of them happens to be the box I’m interested in.

I’ll keep looking but if I can have a prod in the right direction that’d be awesome.

Hi,

Thank you for reaching out! Currently there’s no way to do this as we don’t keep a record of what machines are doing at any given time. I would love to know more about your scenario and how you would want to use this information.

This is an interesting idea, so feel free to create a UserVoice suggestion to see if there’s enough community interest to have this feature implemented in a future version!

Kind regards,

Kenny

Hi Kenny

So basically we deploy out to servers behind a load balancer. We refer to the boxes serving the requests as a “loop” though I’ve heard the term rotation used, but we basically

  • Take a box out the loop
  • Deploy to it
  • Run post-deploy tests on it
  • Put the box back in the loop

Yesterday I was writing a “loop monitor dashboard” which saves us having to log in to a cumbersome massive load balancer UI. Basically to show us at a quick glance per-application which servers are in/out of the loop.

That bit was easy but then I wanted to enhance it with a “why”. If Octopus Deploy has taken a box out the loop to deploy to it, that’s a different thing than someone having manually taken it out (maybe because there’s a problem or they’re doing some specific maintenance/testing on it).

So yeah - for my loop monitor dashboard, if a box is out, I wanted to display a “Currenty deploying to this box” section.

I did do it though! :slight_smile:

So what I did was to access the Deployments API with a filter of taskState=Executing

/api/deployments?taskState=Executing

I then followed the /Task URL for each deployment in progress appending /Details to it:

/api/tasks/ServerTasks-47406/details

In here it gives me the boxes it’s currently deploying to.

So I take that JSON and parse it out, finding only “Running” statuses and wrote all that out into my own custom API that gives me a JSON object like

{
“machineName”: “WEBSERVER123”,
“deployments”: [
{ “description”: “Deploying MY APP to TEST1” },
{ “timeStarted”: “2016-08-25T16:00:56” }
]
}

I then consume that in my dashboard and it’s all good. I can now show real-time deployments against each box out of the loop.

So it’s a bit intensive, having to make a request then following all the task links, but it works and the dashboard isn’t something that’s open all the time - just something we can load and look at when we need to.

Cheers
Ben

Hi Ben,

With 3.4 and the elastic environments and transient machines feature we are storing more about individual machines than before. I asked the guys who worked on it specifically if this would change your scenario and below is the information they provided (I have copy and pasted their response thus the context):

So we have some endpoints on the machine API that might be useful.

Connection: Get the status of the network connection between the Octopus server and a machine.
/api/machines/[machine-id]/connection

Tasks: Get the history of related tasks a machine <- this might be what he’s after?
/api/machines/[machine-id]/tasks

Something that’s possibly going to be more useful for him in the very near future is the changes to the events api (for the triggers/notifications we’re working on to help users get notified when events occur within Octopus) … where we’ll let you filter events by a certain category. Eg. You’ll be able to do something like: "Show me all machine-related events between these dates” and you’ll see all events related to machines, which may be useful for his dashboard

He can use the events api right now if he wants to query “per machine” using the “regarding” parameter

Eg.

return octopusRepository.Events.list({ regarding: $scope.machineId, skip: $scope.skip }).then(function (events) {
        $scope.events = events;
      });

This might give you something more useful or ideas :slight_smile:
Vanessa

Notice:

This issue has been closed due to inactivity. If you encounter the same or a similar issue and require help, please open a new discussion (if we asked for logs or extra details in this thread, consider including them in the new thread). If you are the creator of this thread and believe it should not be closed let us know via our support email.