{
  "title": "Immich",
  "icon": "photo.on.rectangle",
  "sources": {
    "server": {
      "url": "http://192.0.2.40:2283",
      "secret": "immich",
      "auth": {
        "type": "header",
        "name": "x-api-key"
      },
      "every": "1m",
      "requests": {
        "stats": "/api/server/statistics",
        "storage": "/api/server/storage",
        "queues": "/api/queues",
        "about": "/api/server/about",
        "check": "/api/server/version-check"
      },
      "derive": [
        {
          "name": "q_failed",
          "value": {
            "each": "queues",
            "where": {
              "path": "statistics.failed",
              "gt": 0
            },
            "fields": {
              "name": "name",
              "text": {
                "path": "name",
                "values": {
                  "thumbnailGeneration": {
                    "template": "Thumbnails"
                  },
                  "metadataExtraction": {
                    "template": "Extract metadata"
                  },
                  "videoConversion": {
                    "template": "Transcode videos"
                  },
                  "faceDetection": {
                    "template": "Face detection"
                  },
                  "facialRecognition": {
                    "template": "Facial recognition"
                  },
                  "smartSearch": {
                    "template": "Smart search"
                  },
                  "duplicateDetection": {
                    "template": "Duplicate detection"
                  },
                  "backgroundTask": {
                    "template": "Background tasks"
                  },
                  "storageTemplateMigration": {
                    "template": "Storage template"
                  },
                  "migration": {
                    "template": "Migration"
                  },
                  "search": {
                    "template": "Search"
                  },
                  "sidecar": {
                    "template": "Sidecar metadata"
                  },
                  "library": {
                    "template": "External libraries"
                  },
                  "notifications": {
                    "template": "Notifications"
                  },
                  "backupDatabase": {
                    "template": "Database backup"
                  },
                  "ocr": {
                    "template": "Text recognition"
                  },
                  "workflow": {
                    "template": "Workflows"
                  },
                  "integrityCheck": {
                    "template": "Integrity check"
                  },
                  "editor": {
                    "template": "Editor"
                  }
                },
                "default": {
                  "template": "{name}"
                }
              },
              "busy": {
                "add": [
                  "statistics.active",
                  "statistics.waiting"
                ]
              },
              "failed": "statistics.failed",
              "paused": "isPaused",
              "detail": {
                "if": {
                  "path": "isPaused",
                  "equals": true
                },
                "then": {
                  "if": {
                    "path": "statistics.failed",
                    "gt": 0
                  },
                  "then": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "Paused · {statistics.waiting} waiting · {statistics.failed} failed"
                    },
                    "else": {
                      "template": "Paused · {statistics.failed} failed"
                    }
                  },
                  "else": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "Paused · {statistics.waiting} waiting"
                    },
                    "else": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "Paused · {statistics.active} running"
                      },
                      "else": {
                        "template": "Paused"
                      }
                    }
                  }
                },
                "else": {
                  "if": {
                    "path": "statistics.failed",
                    "gt": 0
                  },
                  "then": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "{statistics.waiting} waiting · {statistics.failed} failed"
                    },
                    "else": {
                      "template": "{statistics.failed} failed"
                    }
                  },
                  "else": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "{statistics.waiting} waiting · {statistics.active} running"
                      },
                      "else": {
                        "template": "{statistics.waiting} waiting"
                      }
                    },
                    "else": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "{statistics.active} running"
                      },
                      "else": {
                        "template": "Idle"
                      }
                    }
                  }
                }
              },
              "failed_words": {
                "if": {
                  "path": "statistics.failed",
                  "equals": 1
                },
                "then": {
                  "template": "1 failed job"
                },
                "else": {
                  "template": "{statistics.failed} failed jobs"
                }
              }
            }
          }
        },
        {
          "name": "q_paused",
          "value": {
            "each": "queues",
            "where": {
              "all": [
                {
                  "path": "isPaused",
                  "equals": true
                },
                {
                  "path": "statistics.failed",
                  "equals": 0
                },
                {
                  "any": [
                    {
                      "path": "statistics.active",
                      "gt": 0
                    },
                    {
                      "path": "statistics.waiting",
                      "gt": 0
                    }
                  ]
                }
              ]
            },
            "fields": {
              "name": "name",
              "text": {
                "path": "name",
                "values": {
                  "thumbnailGeneration": {
                    "template": "Thumbnails"
                  },
                  "metadataExtraction": {
                    "template": "Extract metadata"
                  },
                  "videoConversion": {
                    "template": "Transcode videos"
                  },
                  "faceDetection": {
                    "template": "Face detection"
                  },
                  "facialRecognition": {
                    "template": "Facial recognition"
                  },
                  "smartSearch": {
                    "template": "Smart search"
                  },
                  "duplicateDetection": {
                    "template": "Duplicate detection"
                  },
                  "backgroundTask": {
                    "template": "Background tasks"
                  },
                  "storageTemplateMigration": {
                    "template": "Storage template"
                  },
                  "migration": {
                    "template": "Migration"
                  },
                  "search": {
                    "template": "Search"
                  },
                  "sidecar": {
                    "template": "Sidecar metadata"
                  },
                  "library": {
                    "template": "External libraries"
                  },
                  "notifications": {
                    "template": "Notifications"
                  },
                  "backupDatabase": {
                    "template": "Database backup"
                  },
                  "ocr": {
                    "template": "Text recognition"
                  },
                  "workflow": {
                    "template": "Workflows"
                  },
                  "integrityCheck": {
                    "template": "Integrity check"
                  },
                  "editor": {
                    "template": "Editor"
                  }
                },
                "default": {
                  "template": "{name}"
                }
              },
              "busy": {
                "add": [
                  "statistics.active",
                  "statistics.waiting"
                ]
              },
              "failed": "statistics.failed",
              "paused": "isPaused",
              "detail": {
                "if": {
                  "path": "isPaused",
                  "equals": true
                },
                "then": {
                  "if": {
                    "path": "statistics.failed",
                    "gt": 0
                  },
                  "then": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "Paused · {statistics.waiting} waiting · {statistics.failed} failed"
                    },
                    "else": {
                      "template": "Paused · {statistics.failed} failed"
                    }
                  },
                  "else": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "Paused · {statistics.waiting} waiting"
                    },
                    "else": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "Paused · {statistics.active} running"
                      },
                      "else": {
                        "template": "Paused"
                      }
                    }
                  }
                },
                "else": {
                  "if": {
                    "path": "statistics.failed",
                    "gt": 0
                  },
                  "then": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "{statistics.waiting} waiting · {statistics.failed} failed"
                    },
                    "else": {
                      "template": "{statistics.failed} failed"
                    }
                  },
                  "else": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "{statistics.waiting} waiting · {statistics.active} running"
                      },
                      "else": {
                        "template": "{statistics.waiting} waiting"
                      }
                    },
                    "else": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "{statistics.active} running"
                      },
                      "else": {
                        "template": "Idle"
                      }
                    }
                  }
                }
              },
              "failed_words": {
                "if": {
                  "path": "statistics.failed",
                  "equals": 1
                },
                "then": {
                  "template": "1 failed job"
                },
                "else": {
                  "template": "{statistics.failed} failed jobs"
                }
              }
            }
          }
        },
        {
          "name": "q_working",
          "value": {
            "each": "queues",
            "where": {
              "all": [
                {
                  "path": "isPaused",
                  "equals": false
                },
                {
                  "path": "statistics.failed",
                  "equals": 0
                },
                {
                  "any": [
                    {
                      "path": "statistics.active",
                      "gt": 0
                    },
                    {
                      "path": "statistics.waiting",
                      "gt": 0
                    }
                  ]
                }
              ]
            },
            "sort": {
              "by": "statistics.waiting",
              "order": "desc"
            },
            "fields": {
              "name": "name",
              "text": {
                "path": "name",
                "values": {
                  "thumbnailGeneration": {
                    "template": "Thumbnails"
                  },
                  "metadataExtraction": {
                    "template": "Extract metadata"
                  },
                  "videoConversion": {
                    "template": "Transcode videos"
                  },
                  "faceDetection": {
                    "template": "Face detection"
                  },
                  "facialRecognition": {
                    "template": "Facial recognition"
                  },
                  "smartSearch": {
                    "template": "Smart search"
                  },
                  "duplicateDetection": {
                    "template": "Duplicate detection"
                  },
                  "backgroundTask": {
                    "template": "Background tasks"
                  },
                  "storageTemplateMigration": {
                    "template": "Storage template"
                  },
                  "migration": {
                    "template": "Migration"
                  },
                  "search": {
                    "template": "Search"
                  },
                  "sidecar": {
                    "template": "Sidecar metadata"
                  },
                  "library": {
                    "template": "External libraries"
                  },
                  "notifications": {
                    "template": "Notifications"
                  },
                  "backupDatabase": {
                    "template": "Database backup"
                  },
                  "ocr": {
                    "template": "Text recognition"
                  },
                  "workflow": {
                    "template": "Workflows"
                  },
                  "integrityCheck": {
                    "template": "Integrity check"
                  },
                  "editor": {
                    "template": "Editor"
                  }
                },
                "default": {
                  "template": "{name}"
                }
              },
              "busy": {
                "add": [
                  "statistics.active",
                  "statistics.waiting"
                ]
              },
              "failed": "statistics.failed",
              "paused": "isPaused",
              "detail": {
                "if": {
                  "path": "isPaused",
                  "equals": true
                },
                "then": {
                  "if": {
                    "path": "statistics.failed",
                    "gt": 0
                  },
                  "then": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "Paused · {statistics.waiting} waiting · {statistics.failed} failed"
                    },
                    "else": {
                      "template": "Paused · {statistics.failed} failed"
                    }
                  },
                  "else": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "Paused · {statistics.waiting} waiting"
                    },
                    "else": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "Paused · {statistics.active} running"
                      },
                      "else": {
                        "template": "Paused"
                      }
                    }
                  }
                },
                "else": {
                  "if": {
                    "path": "statistics.failed",
                    "gt": 0
                  },
                  "then": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "{statistics.waiting} waiting · {statistics.failed} failed"
                    },
                    "else": {
                      "template": "{statistics.failed} failed"
                    }
                  },
                  "else": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "{statistics.waiting} waiting · {statistics.active} running"
                      },
                      "else": {
                        "template": "{statistics.waiting} waiting"
                      }
                    },
                    "else": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "{statistics.active} running"
                      },
                      "else": {
                        "template": "Idle"
                      }
                    }
                  }
                }
              },
              "failed_words": {
                "if": {
                  "path": "statistics.failed",
                  "equals": 1
                },
                "then": {
                  "template": "1 failed job"
                },
                "else": {
                  "template": "{statistics.failed} failed jobs"
                }
              }
            }
          }
        },
        {
          "name": "q_idle",
          "value": {
            "each": "queues",
            "where": {
              "all": [
                {
                  "path": "statistics.failed",
                  "equals": 0
                },
                {
                  "path": "statistics.active",
                  "equals": 0
                },
                {
                  "path": "statistics.waiting",
                  "equals": 0
                }
              ]
            },
            "fields": {
              "name": "name",
              "text": {
                "path": "name",
                "values": {
                  "thumbnailGeneration": {
                    "template": "Thumbnails"
                  },
                  "metadataExtraction": {
                    "template": "Extract metadata"
                  },
                  "videoConversion": {
                    "template": "Transcode videos"
                  },
                  "faceDetection": {
                    "template": "Face detection"
                  },
                  "facialRecognition": {
                    "template": "Facial recognition"
                  },
                  "smartSearch": {
                    "template": "Smart search"
                  },
                  "duplicateDetection": {
                    "template": "Duplicate detection"
                  },
                  "backgroundTask": {
                    "template": "Background tasks"
                  },
                  "storageTemplateMigration": {
                    "template": "Storage template"
                  },
                  "migration": {
                    "template": "Migration"
                  },
                  "search": {
                    "template": "Search"
                  },
                  "sidecar": {
                    "template": "Sidecar metadata"
                  },
                  "library": {
                    "template": "External libraries"
                  },
                  "notifications": {
                    "template": "Notifications"
                  },
                  "backupDatabase": {
                    "template": "Database backup"
                  },
                  "ocr": {
                    "template": "Text recognition"
                  },
                  "workflow": {
                    "template": "Workflows"
                  },
                  "integrityCheck": {
                    "template": "Integrity check"
                  },
                  "editor": {
                    "template": "Editor"
                  }
                },
                "default": {
                  "template": "{name}"
                }
              },
              "busy": {
                "add": [
                  "statistics.active",
                  "statistics.waiting"
                ]
              },
              "failed": "statistics.failed",
              "paused": "isPaused",
              "detail": {
                "if": {
                  "path": "isPaused",
                  "equals": true
                },
                "then": {
                  "if": {
                    "path": "statistics.failed",
                    "gt": 0
                  },
                  "then": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "Paused · {statistics.waiting} waiting · {statistics.failed} failed"
                    },
                    "else": {
                      "template": "Paused · {statistics.failed} failed"
                    }
                  },
                  "else": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "Paused · {statistics.waiting} waiting"
                    },
                    "else": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "Paused · {statistics.active} running"
                      },
                      "else": {
                        "template": "Paused"
                      }
                    }
                  }
                },
                "else": {
                  "if": {
                    "path": "statistics.failed",
                    "gt": 0
                  },
                  "then": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "template": "{statistics.waiting} waiting · {statistics.failed} failed"
                    },
                    "else": {
                      "template": "{statistics.failed} failed"
                    }
                  },
                  "else": {
                    "if": {
                      "path": "statistics.waiting",
                      "gt": 0
                    },
                    "then": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "{statistics.waiting} waiting · {statistics.active} running"
                      },
                      "else": {
                        "template": "{statistics.waiting} waiting"
                      }
                    },
                    "else": {
                      "if": {
                        "path": "statistics.active",
                        "gt": 0
                      },
                      "then": {
                        "template": "{statistics.active} running"
                      },
                      "else": {
                        "template": "Idle"
                      }
                    }
                  }
                }
              },
              "failed_words": {
                "if": {
                  "path": "statistics.failed",
                  "equals": 1
                },
                "then": {
                  "template": "1 failed job"
                },
                "else": {
                  "template": "{statistics.failed} failed jobs"
                }
              }
            }
          }
        },
        {
          "name": "failed_total",
          "value": {
            "sum": "statistics.failed",
            "of": "queues",
            "default": 0
          }
        },
        {
          "name": "busy_total",
          "value": {
            "sum": "busy",
            "of": "q_working",
            "default": 0
          }
        },
        {
          "name": "failed_first",
          "value": {
            "first": "text",
            "of": "q_failed"
          }
        },
        {
          "name": "failed_queues",
          "value": {
            "count": "q_failed",
            "default": 0
          }
        },
        {
          "name": "shown",
          "value": {
            "each": [
              "q_failed",
              "q_paused",
              "q_working"
            ],
            "fields": {
              "name": "name"
            }
          }
        },
        {
          "name": "shown_count",
          "value": {
            "count": "shown",
            "default": 0
          }
        },
        {
          "name": "disk_pct",
          "value": {
            "path": "storage.diskUsagePercentage",
            "round": 0
          }
        },
        {
          "name": "running",
          "value": {
            "path": "about.version",
            "match": "^v?(.+)$"
          }
        },
        {
          "name": "latest",
          "value": {
            "path": "check.releaseVersion",
            "match": "^v?(.+)$"
          }
        }
      ]
    },
    "library": {
      "url": "http://192.0.2.40:2283",
      "secret": "immich",
      "auth": {
        "type": "header",
        "name": "x-api-key"
      },
      "every": "15m",
      "requests": {
        "buckets": "/api/timeline/buckets?visibility=timeline",
        "latest": {
          "path": "/api/search/metadata",
          "method": "POST",
          "body": {
            "size": 4,
            "type": "IMAGE",
            "visibility": "timeline",
            "order": "desc"
          }
        }
      }
    }
  },
  "cards": [
    {
      "id": "server",
      "type": "status",
      "placement": "page_info",
      "label": "Immich",
      "state": "unknown",
      "width": "full",
      "source": {
        "ref": "server",
        "map": {
          "state": {
            "if": {
              "any": [
                {
                  "path": "failed_total",
                  "gt": 0
                },
                {
                  "path": "storage.diskUsagePercentage",
                  "gte": 90
                }
              ]
            },
            "then": {
              "template": "warning"
            },
            "else": {
              "template": "ok"
            }
          },
          "detail": {
            "if": {
              "path": "failed_total",
              "gt": 0
            },
            "then": {
              "if": {
                "path": "failed_queues",
                "gt": 1
              },
              "then": {
                "template": "{failed_total} failed jobs in {failed_queues} queues · disk {disk_pct}% used"
              },
              "else": {
                "if": {
                  "path": "failed_total",
                  "equals": 1
                },
                "then": {
                  "template": "1 failed job · {failed_first} · disk {disk_pct}% used"
                },
                "else": {
                  "template": "{failed_total} failed jobs · {failed_first} · disk {disk_pct}% used"
                }
              }
            },
            "else": {
              "if": {
                "path": "busy_total",
                "equals": 1
              },
              "then": {
                "template": "Processing 1 job · disk {disk_pct}% used"
              },
              "else": {
                "if": {
                  "path": "busy_total",
                  "gt": 0
                },
                "then": {
                  "template": "Processing {busy_total} jobs · disk {disk_pct}% used"
                },
                "else": {
                  "template": "{stats.photos} photos · {stats.videos} videos · disk {disk_pct}% used"
                }
              }
            }
          }
        },
        "failed": {
          "state": "critical",
          "detail": "Can't read Immich's status",
          "after": 3
        }
      }
    },
    {
      "id": "months",
      "type": "columns",
      "label": "Taken each month",
      "series": [
        "Photos and videos"
      ],
      "items": [],
      "source": {
        "ref": "library",
        "map": {
          "items": {
            "each": "buckets",
            "by_month": {
              "at": "timeBucket",
              "months": 12
            },
            "fields": {
              "label": {
                "template": "{from|month}"
              },
              "values[0]": {
                "sum": "count",
                "of": "rows"
              }
            }
          }
        }
      }
    },
    {
      "id": "library",
      "type": "facts",
      "label": "Library",
      "source": {
        "ref": "server",
        "map": {
          "items[0].value": {
            "template": "{stats.usage|bytes}"
          },
          "items[1].value": {
            "template": "{storage.diskUseRaw|bytes} of {storage.diskSizeRaw|bytes} · {disk_pct}%"
          },
          "items[2].value": {
            "if": {
              "all": [
                {
                  "path": "latest",
                  "exists": true
                },
                {
                  "path": "latest",
                  "not": {
                    "path": "running"
                  }
                }
              ]
            },
            "then": {
              "template": "{running} · {latest} is out"
            },
            "else": {
              "template": "{running}"
            }
          },
          "items[3].value": {
            "template": "{stats.photos}"
          },
          "items[4].value": {
            "template": "{stats.videos}"
          }
        }
      },
      "items": [
        {
          "key": "Library size",
          "value": "—"
        },
        {
          "key": "Disk",
          "value": "—"
        },
        {
          "key": "Version",
          "value": "—"
        },
        {
          "key": "Photos",
          "value": "—"
        },
        {
          "key": "Videos",
          "value": "—"
        }
      ]
    },
    {
      "id": "processing",
      "type": "list",
      "label": "Processing",
      "max_items": 7,
      "items": [],
      "source": {
        "ref": "server",
        "empty": {
          "text": "Nothing processing",
          "when": {
            "path": "shown_count",
            "equals": 0
          }
        },
        "map": {
          "items": {
            "each": [
              "q_failed",
              "q_paused",
              "q_working"
            ],
            "fields": {
              "text": "text",
              "detail": "detail",
              "url": {
                "template": "legato://page/immich-jobs"
              }
            }
          }
        }
      }
    },
    {
      "id": "latest",
      "type": "list",
      "label": "Latest photos",
      "layout": "shelf",
      "max_items": 4,
      "image_shape": "square",
      "items": [],
      "source": {
        "ref": "library",
        "empty": {
          "text": "No photos yet",
          "when": {
            "path": "latest.assets.count",
            "equals": 0
          }
        },
        "map": {
          "items": {
            "each": "latest.assets.items",
            "fields": {
              "text": {
                "template": "{fileCreatedAt|day}"
              },
              "image": {
                "template": "/api/assets/{id|raw}/thumbnail?size=thumbnail"
              },
              "url": {
                "template": "http://192.0.2.40:2283/photos/{id|raw}"
              }
            }
          }
        }
      }
    },
    {
      "id": "explore",
      "type": "list",
      "label": "Explore",
      "items": [
        {
          "text": "Jobs",
          "url": "legato://page/immich-jobs"
        },
        {
          "text": "Albums",
          "url": "legato://page/immich-albums"
        }
      ]
    }
  ]
}
