Prometheus metrics endpoint
Nội dung này hiện chưa có sẵn bằng ngôn ngữ của bạn.
MZPanel already collects a heartbeat from every server’s agent (about every 10 seconds) and
the result of every uptime check. GET /v1/api/metrics/prometheus hands that data to your
own monitoring stack in the Prometheus text format, so Prometheus, Grafana Agent / Alloy,
VictoriaMetrics or any other scraper can pull the whole fleet from one URL. Nothing is
installed on the boxes and a scrape never reaches an agent: it reads what the control plane
already holds. It works on every plan.
Set it up, step by step
Section titled “Set it up, step by step”- Open Advanced → Developer (
/developer) and click Create token. - Label it (e.g.
Prometheus scraper) and pick the Read only ability. Read is all the endpoint needs. - Optional: under Servers, choose specific servers to expose only those. Leave All servers if you also want the uptime-monitor metrics (see What you get).
- Optional but recommended: fill Allowed IPs with your Prometheus server’s public address (one address or CIDR block per line), so the token is useless anywhere else.
- Click Create token and copy the
mzmcp_…value (it is shown once). - Add a scrape job to your Prometheus config:
scrape_configs: - job_name: mzpanel scheme: https metrics_path: /v1/api/metrics/prometheus scrape_interval: 60s authorization: type: Bearer credentials_file: /etc/prometheus/mzpanel.token # the mzmcp_… value static_configs: - targets: ['api.mzpanel.com']Reload Prometheus and check Status → Targets: the mzpanel job should be UP. To
test by hand:
curl -s https://api.mzpanel.com/v1/api/metrics/prometheus \ -H "Authorization: Bearer mzmcp_YOUR_TOKEN" | head -20What you get
Section titled “What you get”Every server sample carries the labels server_id (the server UUID) and server (its
name). Values are the agent’s last heartbeat; when an agent is offline its last values
stay and mzpanel_server_online drops to 0.
| Metric | Meaning |
|---|---|
mzpanel_server_info{agent_version} | Always 1; carries the agent version |
mzpanel_server_online | 1 while the agent is connected, 0 otherwise |
mzpanel_server_last_seen_timestamp_seconds | Unix time of the last heartbeat |
mzpanel_server_cpu_usage_percent, mzpanel_server_cpu_cores | CPU usage (all cores) and core count |
mzpanel_server_memory_used_bytes, mzpanel_server_memory_total_bytes | Memory |
mzpanel_server_swap_used_bytes, mzpanel_server_swap_total_bytes | Swap |
mzpanel_server_disk_used_bytes{mount}, mzpanel_server_disk_total_bytes{mount} | Disk per mount point (/ from the heartbeat, other mounts from the storage inventory, refreshed every few minutes) |
mzpanel_server_load1, mzpanel_server_load5, mzpanel_server_load15 | Load averages |
mzpanel_server_network_receive_bytes_per_second, mzpanel_server_network_transmit_bytes_per_second | Network rate over the last heartbeat interval |
mzpanel_server_uptime_seconds | Seconds since boot |
mzpanel_server_processes | Running processes |
mzpanel_uptime_monitor_up{monitor_id,monitor,type,target} | 1 up, 0 down; absent while a monitor is paused or has no verdict yet |
mzpanel_uptime_monitor_paused | 1 when the monitor is paused |
mzpanel_uptime_monitor_response_time_seconds | Response time of the last check |
mzpanel_uptime_monitor_last_check_timestamp_seconds | Unix time of the last check |
mzpanel_scrape_timestamp_seconds | When this response was generated |
A metric the agent did not report (an older agent, a box without swap) is left out rather
than sent as 0.
Which servers appear. Agent-managed servers the token can see: its server allowlist (if any), narrowed by the team role and site grants of the user who minted it. Agentless (SSH-only) servers have no heartbeat and are not listed. Uptime monitors are workspace-wide, so they appear only for a token without a server allowlist whose owner can see the whole workspace.
Example alerts
Section titled “Example alerts”groups: - name: mzpanel rules: - alert: MZPanelServerOffline expr: mzpanel_server_online == 0 for: 5m - alert: MZPanelDiskAlmostFull expr: mzpanel_server_disk_used_bytes / mzpanel_server_disk_total_bytes > 0.9 for: 15m - alert: MZPanelMonitorDown expr: mzpanel_uptime_monitor_up == 0 for: 2mGotchas & troubleshooting
Section titled “Gotchas & troubleshooting”- Scrape every 30–60 s. The heartbeat arrives about every 10 s, so faster scrapes add nothing. Each scrape counts as one request against the token’s per-minute rate limit.
401 unauthorized: theAuthorization: Bearer mzmcp_…header is missing, or the token is revoked or expired.403 token_ip_denied: the token has an Allowed IPs list and the scraper’s address is not on it. The message names the address the request came from; add it on the Developer page (edit the token).- Metrics look stale for one server: check
mzpanel_server_onlineandmzpanel_server_last_seen_timestamp_seconds; an offline agent keeps its last values. - No
mzpanel_uptime_monitor_*series: the token has a server allowlist, or you have no monitors yet.
Related
Section titled “Related”- Developer & API keys — creating and editing tokens.
- Tokens, levels & scopes — server and IP allowlists.
- Monitoring — the same metrics in the dashboard, with history.
- Uptime — the monitors behind
mzpanel_uptime_monitor_*.