Provide API to get node statistics, including node count by status

Bug #1584926 reported by Christian Reis on 2016-05-23
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Wishlist
Unassigned

Bug Description

It would be very convenient for MAAS to return some basic statistics on the nodes registered, including in order of priority:

  * Total number of nodes registered
  * Number of nodes per user
  * Number of nodes per status
  * Number of nodes per zone

Related branches

Changed in maas:
status: New → Triaged
importance: Undecided → Medium
assignee: nobody → Mike Pontillo (mpontillo)
status: Triaged → In Progress
milestone: none → 2.0.0
Mike Pontillo (mpontillo) wrote :

The first and most obvious thing to do, I think, is to add a generic "count" endpoint to just about any object:

ubuntu@maas:~$ maas admin rack-controllers count | jq
1
ubuntu@maas:~$ maas admin region-controllers count | jq
1
ubuntu@maas:~$ maas admin devices count | jq
0
ubuntu@maas:~$ maas admin machines count | jq
8
ubuntu@maas:~$ maas admin nodes count | jq
9

The above could be generically useful across the entire API.

The second thing is the more specific thing that you asked for. We could start with something like the following:

ubuntu@maas:~$ maas admin nodes statistics
Success.
Machine-readable output follows:
{
    "machine_count": 8,
    "node_count": 9,
    "rack_count": 1,
    "region_count": 1,
    "device_count": 0
}

And with that, I think the easy part is done. The last three things you asked for shouldn't be hard either, it's just a question of how to format them nicely.

Also, to keep scope down, I think these should all be admin-only for now.

Mike Pontillo (mpontillo) wrote :

What do you think of this?

$ maas admin machines summary | jq
{
  "machines_per_zone": {
    "default": [
      "4y3h7t",
      "4y3h7r",
      "4y3h7p",
      "4y3h88",
      "4y3h7q",
      "4y3h7s",
      "4y3h87",
      "4y3h7w"
    ]
  },
  "machines_per_status": {
    "Allocated": [],
    "Retired": [],
    "Reserved": [],
    "Releasing failed": [],
    "Failed disk erasing": [],
    "Failed deployment": [],
    "Commissioning": [],
    "Ready": [
      "4y3h7p",
      "4y3h88",
      "4y3h87"
    ],
    "Deployed": [
      "4y3h7s"
    ],
    "Broken": [],
    "Releasing": [],
    "Deploying": [],
    "New": [
      "4y3h7t",
      "4y3h7r",
      "4y3h7q",
      "4y3h7w"
    ],
    "Failed commissioning": [],
    "Disk erasing": [],
    "Missing": []
  },
  "machines_per_user": {
    "maas-init-node": [],
    "MAAS": [],
    "admin": [
      "4y3h7s"
    ]
  }
}

I was just going to do counts at first, but I figured if we're going to execute the query anyway, why not provide the data? Someone is going to have to parse the JSON anyway. It might as well be more useful. (they can check the length of the arrays if they just want a count, right?)

I think "summary" is a better name than "statistics". Statistics, to me, implies that we're doing some kind of smart calculations on the data. ;-) What do you think? (I had the same concern with the now-shipped "subnet statistics" operation, which was in fact statistics to begin with, but has expanded to more of a "summary".) Maybe "metadata"?

Mike Pontillo (mpontillo) wrote :

To be clear, this "fix" (miniture feature in disguise?) would potentially introduce a few new operations:

 - <nodes|machines|devices|rack-controllers|region-controllers> count
   * could really apply to anything in the system
 - nodes summary
   * prints a summary of object counts per node type
 - machines summary
   * prints the result of the three queries you asked for

The "summary" name on both endpoints is up for debate.

Also, the behavior is up for debate - I think it might be cleaner to have 4 separate APIs - one for the summary of node/type counts, and one for each requested "report"-like query.

Any thoughts you have would be appreciated.

Mike Pontillo (mpontillo) wrote :

Iterated on this a bit. I think it's better to have separate operations for each query.

See latest examples here:

https://paste.ubuntu.com/17364447/

Mike Pontillo (mpontillo) wrote :

Here's the latest iteration of what I was thinking of doing for this:

https://paste.ubuntu.com/17370652/

Changed in maas:
milestone: 2.0.0 → 2.1.0
Changed in maas:
milestone: 2.0.1 → 2.1.0
importance: Medium → Wishlist
Changed in maas:
milestone: 2.1.0 → 2.1.1
Changed in maas:
milestone: 2.1.1 → 2.1.2
Changed in maas:
milestone: 2.1.2 → 2.1.3
Adam Collard (adam-collard) wrote :

This information is available in MAAS' Prometheus stats

Changed in maas:
assignee: Mike Pontillo (mpontillo) → nobody
milestone: 2.1.3 → none
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers