Skip to content

feat: changes to creating sync.yml and retrieving data monitoring histories - #37

Open
adnannpm wants to merge 17 commits into
devfrom
feat/sync
Open

feat: changes to creating sync.yml and retrieving data monitoring histories#37
adnannpm wants to merge 17 commits into
devfrom
feat/sync

Conversation

@adnannpm

Copy link
Copy Markdown
Collaborator

No description provided.

@RyanRiz RyanRiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. buat response api yang jelas ketika agent membaca sync.yml dan request ke plugin. isinya bisa:
  • Current monitor status
  • URL
  • Status code
  • Response time
  • Certificate expiration
  • Last up/down/check times
  • Accurate daily uptime statistics
  • Enough history for the Laravel charts
  1. saat ini data yang dikirim cuma max 100 ke master. lalu di master dihitung history per-90 hari. harusnya langsung dihitung dari uptime-go karena memiliki akses data secara langsung, jadi laravel master hanya meload hasil generate summary
  2. jangan generate sync.yml pakai relative runtime path. bisa buat init command yang menggenerate required folder, configs, etc. supaya bisa dijalankan oleh ansible saat install dan update
  3. tambahlan:
params:
  with_stat: true

ke sync, karena jika di request saat ini hasilnya:

[
  {
    "url": "https://example.com",
    "is_up": true,
    "status_code": 200,
    "response_time": 120,
    "histories": []
  }
]

history nya kosong, jadi harusnya seperti:

[
  {
    "url": "https://example.com",
    "enabled": true,
    "is_up": true,
    "status_code": 200,
    "response_time": 120,
    "last_check": "2026-07-20T11:00:00Z",
    "stats": [
      {
        "date": "2026-07-19",
        "uptime_percentage": 99.65,
        "total_checks": 288
      },
      {
        "date": "2026-07-20",
        "uptime_percentage": 100,
        "total_checks": 132
      }
    ],
    "histories": []
  }
]

@RyanRiz

RyanRiz commented Jul 23, 2026

Copy link
Copy Markdown
Contributor
  1. The binary can panic before the first uptime check.

    handlers.go uses:

    IsUp: *m.IsUp,

    Monitor.IsUp is nullable. A newly created monitor may have nil, causing a nil-pointer panic.

    Preserve null/unknown status using *bool, or check for nil before dereferencing.

  2. History retrieval remains expensive and uneven.

    handlers.goloads every raw check from the last 90 days to calculate statistics on every sync request. Meanwhile, database.go applies one LIMIT 100 preload across multiple monitors, so some monitors may receive little or no recent history.

    Fix:

    • Calculate daily statistics using grouped SQL or stored daily summaries.
    • Load a defined recent history sample per monitor, not one shared limit.

Additional defects

  1. Single-monitor statistics use the wrong error condition at handlers.go. Statistics are calculated only when GetHistoryWithMonitor() returns an error; it should calculate on success and return an error response on failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants