{
  "uid": "chronos-customer",
  "title": "chronos recording health",
  "description": "Customer view: which devices are recording, how much was recorded and delivered, and how the privacy filter is protecting content. Counts and timestamps only.",
  "schemaVersion": 39,
  "version": 1,
  "editable": true,
  "graphTooltip": 1,
  "tags": [
    "chronos",
    "customer"
  ],
  "time": {
    "from": "now-24h",
    "to": "now"
  },
  "refresh": "1m",
  "timepicker": {
    "refresh_intervals": [
      "1m",
      "5m",
      "15m",
      "1h"
    ]
  },
  "templating": {
    "list": [
      {
        "name": "datasource",
        "label": "datasource",
        "type": "datasource",
        "query": "prometheus",
        "current": {},
        "hide": 0,
        "refresh": 1
      },
      {
        "name": "prefix",
        "label": "group",
        "type": "query",
        "datasource": {
          "type": "prometheus",
          "uid": "${datasource}"
        },
        "query": {
          "query": "query_result(group by (chronos_cloud_prefix) (last_over_time(target_info{job=\"chronos\"}[7d])))",
          "refId": "prefix"
        },
        "definition": "query_result(group by (chronos_cloud_prefix) (last_over_time(target_info{job=\"chronos\"}[7d])))",
        "includeAll": true,
        "allValue": ".*",
        "multi": true,
        "refresh": 2,
        "sort": 1,
        "current": {},
        "hide": 0,
        "regex": "/chronos_cloud_prefix=\"([^\"]+)\"/"
      },
      {
        "name": "instance",
        "label": "device",
        "type": "query",
        "datasource": {
          "type": "prometheus",
          "uid": "${datasource}"
        },
        "query": {
          "query": "query_result(group by (instance) (last_over_time(target_info{job=\"chronos\", chronos_cloud_prefix=~\"$prefix\"}[7d])))",
          "refId": "instance"
        },
        "definition": "query_result(group by (instance) (last_over_time(target_info{job=\"chronos\", chronos_cloud_prefix=~\"$prefix\"}[7d])))",
        "includeAll": true,
        "multi": true,
        "refresh": 2,
        "sort": 1,
        "current": {},
        "hide": 0,
        "regex": "/instance=\"([^\"]+)\"/"
      }
    ]
  },
  "panels": [
    {
      "id": 1,
      "type": "row",
      "title": "right now",
      "collapsed": false,
      "gridPos": {
        "x": 0,
        "y": 0,
        "w": 24,
        "h": 1
      },
      "panels": []
    },
    {
      "id": 2,
      "type": "stat",
      "title": "devices recording now",
      "description": "Devices that are reporting in and recording as expected right now.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 0,
        "y": 1,
        "w": 4,
        "h": 4
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "count((((group by (instance) (((sum by (instance) (increase(chronos_recording_expected_duration_seconds_total{instance=~\"$instance\"}[3h]))) > 9000) unless on (instance) ((sum by (instance) (increase(chronos_video_chunk_encoded_duration_seconds_total{instance=~\"$instance\"}[3h]))) >= 0.2 * (sum by (instance) (increase(chronos_recording_expected_duration_seconds_total{instance=~\"$instance\"}[3h]))))) or group by (instance) ((max_over_time(chronos_disk_free_bytes{instance=~\"$instance\"}[30m]) < 5e9) and (count_over_time(chronos_disk_free_bytes{instance=~\"$instance\"}[30m]) >= 25)) or group by (instance) (min_over_time(chronos_runtime_stalled{instance=~\"$instance\"}[10m]) == 1) or group by (instance) (((time() - max by (instance) (chronos_upload_last_success_seconds{instance=~\"$instance\",kind=\"video\"})) > 21600) and on (instance) ((time() - max by (instance) (chronos_video_chunk_last_success_seconds{instance=~\"$instance\"})) < 3600) and on (instance) (count_over_time(chronos_up{instance=~\"$instance\"}[2h]) >= 90)) or group by (instance) (min_over_time(chronos_observation_state{instance=~\"$instance\",state=\"misconfigured\"}[30m]) == 1) or group by (instance) (changes(chronos_process_start_time_seconds{instance=~\"$instance\"}[1h]) > 4)) and on (instance) (group by (instance) (max_over_time(chronos_up{instance=~\"$instance\"}[10m])))) * 4 or (group by (instance) (chronos_recording_state{instance=~\"$instance\",state=\"paused_by_user\"} == 1) and on (instance) (group by (instance) (max_over_time(chronos_up{instance=~\"$instance\"}[10m])))) * 3 or (group by (instance) (chronos_recording_state{instance=~\"$instance\",state=\"off_by_schedule\"} == 1) and on (instance) (group by (instance) (max_over_time(chronos_up{instance=~\"$instance\"}[10m])))) * 2 or (group by (instance) (max_over_time(chronos_up{instance=~\"$instance\"}[10m]))) * 1 or ((group by (instance) (last_over_time(chronos_up{instance=~\"$instance\"}[24h]))) unless on (instance) (group by (instance) (max_over_time(chronos_up{instance=~\"$instance\"}[10m])))) * 5 or (group by (instance) (last_over_time(chronos_up{instance=~\"$instance\"}[7d])) unless on (instance) (group by (instance) (last_over_time(chronos_up{instance=~\"$instance\"}[24h])))) * 6) == 1) or vector(0)",
          "legendFormat": "",
          "instant": true,
          "range": false
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "none",
          "noValue": "0",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "#6e7681",
                "value": null
              },
              {
                "color": "green",
                "value": 1
              }
            ]
          },
          "color": {
            "mode": "thresholds"
          }
        },
        "overrides": []
      },
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      }
    },
    {
      "id": 3,
      "type": "stat",
      "title": "need attention",
      "description": "Devices with a problem that has lasted a while, so a short interruption never shows here. Examples: the device should have been recording for 3 hours but saved almost no video, it is running out of disk space, the recorder stopped responding, its recording schedule is set up incorrectly, recordings are not being delivered to your storage, or it keeps restarting. A device that restarts more often than every 6 hours will not show the delivery problem. Open the device status table to see which device. Devices that run without screen recording always show here.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 4,
        "y": 1,
        "w": 4,
        "h": 4
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "count((((group by (instance) (((sum by (instance) (increase(chronos_recording_expected_duration_seconds_total{instance=~\"$instance\"}[3h]))) > 9000) unless on (instance) ((sum by (instance) (increase(chronos_video_chunk_encoded_duration_seconds_total{instance=~\"$instance\"}[3h]))) >= 0.2 * (sum by (instance) (increase(chronos_recording_expected_duration_seconds_total{instance=~\"$instance\"}[3h]))))) or group by (instance) ((max_over_time(chronos_disk_free_bytes{instance=~\"$instance\"}[30m]) < 5e9) and (count_over_time(chronos_disk_free_bytes{instance=~\"$instance\"}[30m]) >= 25)) or group by (instance) (min_over_time(chronos_runtime_stalled{instance=~\"$instance\"}[10m]) == 1) or group by (instance) (((time() - max by (instance) (chronos_upload_last_success_seconds{instance=~\"$instance\",kind=\"video\"})) > 21600) and on (instance) ((time() - max by (instance) (chronos_video_chunk_last_success_seconds{instance=~\"$instance\"})) < 3600) and on (instance) (count_over_time(chronos_up{instance=~\"$instance\"}[2h]) >= 90)) or group by (instance) (min_over_time(chronos_observation_state{instance=~\"$instance\",state=\"misconfigured\"}[30m]) == 1) or group by (instance) (changes(chronos_process_start_time_seconds{instance=~\"$instance\"}[1h]) > 4)) and on (instance) (group by (instance) (max_over_time(chronos_up{instance=~\"$instance\"}[10m])))) * 4 or (group by (instance) (chronos_recording_state{instance=~\"$instance\",state=\"paused_by_user\"} == 1) and on (instance) (group by (instance) (max_over_time(chronos_up{instance=~\"$instance\"}[10m])))) * 3 or (group by (instance) (chronos_recording_state{instance=~\"$instance\",state=\"off_by_schedule\"} == 1) and on (instance) (group by (instance) (max_over_time(chronos_up{instance=~\"$instance\"}[10m])))) * 2 or (group by (instance) (max_over_time(chronos_up{instance=~\"$instance\"}[10m]))) * 1 or ((group by (instance) (last_over_time(chronos_up{instance=~\"$instance\"}[24h]))) unless on (instance) (group by (instance) (max_over_time(chronos_up{instance=~\"$instance\"}[10m])))) * 5 or (group by (instance) (last_over_time(chronos_up{instance=~\"$instance\"}[7d])) unless on (instance) (group by (instance) (last_over_time(chronos_up{instance=~\"$instance\"}[24h])))) * 6) == 4) or vector(0)",
          "legendFormat": "",
          "instant": true,
          "range": false
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "none",
          "noValue": "0",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "orange",
                "value": 1
              }
            ]
          },
          "color": {
            "mode": "thresholds"
          },
          "mappings": [
            {
              "type": "value",
              "options": {
                "0": {
                  "text": "all clear",
                  "color": "green",
                  "index": 0
                }
              }
            }
          ]
        },
        "overrides": []
      },
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      }
    },
    {
      "id": 4,
      "type": "stat",
      "title": "hours recorded (24h)",
      "description": "Total hours of screen recording saved by the selected devices in the last 24 hours. A device with two screens adds the hours of both.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 8,
        "y": 1,
        "w": 4,
        "h": 4
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "sum(increase(chronos_video_chunk_encoded_duration_seconds_total{instance=~\"$instance\"}[24h])) / 3600",
          "legendFormat": "",
          "instant": true,
          "range": false
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "suffix: h",
          "noValue": "0",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "color": {
            "mode": "thresholds"
          },
          "decimals": 1
        },
        "overrides": []
      },
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      }
    },
    {
      "id": 5,
      "type": "stat",
      "title": "coverage (24h)",
      "description": "Of the time a device was supposed to be recording (not paused, inside its recording hours), the share that was actually saved as video, averaged over the devices that were expected to record for at least 30 minutes in the last 24 hours. Other devices are left out. A qualifying device that saved no video at all counts as 0%. Close to 100% means almost every expected minute was recorded. A device with several screens counts all its screens together, capped at 100%, so docking a laptop or unplugging a screen does not lower it. Reads \"not enough data yet\" when no device qualifies, for example right after install or when devices were paused or outside their hours.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 12,
        "y": 1,
        "w": 4,
        "h": 4
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "avg(clamp_max((sum by (instance) (increase(chronos_video_chunk_encoded_duration_seconds_total{instance=~\"$instance\"}[24h])) or (sum by (instance) (increase(chronos_recording_expected_duration_seconds_total{instance=~\"$instance\"}[24h])) * 0)) / on (instance) (sum by (instance) (increase(chronos_recording_expected_duration_seconds_total{instance=~\"$instance\"}[24h])) > 1800), 1))",
          "legendFormat": "",
          "instant": true,
          "range": false
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "percentunit",
          "noValue": "not enough data yet",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "blue",
                "value": null
              },
              {
                "color": "green",
                "value": 0.9
              }
            ]
          },
          "color": {
            "mode": "thresholds"
          },
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      }
    },
    {
      "id": 6,
      "type": "stat",
      "title": "delivered (24h)",
      "description": "Video files delivered to your storage in the last 24 hours. Reads \"no deliveries\" when none arrived, which is also what you see when delivery to your storage is not set up or is failing. Check the \"need attention\" card and the last video delivered column.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 16,
        "y": 1,
        "w": 4,
        "h": 4
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "round(sum(increase(chronos_upload_files_total{instance=~\"$instance\",kind=\"video\",outcome=\"ok\"}[24h])))",
          "legendFormat": "",
          "instant": true,
          "range": false
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "none",
          "noValue": "no deliveries",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "#6e7681",
                "value": null
              },
              {
                "color": "green",
                "value": 1
              }
            ]
          },
          "color": {
            "mode": "thresholds"
          },
          "decimals": 0,
          "mappings": [
            {
              "type": "value",
              "options": {
                "0": {
                  "text": "no deliveries",
                  "color": "#6e7681",
                  "index": 0
                }
              }
            }
          ]
        },
        "overrides": []
      },
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      }
    },
    {
      "id": 7,
      "type": "stat",
      "title": "frames protected (24h)",
      "description": "Screen frames where a protected application or website was on screen and was blurred before anything was saved. Counts the app in focus and protected windows in the background.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 20,
        "y": 1,
        "w": 4,
        "h": 4
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "sum(increase(chronos_frames_blurred_total{instance=~\"$instance\"}[24h])) or vector(0)",
          "legendFormat": "",
          "instant": true,
          "range": false
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "none",
          "noValue": "0",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "color": {
            "mode": "thresholds"
          },
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      }
    },
    {
      "id": 8,
      "type": "row",
      "title": "devices",
      "collapsed": false,
      "gridPos": {
        "x": 0,
        "y": 5,
        "w": 24,
        "h": 1
      },
      "panels": []
    },
    {
      "id": 9,
      "type": "table",
      "title": "device status",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "description": "One row per device. recording: working as expected. paused: recording was paused by the user. outside recording hours: recording is scheduled off right now. not reporting: the device has not checked in for 10 minutes or more, which is normal for a laptop that is off, asleep or offline. offline: not seen for more than a day. needs attention: a lasting condition described on the card above. Screens is how many displays the device last reported using; a laptop that is docked at the office and undocked at home will change. The last two columns show how long ago a video was last recorded and delivered.",
      "gridPos": {
        "x": 0,
        "y": 6,
        "w": 24,
        "h": 7
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "((group by (instance) (((sum by (instance) (increase(chronos_recording_expected_duration_seconds_total{instance=~\"$instance\"}[3h]))) > 9000) unless on (instance) ((sum by (instance) (increase(chronos_video_chunk_encoded_duration_seconds_total{instance=~\"$instance\"}[3h]))) >= 0.2 * (sum by (instance) (increase(chronos_recording_expected_duration_seconds_total{instance=~\"$instance\"}[3h]))))) or group by (instance) ((max_over_time(chronos_disk_free_bytes{instance=~\"$instance\"}[30m]) < 5e9) and (count_over_time(chronos_disk_free_bytes{instance=~\"$instance\"}[30m]) >= 25)) or group by (instance) (min_over_time(chronos_runtime_stalled{instance=~\"$instance\"}[10m]) == 1) or group by (instance) (((time() - max by (instance) (chronos_upload_last_success_seconds{instance=~\"$instance\",kind=\"video\"})) > 21600) and on (instance) ((time() - max by (instance) (chronos_video_chunk_last_success_seconds{instance=~\"$instance\"})) < 3600) and on (instance) (count_over_time(chronos_up{instance=~\"$instance\"}[2h]) >= 90)) or group by (instance) (min_over_time(chronos_observation_state{instance=~\"$instance\",state=\"misconfigured\"}[30m]) == 1) or group by (instance) (changes(chronos_process_start_time_seconds{instance=~\"$instance\"}[1h]) > 4)) and on (instance) (group by (instance) (max_over_time(chronos_up{instance=~\"$instance\"}[10m])))) * 4 or (group by (instance) (chronos_recording_state{instance=~\"$instance\",state=\"paused_by_user\"} == 1) and on (instance) (group by (instance) (max_over_time(chronos_up{instance=~\"$instance\"}[10m])))) * 3 or (group by (instance) (chronos_recording_state{instance=~\"$instance\",state=\"off_by_schedule\"} == 1) and on (instance) (group by (instance) (max_over_time(chronos_up{instance=~\"$instance\"}[10m])))) * 2 or (group by (instance) (max_over_time(chronos_up{instance=~\"$instance\"}[10m]))) * 1 or ((group by (instance) (last_over_time(chronos_up{instance=~\"$instance\"}[24h]))) unless on (instance) (group by (instance) (max_over_time(chronos_up{instance=~\"$instance\"}[10m])))) * 5 or (group by (instance) (last_over_time(chronos_up{instance=~\"$instance\"}[7d])) unless on (instance) (group by (instance) (last_over_time(chronos_up{instance=~\"$instance\"}[24h])))) * 6",
          "legendFormat": "",
          "format": "table",
          "instant": true,
          "range": false
        },
        {
          "refId": "B",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "time() - max by (instance) (chronos_video_chunk_last_success_seconds{instance=~\"$instance\"})",
          "legendFormat": "",
          "format": "table",
          "instant": true,
          "range": false
        },
        {
          "refId": "C",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "time() - max by (instance) (chronos_upload_last_success_seconds{instance=~\"$instance\",kind=\"video\"})",
          "legendFormat": "",
          "format": "table",
          "instant": true,
          "range": false
        },
        {
          "refId": "D",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (instance, version) (chronos_build_info{instance=~\"$instance\"})",
          "legendFormat": "",
          "format": "table",
          "instant": true,
          "range": false
        },
        {
          "refId": "E",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (instance) (last_over_time(chronos_monitors_active{instance=~\"$instance\"}[7d]))",
          "legendFormat": "",
          "format": "table",
          "instant": true,
          "range": false
        }
      ],
      "transformations": [
        {
          "id": "joinByField",
          "options": {
            "byField": "instance",
            "mode": "outer"
          }
        },
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Time": true,
              "Time 1": true,
              "Time 2": true,
              "Time 3": true,
              "Time 4": true,
              "Value #D": true,
              "Time 5": true
            },
            "renameByName": {
              "instance": "device",
              "Value #A": "status",
              "Value #B": "last video recorded",
              "Value #C": "last video delivered",
              "version": "version",
              "Value #E": "screens"
            },
            "indexByName": {
              "instance": 0,
              "Value #A": 1,
              "Value #E": 2,
              "Value #B": 3,
              "Value #C": 4,
              "version": 5
            }
          }
        }
      ],
      "fieldConfig": {
        "defaults": {
          "custom": {
            "align": "auto"
          },
          "noValue": "-"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "status"
            },
            "properties": [
              {
                "id": "mappings",
                "value": [
                  {
                    "type": "value",
                    "options": {
                      "1": {
                        "text": "recording",
                        "color": "green",
                        "index": 0
                      },
                      "2": {
                        "text": "outside recording hours",
                        "color": "light-blue",
                        "index": 1
                      },
                      "3": {
                        "text": "paused",
                        "color": "blue",
                        "index": 2
                      },
                      "4": {
                        "text": "needs attention",
                        "color": "orange",
                        "index": 3
                      },
                      "5": {
                        "text": "not reporting",
                        "color": "#8b949e",
                        "index": 4
                      },
                      "6": {
                        "text": "offline",
                        "color": "#57606a",
                        "index": 5
                      }
                    }
                  }
                ]
              },
              {
                "id": "custom.cellOptions",
                "value": {
                  "type": "color-background"
                }
              },
              {
                "id": "custom.align",
                "value": "center"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "last video recorded"
            },
            "properties": [
              {
                "id": "unit",
                "value": "s"
              },
              {
                "id": "decimals",
                "value": 0
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "last video delivered"
            },
            "properties": [
              {
                "id": "unit",
                "value": "s"
              },
              {
                "id": "decimals",
                "value": 0
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "screens"
            },
            "properties": [
              {
                "id": "unit",
                "value": "none"
              },
              {
                "id": "decimals",
                "value": 0
              },
              {
                "id": "custom.align",
                "value": "center"
              }
            ]
          }
        ]
      },
      "options": {
        "showHeader": true,
        "sortBy": [
          {
            "displayName": "device",
            "desc": false
          }
        ]
      }
    },
    {
      "id": 10,
      "type": "row",
      "title": "trends",
      "collapsed": false,
      "gridPos": {
        "x": 0,
        "y": 15,
        "w": 24,
        "h": 1
      },
      "panels": []
    },
    {
      "id": 11,
      "type": "timeseries",
      "title": "hours recorded, rolling 24 h (last 7 days)",
      "description": "Hours of screen recording saved in the 24 hours up to each point on the line, for the selected devices. A device with two screens adds the hours of both. Lower values on weekends or holidays are normal.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 0,
        "y": 16,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "sum(increase(chronos_video_chunk_encoded_duration_seconds_total{instance=~\"$instance\"}[1d])) / 3600",
          "legendFormat": "hours recorded in the preceding 24 hours"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "suffix: h",
          "custom": {
            "lineWidth": 2,
            "fillOpacity": 15,
            "showPoints": "never"
          },
          "min": 0,
          "color": {
            "mode": "fixed",
            "fixedColor": "green"
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi"
        }
      },
      "timeFrom": "7d"
    },
    {
      "id": 12,
      "type": "timeseries",
      "title": "devices reporting",
      "description": "How many devices checked in over time. Dips are normal outside working hours when laptops are off.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 12,
        "y": 16,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "count(chronos_up{instance=~\"$instance\"}) or vector(0)",
          "legendFormat": "devices reporting"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "none",
          "custom": {
            "lineWidth": 2,
            "fillOpacity": 15,
            "showPoints": "never",
            "axisSoftMax": 3
          },
          "min": 0,
          "color": {
            "mode": "fixed",
            "fixedColor": "blue"
          },
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi"
        }
      }
    },
    {
      "id": 13,
      "type": "row",
      "title": "delivery and privacy",
      "collapsed": false,
      "gridPos": {
        "x": 0,
        "y": 24,
        "w": 24,
        "h": 1
      },
      "panels": []
    },
    {
      "id": 14,
      "type": "timeseries",
      "title": "recordings delivered (rolling hour)",
      "description": "Video files delivered to your storage bucket in the hour up to each point on the line. Empty when cloud upload is not enabled.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 0,
        "y": 25,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "sum(increase(chronos_upload_files_total{instance=~\"$instance\",kind=\"video\",outcome=\"ok\"}[1h]))",
          "legendFormat": "recordings delivered in the preceding hour"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "none",
          "custom": {
            "lineWidth": 2,
            "fillOpacity": 15,
            "showPoints": "never"
          },
          "min": 0,
          "color": {
            "mode": "fixed",
            "fixedColor": "green"
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi"
        }
      }
    },
    {
      "id": 15,
      "type": "timeseries",
      "title": "frames protected (rolling hour)",
      "description": "Frames blurred in the hour up to each point on the line because a protected application or website was on screen. focused: the app in front was protected. background: a protected window was visible behind it.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 12,
        "y": 25,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "sum by (trigger) (increase(chronos_frames_blurred_total{instance=~\"$instance\"}[1h]))",
          "legendFormat": "{{trigger}} window"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "none",
          "custom": {
            "lineWidth": 2,
            "fillOpacity": 15,
            "showPoints": "never"
          },
          "min": 0
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi"
        }
      }
    },
    {
      "id": 16,
      "type": "text",
      "title": "how to read this dashboard",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 0,
        "y": 33,
        "w": 24,
        "h": 6
      },
      "options": {
        "mode": "markdown",
        "content": "**Good to know**\n\n- A device only shows **needs attention** after a condition has lasted a while (for example 3 hours of expected recording with almost no video). A short network interruption, a restart or a pause never triggers it.\n- **not reporting** and **offline** are neutral. Laptops are often off or asleep, and recordings made meanwhile are delivered once the device is back online.\n- **paused** and **outside recording hours** mean recording is switched off on purpose.\n- A **locked** screen is not a recording state: the device stays in its state and simply has nothing new to capture.\n- This dashboard contains counts and timestamps only. It never contains screen content, window titles, file names or user names.\n"
      }
    },
    {
      "type": "row",
      "title": "activity",
      "collapsed": false,
      "panels": [],
      "id": 17,
      "gridPos": {
        "x": 0,
        "y": 39,
        "w": 24,
        "h": 1
      }
    },
    {
      "type": "state-timeline",
      "title": "recording state",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "description": "What each device was doing over time. recording: capturing the screen. paused: paused by the user. outside recording hours: switched off by the recording schedule. not reporting (asleep/off): the device did not check in, which is normal for a laptop that is asleep, off or offline; it shows about 5 minutes after the last check-in. Devices report every 60 seconds, so a change can take up to two minutes to show. Colours: grey = not reporting, green = recording, light blue = outside recording hours, blue = paused.",
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (instance) ((chronos_recording_state{instance=~\"$instance\",state=\"recording\"} == 1) * 0 + 1 or (chronos_recording_state{instance=~\"$instance\",state=\"off_by_schedule\"} == 1) * 0 + 2 or (chronos_recording_state{instance=~\"$instance\",state=\"paused_by_user\"} == 1) * 0 + 3) or (group by (instance) (last_over_time(chronos_up{instance=~\"$instance\"}[1d])) unless on (instance) group by (instance) (chronos_up{instance=~\"$instance\"})) * 0",
          "legendFormat": "{{instance}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "mappings": [
            {
              "type": "value",
              "options": {
                "0": {
                  "text": "not reporting (asleep/off)",
                  "color": "#8b949e",
                  "index": 0
                },
                "1": {
                  "text": "recording",
                  "color": "green",
                  "index": 1
                },
                "2": {
                  "text": "outside recording hours",
                  "color": "light-blue",
                  "index": 2
                },
                "3": {
                  "text": "paused",
                  "color": "blue",
                  "index": 3
                }
              }
            }
          ],
          "color": {
            "mode": "thresholds"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "#8b949e",
                "value": null
              },
              {
                "color": "green",
                "value": 1
              },
              {
                "color": "light-blue",
                "value": 2
              },
              {
                "color": "blue",
                "value": 3
              }
            ]
          },
          "custom": {
            "fillOpacity": 80,
            "lineWidth": 0
          }
        },
        "overrides": []
      },
      "options": {
        "showValue": "never",
        "mergeValues": true,
        "rowHeight": 0.9,
        "legend": {
          "showLegend": false
        },
        "tooltip": {
          "mode": "single"
        }
      },
      "maxDataPoints": 500,
      "id": 18,
      "gridPos": {
        "x": 0,
        "y": 40,
        "w": 24,
        "h": 8
      }
    },
    {
      "type": "state-timeline",
      "title": "screen locked",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "description": "When the screen of each device was locked. Locking does not change the recording state; a locked screen simply has nothing new to capture. Blank means the device was not reporting. Devices report every 60 seconds, so a change can take up to two minutes to show. Teal = unlocked, purple = locked.",
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (instance) (chronos_session_locked{instance=~\"$instance\"})",
          "legendFormat": "{{instance}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "mappings": [
            {
              "type": "value",
              "options": {
                "0": {
                  "text": "unlocked",
                  "color": "#2f9e9e",
                  "index": 0
                },
                "1": {
                  "text": "locked",
                  "color": "#a371f7",
                  "index": 1
                }
              }
            }
          ],
          "color": {
            "mode": "thresholds"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "#2f9e9e",
                "value": null
              },
              {
                "color": "#a371f7",
                "value": 1
              }
            ]
          },
          "custom": {
            "fillOpacity": 80,
            "lineWidth": 0
          }
        },
        "overrides": []
      },
      "options": {
        "showValue": "never",
        "mergeValues": true,
        "rowHeight": 0.5,
        "legend": {
          "showLegend": false
        },
        "tooltip": {
          "mode": "single"
        }
      },
      "maxDataPoints": 500,
      "id": 19,
      "gridPos": {
        "x": 0,
        "y": 48,
        "w": 24,
        "h": 4
      }
    },
    {
      "type": "timeseries",
      "title": "monitors in use and recorded",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "description": "Monitors connected to the selected devices, and how many of them were being recorded (monitors on a device that is paused or outside recording hours are not recorded). Bars show monitors plugged in or unplugged. Devices report every 60 seconds, so a change can take up to two minutes to show.",
      "interval": "5m",
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "sum(chronos_monitors_active{instance=~\"$instance\"})",
          "legendFormat": "monitors in use"
        },
        {
          "refId": "B",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "sum(chronos_monitors_active{instance=~\"$instance\"} * on (instance) (chronos_recording_state{instance=~\"$instance\",state=\"recording\"}))",
          "legendFormat": "monitors recorded"
        },
        {
          "refId": "C",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "sum(increase(chronos_monitors_changes_total{instance=~\"$instance\",event=~\"added|removed\"}[$__interval]))",
          "legendFormat": "monitors plugged in or unplugged"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "none",
          "custom": {
            "lineWidth": 2,
            "fillOpacity": 15,
            "showPoints": "never"
          },
          "min": 0,
          "decimals": 0
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "monitors in use"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "blue"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "monitors recorded"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "green"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "monitors plugged in or unplugged"
            },
            "properties": [
              {
                "id": "custom.drawStyle",
                "value": "bars"
              },
              {
                "id": "custom.fillOpacity",
                "value": 60
              },
              {
                "id": "custom.axisPlacement",
                "value": "right"
              },
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "#8b949e"
                }
              },
              {
                "id": "custom.axisSoftMax",
                "value": 3
              }
            ]
          }
        ]
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi"
        }
      },
      "id": 20,
      "gridPos": {
        "x": 0,
        "y": 52,
        "w": 12,
        "h": 8
      }
    },
    {
      "type": "timeseries",
      "title": "monitor-minutes recorded per hour",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "description": "Minutes of screen recording saved per hour, per device. A device with two screens adds the minutes of both. A recording is counted when its video file is finished, so the latest hour fills in a few minutes late. Devices report every 60 seconds, so a change can take up to two minutes to show.",
      "interval": "1h",
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "sum by (instance) (increase(chronos_video_chunk_encoded_duration_seconds_total{instance=~\"$instance\"}[1h])) / 60",
          "legendFormat": "{{instance}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "m",
          "custom": {
            "drawStyle": "bars",
            "fillOpacity": 80,
            "lineWidth": 1,
            "showPoints": "never",
            "stacking": {
              "mode": "normal",
              "group": "A"
            }
          },
          "min": 0,
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi"
        }
      },
      "id": 21,
      "gridPos": {
        "x": 12,
        "y": 52,
        "w": 12,
        "h": 8
      }
    },
    {
      "type": "bargauge",
      "title": "time per state",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "description": "Hours the selected devices spent in each state over the time range shown. Counted from the 60 second check-ins, so missed check-ins make it read a little low, and time a device was asleep or off is not included.",
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "sum by (state) (sum_over_time(chronos_recording_state{instance=~\"$instance\"}[$__range])) / 60",
          "legendFormat": "{{state}}",
          "instant": true,
          "range": false
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "suffix: h",
          "decimals": 1,
          "min": 0,
          "color": {
            "mode": "fixed",
            "fixedColor": "blue"
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "recording"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "green"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "paused_by_user"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "paused"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "off_by_schedule"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "outside recording hours"
              },
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "light-blue"
                }
              }
            ]
          }
        ]
      },
      "options": {
        "orientation": "horizontal",
        "displayMode": "basic",
        "showUnfilled": true,
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "id": 22,
      "gridPos": {
        "x": 0,
        "y": 60,
        "w": 12,
        "h": 6
      }
    },
    {
      "type": "timeseries",
      "title": "pauses and resumes per hour",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "description": "How often recording was paused and resumed per hour on the selected devices, from any source: the user, the recording schedule starting or ending, or an automatic resume. Devices report every 60 seconds, so a change can take up to two minutes to show.",
      "interval": "1h",
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "sum by (event) (increase(chronos_recording_transitions_total{instance=~\"$instance\"}[1h]))",
          "legendFormat": "{{event}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "none",
          "custom": {
            "drawStyle": "bars",
            "fillOpacity": 80,
            "lineWidth": 1,
            "showPoints": "never",
            "stacking": {
              "mode": "normal",
              "group": "A"
            }
          },
          "min": 0,
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi"
        }
      },
      "id": 23,
      "gridPos": {
        "x": 12,
        "y": 60,
        "w": 12,
        "h": 6
      }
    }
  ]
}
