{
  "id": null,
  "uid": "legion-agent-provider",
  "title": "Legion agent",
  "version": 1,
  "schemaVersion": 39,
  "tags": [
    "legion",
    "agent"
  ],
  "timezone": "utc",
  "editable": true,
  "refresh": "1m",
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "description": "Health, market listing, rentals, GPUs, benchmarks and certificate of your Legion host agents, from their legion_agent_* Prometheus metrics. Import it and pick your Prometheus data source.",
  "templating": {
    "list": [
      {
        "name": "DS_PROMETHEUS",
        "label": "Data source",
        "type": "datasource",
        "query": "prometheus",
        "current": {},
        "hide": 0,
        "refresh": 1,
        "options": []
      },
      {
        "name": "instance",
        "label": "Instance",
        "type": "query",
        "datasource": {
          "type": "prometheus",
          "uid": "${DS_PROMETHEUS}"
        },
        "query": {
          "query": "label_values(legion_agent_build_info, instance)",
          "refId": "v"
        },
        "definition": "label_values(legion_agent_build_info, instance)",
        "refresh": 2,
        "sort": 1,
        "multi": true,
        "includeAll": true,
        "allValue": ".+",
        "current": {
          "selected": true,
          "text": [
            "All"
          ],
          "value": [
            "$__all"
          ]
        },
        "hide": 0,
        "options": []
      }
    ]
  },
  "annotations": {
    "list": []
  },
  "panels": [
    {
      "id": 1,
      "type": "row",
      "title": "Overview",
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "panels": []
    },
    {
      "id": 2,
      "type": "stat",
      "title": "Hosts reporting",
      "description": "Hosts whose agent metrics were received.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 0,
        "y": 1
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "blue",
                "value": null
              }
            ]
          },
          "noValue": "0"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "textMode": "auto"
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "count(legion_agent_health_status{instance=~\"$instance\"})",
          "instant": true
        }
      ]
    },
    {
      "id": 3,
      "type": "stat",
      "title": "Healthy",
      "description": "Hosts where every health check passes (legion_agent_health_status = 1).",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 4,
        "y": 1
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "noValue": "0"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "textMode": "auto"
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "count(legion_agent_health_status{instance=~\"$instance\"} == 1) or vector(0)",
          "instant": true
        }
      ]
    },
    {
      "id": 4,
      "type": "stat",
      "title": "With an issue",
      "description": "Hosts where at least one health check fails. See 'Failing checks' below.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 8,
        "y": 1
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 1
              }
            ]
          },
          "noValue": "0"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "textMode": "auto"
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "count(legion_agent_health_status{instance=~\"$instance\"} == 0) or vector(0)",
          "instant": true
        }
      ]
    },
    {
      "id": 5,
      "type": "stat",
      "title": "Listed",
      "description": "Hosts actively listed in the market (legion_agent_host_listing_status = 1).",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 12,
        "y": 1
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "blue",
                "value": null
              }
            ]
          },
          "noValue": "0"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "textMode": "auto"
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "count(legion_agent_host_listing_status{instance=~\"$instance\"} == 1) or vector(0)",
          "instant": true
        }
      ]
    },
    {
      "id": 6,
      "type": "stat",
      "title": "Active rentals",
      "description": "Running rentals across the selected hosts.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 16,
        "y": 1
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "blue",
                "value": null
              }
            ]
          },
          "noValue": "0"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "textMode": "auto"
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "sum(legion_agent_active_rentals{instance=~\"$instance\"}) or vector(0)",
          "instant": true
        }
      ]
    },
    {
      "id": 7,
      "type": "stat",
      "title": "GPUs rented",
      "description": "GPUs held by running rentals.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 20,
        "y": 1
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "blue",
                "value": null
              }
            ]
          },
          "noValue": "0"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "textMode": "auto"
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "sum(legion_agent_gpus_rented{instance=~\"$instance\"}) or vector(0)",
          "instant": true
        }
      ]
    },
    {
      "id": 8,
      "type": "timeseries",
      "title": "Healthy hosts vs hosts reporting",
      "description": "Hosts with every check passing, against hosts reporting at all.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 5
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never"
          },
          "min": 0
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "count(legion_agent_health_status{instance=~\"$instance\"} == 1) or vector(0)",
          "legendFormat": "healthy"
        },
        {
          "refId": "B",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "count(legion_agent_health_status{instance=~\"$instance\"})",
          "legendFormat": "reporting"
        }
      ]
    },
    {
      "id": 9,
      "type": "timeseries",
      "title": "Failing checks",
      "description": "Hosts failing each health check. controller_sync: the last sync failed or is stale. mesh: the mesh client is down. docker: the engine did not answer. gpu_driver: nvidia-smi failed. disk_space: under 10 GiB free. certificate: expired or revoked. clock: more than a minute off the controller.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 5
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 40,
            "showPoints": "never",
            "stacking": {
              "mode": "normal",
              "group": "A"
            }
          },
          "min": 0
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "count by (check) (legion_agent_health_check{instance=~\"$instance\"} == 0)",
          "legendFormat": "{{check}}"
        }
      ]
    },
    {
      "id": 10,
      "type": "timeseries",
      "title": "Listing state",
      "description": "Hosts by the market state the controller reports: listed, unlisted, awaiting_first_benchmark, first_benchmark_failed, held, under_review, quarantined, suspended, removed, unknown.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 13
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 40,
            "showPoints": "never",
            "stacking": {
              "mode": "normal",
              "group": "A"
            }
          },
          "min": 0
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "count by (state) (legion_agent_host_listing_state{instance=~\"$instance\"} == 1)",
          "legendFormat": "{{state}}"
        }
      ]
    },
    {
      "id": 11,
      "type": "timeseries",
      "title": "Agent versions",
      "description": "Hosts by agent version: watch a release roll out.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 13
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 40,
            "showPoints": "never",
            "stacking": {
              "mode": "normal",
              "group": "A"
            }
          },
          "min": 0
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "count by (version) (legion_agent_build_info{instance=~\"$instance\"})",
          "legendFormat": "{{version}}"
        }
      ]
    },
    {
      "id": 12,
      "type": "timeseries",
      "title": "Active rentals",
      "description": "Running rentals by host.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 21
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never"
          },
          "min": 0
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "max by (instance) (legion_agent_active_rentals{instance=~\"$instance\"})",
          "legendFormat": "{{instance}}"
        }
      ]
    },
    {
      "id": 13,
      "type": "timeseries",
      "title": "GPUs rented",
      "description": "GPUs held by running rentals, by host.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 21
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never"
          },
          "min": 0
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "max by (instance) (legion_agent_gpus_rented{instance=~\"$instance\"})",
          "legendFormat": "{{instance}}"
        }
      ]
    },
    {
      "id": 14,
      "type": "row",
      "title": "Hosts",
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 29
      },
      "panels": []
    },
    {
      "id": 15,
      "type": "table",
      "title": "This host",
      "description": "One row per host. Failing checks counts the health checks at 0; Listing is the market state the controller reports.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 11,
        "w": 24,
        "x": 0,
        "y": 30
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "custom": {
            "align": "auto",
            "cellOptions": {
              "type": "auto"
            }
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Health"
            },
            "properties": [
              {
                "id": "mappings",
                "value": [
                  {
                    "type": "value",
                    "options": {
                      "0": {
                        "text": "Issue",
                        "color": "red"
                      },
                      "1": {
                        "text": "Healthy",
                        "color": "green"
                      }
                    }
                  }
                ]
              },
              {
                "id": "custom.cellOptions",
                "value": {
                  "type": "color-text"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Failing checks"
            },
            "properties": [
              {
                "id": "thresholds",
                "value": {
                  "mode": "absolute",
                  "steps": [
                    {
                      "color": "green",
                      "value": null
                    },
                    {
                      "color": "red",
                      "value": 1
                    }
                  ]
                }
              },
              {
                "id": "custom.cellOptions",
                "value": {
                  "type": "color-text"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Last sync age"
            },
            "properties": [
              {
                "id": "unit",
                "value": "s"
              },
              {
                "id": "decimals",
                "value": 0
              },
              {
                "id": "thresholds",
                "value": {
                  "mode": "absolute",
                  "steps": [
                    {
                      "color": "green",
                      "value": null
                    },
                    {
                      "color": "orange",
                      "value": 120
                    },
                    {
                      "color": "red",
                      "value": 600
                    }
                  ]
                }
              },
              {
                "id": "custom.cellOptions",
                "value": {
                  "type": "color-text"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Cert expires in"
            },
            "properties": [
              {
                "id": "unit",
                "value": "h"
              },
              {
                "id": "decimals",
                "value": 0
              },
              {
                "id": "thresholds",
                "value": {
                  "mode": "absolute",
                  "steps": [
                    {
                      "color": "red",
                      "value": null
                    },
                    {
                      "color": "orange",
                      "value": 4
                    },
                    {
                      "color": "green",
                      "value": 8
                    }
                  ]
                }
              },
              {
                "id": "custom.cellOptions",
                "value": {
                  "type": "color-text"
                }
              }
            ]
          }
        ]
      },
      "options": {
        "showHeader": true,
        "cellHeight": "sm",
        "sortBy": [
          {
            "displayName": "Health",
            "desc": false
          }
        ]
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "max by (instance, instance) (legion_agent_health_status{instance=~\"$instance\"})",
          "format": "table",
          "instant": true,
          "legendFormat": ""
        },
        {
          "refId": "B",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "count by (instance) (legion_agent_health_check{instance=~\"$instance\"} == 0)",
          "format": "table",
          "instant": true,
          "legendFormat": ""
        },
        {
          "refId": "C",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "max by (instance, state) (legion_agent_host_listing_state{instance=~\"$instance\"} == 1)",
          "format": "table",
          "instant": true,
          "legendFormat": ""
        },
        {
          "refId": "D",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "max by (instance) (legion_agent_active_rentals{instance=~\"$instance\"})",
          "format": "table",
          "instant": true,
          "legendFormat": ""
        },
        {
          "refId": "E",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "max by (instance) (legion_agent_gpus_total{instance=~\"$instance\"})",
          "format": "table",
          "instant": true,
          "legendFormat": ""
        },
        {
          "refId": "F",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "time() - max by (instance) (legion_agent_last_sync_timestamp_seconds{instance=~\"$instance\"})",
          "format": "table",
          "instant": true,
          "legendFormat": ""
        },
        {
          "refId": "G",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "max by (instance, version) (legion_agent_build_info{instance=~\"$instance\"})",
          "format": "table",
          "instant": true,
          "legendFormat": ""
        },
        {
          "refId": "H",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "(max by (instance) (legion_agent_certificate_expiry_timestamp_seconds{instance=~\"$instance\"}) - time()) / 3600",
          "format": "table",
          "instant": true,
          "legendFormat": ""
        }
      ],
      "transformations": [
        {
          "id": "merge",
          "options": {}
        },
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Time": true,
              "Value #C": true,
              "Value #G": true
            },
            "renameByName": {
              "Value #A": "Health",
              "Value #B": "Failing checks",
              "state": "Listing",
              "Value #D": "Rentals",
              "Value #E": "GPUs",
              "Value #F": "Last sync age",
              "version": "Version",
              "Value #H": "Cert expires in"
            },
            "indexByName": {
              "host_name": 0,
              "instance": 1,
              "Health": 2,
              "Failing checks": 3,
              "Listing": 4,
              "Rentals": 5,
              "GPUs": 6,
              "Last sync age": 7,
              "Version": 8,
              "Cert expires in": 9
            }
          }
        }
      ]
    },
    {
      "id": 16,
      "type": "row",
      "title": "Health checks",
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 41
      },
      "panels": []
    },
    {
      "id": 17,
      "type": "timeseries",
      "title": "Health check results (1 = pass)",
      "description": "Every health check of every selected host over time. A 0 is the reason a host reads as having an issue.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 9,
        "w": 24,
        "x": 0,
        "y": 42
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never"
          },
          "min": 0,
          "max": 1
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "min by (instance, check) (legion_agent_health_check{instance=~\"$instance\"})",
          "legendFormat": "{{instance}} {{check}}"
        }
      ]
    },
    {
      "id": 18,
      "type": "timeseries",
      "title": "Time since last successful sync",
      "description": "Seconds since each agent last synced with the controller. The agent syncs every 30 s.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 51
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "s",
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never"
          },
          "min": 0
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "time() - max by (instance) (legion_agent_last_sync_timestamp_seconds{instance=~\"$instance\"})",
          "legendFormat": "{{instance}}"
        }
      ]
    },
    {
      "id": 19,
      "type": "timeseries",
      "title": "Clock skew vs the controller",
      "description": "The controller's clock minus the host's, in seconds. Beyond 60 s the clock check fails.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 51
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "s",
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never"
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "max by (instance) (legion_agent_clock_skew_seconds{instance=~\"$instance\"})",
          "legendFormat": "{{instance}}"
        }
      ]
    },
    {
      "id": 20,
      "type": "row",
      "title": "GPUs",
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 59
      },
      "panels": []
    },
    {
      "id": 21,
      "type": "timeseries",
      "title": "GPU utilization",
      "description": "Per GPU, 0 to 100 percent.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 60
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "percent",
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never"
          },
          "min": 0,
          "max": 100
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "max by (instance, gpu) (legion_agent_gpu_utilization_percent{instance=~\"$instance\"})",
          "legendFormat": "{{instance}} gpu {{gpu}}"
        }
      ]
    },
    {
      "id": 22,
      "type": "timeseries",
      "title": "GPU power",
      "description": "Per GPU, watts, with the enforced limit.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 60
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "watt",
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never"
          },
          "min": 0
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "max by (instance, gpu) (legion_agent_gpu_power_watts{instance=~\"$instance\"})",
          "legendFormat": "{{instance}} gpu {{gpu}}"
        },
        {
          "refId": "B",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "max by (instance, gpu) (legion_agent_gpu_power_limit_watts{instance=~\"$instance\"})",
          "legendFormat": "limit {{instance}} gpu {{gpu}}"
        }
      ]
    },
    {
      "id": 23,
      "type": "timeseries",
      "title": "GPU temperature",
      "description": "Per GPU, degrees Celsius. Absent where the driver does not report it.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 68
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "celsius",
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never"
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "max by (instance, gpu) (legion_agent_gpu_temperature_celsius{instance=~\"$instance\"})",
          "legendFormat": "{{instance}} gpu {{gpu}}"
        }
      ]
    },
    {
      "id": 24,
      "type": "timeseries",
      "title": "GPU memory used",
      "description": "Per GPU, the share of device memory in use.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 68
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "percent",
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never"
          },
          "min": 0,
          "max": 100
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "100 * max by (instance, gpu) (legion_agent_gpu_memory_used_bytes{instance=~\"$instance\"}) / max by (instance, gpu) (legion_agent_gpu_memory_total_bytes{instance=~\"$instance\"})",
          "legendFormat": "{{instance}} gpu {{gpu}}"
        }
      ]
    },
    {
      "id": 25,
      "type": "row",
      "title": "Benchmarks (last run, measured by the agent when the host is idle)",
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 76
      },
      "panels": []
    },
    {
      "id": 26,
      "type": "timeseries",
      "title": "Upload and download line speed",
      "description": "Bits per second, as the last benchmark run measured them.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 77
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "bps",
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never"
          },
          "min": 0
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "max by (instance) (legion_agent_bench_upload_bits_per_second{instance=~\"$instance\"})",
          "legendFormat": "up {{instance}}"
        },
        {
          "refId": "B",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "max by (instance) (legion_agent_bench_download_bits_per_second{instance=~\"$instance\"})",
          "legendFormat": "down {{instance}}"
        }
      ]
    },
    {
      "id": 27,
      "type": "timeseries",
      "title": "Disk speed",
      "description": "Sequential read and write, bytes per second, of the last benchmark run.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 77
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "Bps",
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never"
          },
          "min": 0
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "max by (instance) (legion_agent_bench_disk_read_bytes_per_second{instance=~\"$instance\"})",
          "legendFormat": "read {{instance}}"
        },
        {
          "refId": "B",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "max by (instance) (legion_agent_bench_disk_write_bytes_per_second{instance=~\"$instance\"})",
          "legendFormat": "write {{instance}}"
        }
      ]
    },
    {
      "id": 28,
      "type": "timeseries",
      "title": "GPU compute (FP16) and memory bandwidth",
      "description": "From the last GPU benchmark run: dense FP16 TFLOPS and device memory bandwidth.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 85
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never"
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "max by (instance, gpu) (legion_agent_bench_gpu_fp16_tflops{instance=~\"$instance\"})",
          "legendFormat": "fp16 TFLOPS {{instance}} gpu {{gpu}}"
        }
      ]
    },
    {
      "id": 29,
      "type": "timeseries",
      "title": "Time since the last benchmark run",
      "description": "Seconds since the last network and disk run finished.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 85
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "s",
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never"
          },
          "min": 0
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "time() - max by (instance) (legion_agent_bench_last_run_timestamp_seconds{instance=~\"$instance\"})",
          "legendFormat": "{{instance}}"
        }
      ]
    },
    {
      "id": 30,
      "type": "row",
      "title": "Host",
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 93
      },
      "panels": []
    },
    {
      "id": 31,
      "type": "timeseries",
      "title": "Workspace disk free",
      "description": "Free bytes on the filesystem that holds rentals. Under 10 GiB fails the disk_space check.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 94
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "bytes",
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never"
          },
          "min": 0
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "max by (instance) (legion_agent_workspace_disk_free_bytes{instance=~\"$instance\"})",
          "legendFormat": "{{instance}}"
        }
      ]
    },
    {
      "id": 32,
      "type": "timeseries",
      "title": "Certificate expiry",
      "description": "Days until the agent's client certificate expires; the agent renews it by itself well before.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 94
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "h",
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never"
          },
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "orange",
                "value": 4
              },
              {
                "color": "green",
                "value": 8
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "(max by (instance) (legion_agent_certificate_expiry_timestamp_seconds{instance=~\"$instance\"}) - time()) / 3600",
          "legendFormat": "{{instance}}"
        }
      ]
    },
    {
      "id": 33,
      "type": "timeseries",
      "title": "Uptime",
      "description": "Seconds since the agent process started; a drop is a restart or an upgrade.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 102
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "s",
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never"
          },
          "min": 0
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "max by (instance) (legion_agent_uptime_seconds{instance=~\"$instance\"})",
          "legendFormat": "{{instance}}"
        }
      ]
    },
    {
      "id": 34,
      "type": "timeseries",
      "title": "Mesh connected and upgrade deferred",
      "description": "1 when the mesh client is up; 1 while an offered upgrade is held back for a renter's SSH session.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 102
      },
      "pluginVersion": "10.0.0",
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never"
          },
          "min": 0,
          "max": 1
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "min by (instance) (legion_agent_mesh_connected{instance=~\"$instance\"})",
          "legendFormat": "mesh {{instance}}"
        },
        {
          "refId": "B",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "max by (instance) (legion_agent_upgrade_deferred{instance=~\"$instance\"})",
          "legendFormat": "upgrade deferred {{instance}}"
        }
      ]
    }
  ],
  "__inputs": [
    {
      "name": "DS_PROMETHEUS",
      "label": "Prometheus",
      "description": "The Prometheus (or VictoriaMetrics) that scrapes your agents",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "10.0.0"
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "1.0.0"
    }
  ]
}
