Glanceway Glanceway
所有資料來源

Service Health Check

開發者 v1.0.0

Monitor service endpoints and get notified when they go down

@codytseng #monitoring #health-check

安裝與設定方式

  1. 先在 Mac 上安裝並開啟 Glanceway,再使用上方的安裝連結。
  2. 點選「安裝到 Glanceway」。若瀏覽器無法開啟應用程式,下載 .gwsrc 檔案並在資訊源管理中匯入。
  3. 填寫以下必填欄位並儲存,設定更新間隔,等待首次成功取得內容。

設定檢查

  • URLS — 必填. URLs to monitor (e.g. https://example.com) 每個值分別作為一個清單項目新增。

沒有顯示內容時如何排查

  • 對照目前版本設定表檢查欄位、清單項目與憑證。下方範例不包含可用的真實憑證。
  • 檢查網路及上游服務狀態。認證失敗或速率限制可能使更新失敗,請依上游限制調整間隔。
  • 空清單也可能代表沒有符合條件的條目。內容與更新時間取決於資料提供方及資訊源實作。

設定項目

名稱 鍵 類型 必填 預設值 描述
Service URLs URLS list 是 — URLs to monitor (e.g. https://example.com)

原始碼

id: codytseng/service-health-check
version: 1.0.0
name: Service Health Check
description: Monitor service endpoints and get notified when they go down
author: codytseng
author_url: https://github.com/codytseng
category: Developer
tags:
  - monitoring
  - health-check

config:
  - key: URLS
    name: Service URLs
    type: list
    required: true
    description: URLs to monitor (e.g. https://example.com)
module.exports = async (api) => {
  const urls = api.config.get("URLS");

  async function fetchData() {
    if (!urls || urls.length === 0) return;

    const previousDownUrls = new Set(
      JSON.parse(api.storage.get("downUrls") ?? `[]`),
    );
    const currentDownUrls = new Set();

    await Promise.allSettled(
      urls.map(async (url) => {
        const res = await api.fetch(url);
        if (!res.ok) {
          currentDownUrls.add(url);
          if (!previousDownUrls.has(url)) {
            api.emit([
              {
                id: `${url}-${Date.now()}`,
                title: `Failed to fetch ${url}`,
                subtitle: `HTTP ${res.status}, error: ${res.error || "unknown"}`,
                url,
                timestamp: Date.now(),
              },
            ]);
          }
        }
      }),
    );

    // Store the current down URLs for the next refresh
    api.storage.set("downUrls", JSON.stringify(Array.from(currentDownUrls)));
  }

  await fetchData();

  return {
    refresh: fetchData,
  };
};

相關資料來源