{
  "$schema": "./.schemas/page.schema.json",
  "title": "Response times",
  "icon": "gauge.with.needle",
  "sidebar": false,
  "sources": {
    "kuma": {
      "url": "https://kuma.example.com",
      "secret": "kuma",
      "every": "1m",
      "auth": {
        "type": "basic"
      },
      "requests": {
        "monitors": {
          "path": "/metrics",
          "format": "prometheus",
          "group_by": "monitor_id",
          "split_by": [
            "window"
          ]
        }
      },
      "derive": [
        {
          "name": "web_count",
          "value": {
            "count": "monitors",
            "where": {
              "all": [
                {
                  "path": "monitor_type",
                  "equals": "http"
                },
                {
                  "path": "monitor_status",
                  "equals": 1
                },
                {
                  "path": "monitor_response_time",
                  "gte": 0
                }
              ]
            }
          }
        }
      ]
    }
  },
  "cards": [
    {
      "id": "slowest",
      "type": "bars",
      "label": "Web services now",
      "unit": "ms",
      "items": [],
      "source": {
        "ref": "kuma",
        "map": {
          "items": {
            "each": "monitors",
            "where": {
              "all": [
                {
                  "path": "monitor_type",
                  "equals": "http"
                },
                {
                  "path": "monitor_status",
                  "equals": 1
                },
                {
                  "path": "monitor_response_time",
                  "gte": 0
                }
              ]
            },
            "sort": {
              "by": "monitor_response_time",
              "order": "desc"
            },
            "limit": 20,
            "fields": {
              "label": "monitor_name",
              "value": "monitor_response_time",
              "url": {
                "template": "legato://page/uptime-monitor?id={monitor_id|raw}"
              }
            }
          }
        }
      }
    },
    {
      "id": "more",
      "type": "text",
      "tone": "info",
      "body": "",
      "source": {
        "ref": "kuma",
        "when": {
          "path": "web_count",
          "gt": 20
        },
        "map": {
          "body": {
            "template": "The 20 slowest of {web_count}. [Uptime Kuma](https://kuma.example.com) lists them all."
          }
        }
      }
    }
  ]
}
