RESTful sensor, XML and Monit

I’m using what I think is a new feature of the RESTful sensor to pick up an XML feed from Monit (which saves feeding it through Node-Red!).

However, I don’t really understand the different templates etc to be able to pick up the data I want cleanly.

configuralion.yaml

- platform: rest
  name: Monit Hassio
  resource: http://192.168.7.30:2812/_status?format=xml
  json_attributes_path: "$.monit"
  value_template: 'OK'
  json_attributes:
    - "platform"
    - "server"
    - "service"

This collects the XML into a single sensor, but I’d like to break it up and cannot find a combination of configuration to do that :frowning_face:

For example, how could I simply pull out a sensor that has the % of memory used and the CPU Load?

This is what the state attributes look like from the above configuration;

platform:
  name: Linux
  release: 4.19.97-v7l+
  version: '#1294 SMP Thu Jan 30 13:21:14 GMT 2020'
  machine: armv7l
  cpu: '4'
  memory: '3999756'
  swap: '102396'
server:
  id: 501a8b2fcf0b88434cba245a8b32f64c
  incarnation: '1582836234'
  version: 5.25.2
  uptime: '1682'
  poll: '120'
  startdelay: '0'
  localhostname: raspberrypi
  controlfile: /etc/monit/monitrc
  httpd:
    address: 192.168.7.30
    port: '2812'
    ssl: '0'
service:
  '@type': '5'
  name: raspberrypi
  collected_sec: '1582837928'
  collected_usec: '901937'
  status: '0'
  status_hint: '0'
  monitor: '1'
  monitormode: '0'
  onreboot: '0'
  pendingaction: '0'
  system:
    load:
      avg01: '0.17'
      avg05: '0.17'
      avg15: '0.22'
    cpu:
      user: '2.9'
      system: '1.8'
      wait: '0.0'
    memory:
      percent: '21.0'
      kilobyte: '839936'
    swap:
      percent: '0.0'
      kilobyte: '0'
friendly_name: Monit Hassio

This is the JSON the suggested debugger produces (which isn’t actually valid JSON).

{
  "monit": {
    "platform": {
      "cpu": "4",
      "machine": "armv7l",
      "memory": "3999756",
      "name": "Linux",
      "release": "4.19.97-v7l+",
      "swap": "102396",
      "version": "#1294 SMP Thu Jan 30 13:21:14 GMT 2020"
    },
    "server": {
      "controlfile": "/etc/monit/monitrc",
      "httpd": {
        "address": "192.168.7.30",
        "port": "2812",
        "ssl": "0"
      },
      "id": "501a8b2fcf0b88434cba245a8b32f64c",
      "incarnation": "1582750875",
      "localhostname": "raspberrypi",
      "poll": "120",
      "startdelay": "0",
      "uptime": "67823",
      "version": "5.25.2"
    },
    "service": {
      "@type": "5",
      "collected_sec": "1582818697",
      "collected_usec": "769251",
      "monitor": "1",
      "monitormode": "0",
      "name": "raspberrypi",
      "onreboot": "0",
      "pendingaction": "0",
      "status": "0",
      "status_hint": "0",
      "system": {
        "cpu": {
          "system": "1.7",
          "user": "3.0",
          "wait": "0.0"
        },
        "load": {
          "avg01": "0.15",
          "avg05": "0.15",
          "avg15": "0.18"
        },
        "memory": {
          "kilobyte": "910472",
          "percent": "22.8"
        },
        "swap": {
          "kilobyte": "0",
          "percent": "0.0"
        }
      }
    }
  }
}