beacon

module
v0.2.0-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2026 License: Apache-2.0

README

Beacon · 烽火

English | 简体中文

Beacon tells you whether your services work for your users, checked from where your users are, and closes the loop with the people on call and with their AI agents. A Go service and a small probe agent, on top of VictoriaMetrics and vmalert.

Named after the beacon towers of the Great Wall: watch posts along the border lit a fire when they saw trouble, the signal ran from tower to tower to the capital, and the number of fires told how serious it was.

Early days: Beacon runs the monitoring of LinkOS's own services. Public status pages are next.

What it does

  • Probes from where your users are. linkos-probe runs on any small machine (an edge node, a VPS in mainland China) and checks HTTP, TCP, TLS, container registries, Git over HTTP and domain expiry, like the Blackbox Exporter and with its metric names, and says why each failure happened: DNS, connect, timeout, TLS, status code, body. It reports a few host metrics and heartbeats too, and pushes everything with a queue on disk for when the network is down. One static binary, under 20 MB of memory.
  • An outage is what several locations agree on. A service is down only when at least two locations, and at least half of those reporting, fail; one location's hiccup never pages anyone. Locations follow their machines: when a machine is let go, its location stops counting.
  • One door for machines. The gateway gives each probe and host its own token (linkos-beacon enroll) and labels what it writes, so no machine can speak for another. It hands every probe its targets and probe modules, so changing what is checked needs no redeployment, and it takes heartbeats, alerts from the rule engine and Flux, and metric queries from agents.
  • Alert routing built in. Grouping, inhibition and silences, as Alertmanager does them, inside the service. Rule engines post alerts to it as they would to Alertmanager.
  • Alert cards in Feishu. A new alert becomes an interactive card in the alert chat: what is wrong, since when, which locations see it failing, and links to the runbook and the dashboard. Buttons on the card acknowledge it (with a note) or silence it for 1, 4 or 24 hours. The card changes in place, and turns green when the alert resolves.
  • Escalation to phones. A critical alert that nobody acknowledges is buzzed in the Feishu app after 10 minutes and sent to Pushover's emergency priority after 15: the phone keeps ringing until someone acknowledges it there, which also acknowledges it here. An acknowledgement lapses after 4 hours if the alert is still firing.
  • Nothing silently lost. Low-severity alerts and anything over the Feishu app's monthly API budget go to the chat's custom bot, which needs no quota. If the card cannot be sent, a critical alert goes straight to Pushover. The service pings healthchecks.io every minute while rules, routing and delivery all work, so a dead monitoring host or a broken Feishu connection still reaches a phone.
  • An API and MCP for agents. List alerts, acknowledge, silence and end silences, with scoped tokens that expire. Every write is audited and echoed to the alert chat, so what an agent did is visible to everyone.
  • CDN nodes in rotation. For probe locations on CDN nodes, Beacon notices when a node drops out of its cluster's DNS answers (up and probing, yet serving nobody), and when the rotation holds a node nobody watches.
  • Small. A whole installation is four containers (Beacon, VictoriaMetrics, vmalert, Caddy) and one binary per probe machine.

How it fits

linkos-probe (each location) ─push─▶ gateway ─▶ VictoriaMetrics ─▶ vmalert ─alerts─▶ router ─▶ bridge ─▶ Feishu app ◀─▶ people on call
hosts, CI, Flux ─────────────────▶ gateway                                                          ├─▶ Feishu group bot
agents ─▶ /api/v1, /mcp ─▶ linkos-beacon                                                            ├─▶ Pushover / Bark
                                   healthchecks.io ◀─ every minute, while rules, routing and delivery work

The gateway, the router and the bridge are all linkos-beacon. Alerts need the labels severity (critical, warning or info) and service, and the annotation summary (optionally description, runbook, dashboard). An alert named Watchdog proves the pipeline works and is never shown.

Running it

docker run -d --name linkos-beacon -p 127.0.0.1:17001:17001 -p 127.0.0.1:17006:17006 \
  -v ./config.yaml:/etc/linkos-beacon/config.yaml:ro \
  -v ./catalog:/etc/linkos-beacon/catalog:ro \
  -v ./targets:/etc/linkos-beacon/targets:ro \
  -v ./secrets:/etc/linkos-beacon/secrets:ro \
  -v linkos-beacon:/var/lib/linkos-beacon \
  ghcr.io/openlinkos/beacon:latest

Start from config.example.yaml; linkos-beacon check-config validates it, with the catalogue (probe locations, heartbeats, expiring resources), the probe targets and the module file. Port 17001 serves the API and MCP, and the status pages once they land; port 17006 is the gateway for machines.

Point vmalert at the gateway: -notifier.url=http://linkos-beacon:17006 -notifier.bearerTokenFile=<the file in rules.token_file>.

Give each probe location its token and start the agent there:

docker exec linkos-beacon linkos-beacon enroll probe edge-1 > token     # edge-1 is a location in the catalogue
linkos-probe agent -gateway https://metrics.example.com -token-file /etc/linkos-agent/token

Set up the Feishu app as in docs/feishu.md. Pushover needs its iOS app with Critical Alerts allowed, an application token and your user key.

Tokens and drills

Commands that change the running service talk to it over a socket in its data directory:

docker exec linkos-beacon linkos-beacon token create claude-code -scopes status:read,alerts:write -expires 90d
docker exec linkos-beacon linkos-beacon token list
docker exec linkos-beacon linkos-beacon enroll probe edge-1 -rotate    # a new token; the old one stops working
docker exec linkos-beacon linkos-beacon drill fail 15m    # /drill/healthz answers 503: probe it to rehearse the whole chain
docker exec linkos-beacon linkos-beacon drill off

API and MCP

  • REST: /api/v1, described in internal/api/openapi.yaml (also served at /api/v1/openapi.yaml).
  • MCP: streamable HTTP at /mcp with the same bearer tokens. Tools: status_summary, list_alerts, get_alert, list_silences, list_audit, ack_alert, silence_alert, expire_silence.
claude mcp add --transport http linkos-beacon https://status.example.com/mcp --header "Authorization: Bearer lbt_…"
Route (port 17001) Purpose
GET /healthz, GET /readyz Liveness; readiness (Watchdog seen, Feishu connection up, budget left)
GET /metrics Prometheus metrics, direct connections only
POST /hooks/feishu Feishu card callbacks when feishu.callback: http
GET /drill/healthz 200, or 503 during a drill
Gateway route (port 17006) Scope Purpose
POST /api/v1/import/prometheus probe:write, host:write, heartbeat:write Samples in the text format (what linkos-probe pushes), heartbeats
POST /api/v1/write probe:write, host:write Prometheus remote write
GET /api/v1/targets, GET /api/v1/modules probe:write What the probe checks, and how
POST /api/v2/alerts the rule engine's token, alerts:send Alerts, in Alertmanager's API v2 form
GET /api/v1/query, query_range, series, … metrics:read Metric queries for agents

Security

Tokens are stored only as SHA-256 hashes and expire; failed attempts are limited per client address. A probe or host token can only write as its own location or host, and a location whose machine has expired cannot write at all. Only the people listed in feishu.on_call can act on cards. Secrets are read from files and never logged. Report vulnerabilities to security@linkos.io.

Licence

Apache License 2.0. The LinkOS and OpenLinkOS names and marks are not covered by it.

Directories

Path Synopsis
cmd
linkos-beacon command
Command linkos-beacon is Beacon's service: status pages, alert delivery with a closed loop on Feishu and phones, a REST API and an MCP server.
Command linkos-beacon is Beacon's service: status pages, alert delivery with a closed loop on Feishu and phones, a REST API and an MCP server.
linkos-probe command
Command linkos-probe is the probe agent: it checks targets for the status service (like the Blackbox Exporter, with the same metric names, plus a failure reason and multi-step checks) and reports a few host metrics (like a small Node Exporter).
Command linkos-probe is the probe agent: it checks targets for the status service (like the Blackbox Exporter, with the same metric names, plus a failure reason and multi-step checks) and reports a few host metrics (like a small Node Exporter).
internal
agent
Package agent is linkos-probe's push mode, the whole probe agent in one process: every interval it fetches what to check from the gateway (its targets and the module file, cached on disk for when the gateway cannot be reached), probes every target, reads the host's metrics and heartbeats, and pushes it all to the gateway in the Prometheus text format with timestamps.
Package agent is linkos-probe's push mode, the whole probe agent in one process: every interval it fetches what to check from the gateway (its targets and the module file, cached on disk for when the gateway cannot be reached), probes every target, reads the host's metrics and heartbeats, and pushes it all to the gateway in the Prometheus text format with timestamps.
alertmanager
Package alertmanager holds alerts, alert groups and silences in Alertmanager's formats.
Package alertmanager holds alerts, alert groups and silences in Alertmanager's formats.
api
Package api is the REST API under /api/v1.
Package api is the REST API under /api/v1.
bridge
Package bridge closes the loop between Alertmanager and the people on call.
Package bridge closes the loop between Alertmanager and the people on call.
catalog
Package catalog loads what is monitored and where from: the probe locations, the heartbeats that jobs must send, and the resources (servers, domains, certificates, tokens) whose expiry dates are watched.
Package catalog loads what is monitored and where from: the probe locations, the heartbeats that jobs must send, and the resources (servers, domains, certificates, tokens) whose expiry dates are watched.
clientip
Package clientip extracts the client's real IP from a request.
Package clientip extracts the client's real IP from a request.
config
Package config loads the service configuration (YAML) and the secrets it names.
Package config loads the service configuration (YAML) and the secrets it names.
ctl
Package ctl is the local admin socket: a small HTTP API on a Unix socket in the data directory, so that `linkos-beacon token …` and `linkos-beacon drill …` work against the running service, which holds the database lock.
Package ctl is the local admin socket: a small HTTP API on a Unix socket in the data directory, so that `linkos-beacon token …` and `linkos-beacon drill …` work against the running service, which holds the database lock.
feishu
Package feishu is the Feishu (Lark) self-built app: it sends interactive cards to the alert group, updates them in place, buzzes people, and receives button clicks, either over Feishu's long connection (no public callback URL needed) or as HTTP callbacks.
Package feishu is the Feishu (Lark) self-built app: it sends interactive cards to the alert group, updates them in place, buzzes people, and receives button clicks, either over Feishu's long connection (no public callback URL needed) or as HTTP callbacks.
gateway
Package gateway is the one door for machines (metrics.<domain>): probes and hosts write their samples (Prometheus remote write) and fetch the targets they check, job hosts push heartbeats, agents query metrics, and the rule engine and Flux post alerts (Alertmanager's API v2, taken by the router).
Package gateway is the one door for machines (metrics.<domain>): probes and hosts write their samples (Prometheus remote write) and fetch the targets they check, job hosts push heartbeats, agents query metrics, and the rule engine and Flux post alerts (Alertmanager's API v2, taken by the router).
hostmetrics
Package hostmetrics reads a few host metrics from /proc, with the Prometheus Node Exporter's names, so that a probe machine needs no node_exporter: CPU time, memory, load, filesystems, network and disk traffic, pressure, time sync, and the heartbeat files of a textfile directory.
Package hostmetrics reads a few host metrics from /proc, with the Prometheus Node Exporter's names, so that a probe machine needs no node_exporter: CPU time, memory, load, filesystems, network and disk traffic, pressure, time sync, and the heartbeat files of a textfile directory.
i18n
Package i18n localises what people read: status pages, alert cards and API errors.
Package i18n localises what people read: status pages, alert cards and API errors.
inventory
Package inventory checks that every CDN node is serving: a probe location that runs on a CDN node names the node's address and the DNS name of its cluster (the rotation), and every minute both are resolved.
Package inventory checks that every CDN node is serving: a probe location that runs on a CDN node names the node's address and the DNS name of its cluster (the rotation), and every minute both are resolved.
mcpserver
Package mcpserver is the built-in MCP server at /mcp (streamable HTTP, stateless).
Package mcpserver is the built-in MCP server at /mcp (streamable HTTP, stateless).
metrics
Package metrics exposes metrics in the Prometheus text format.
Package metrics exposes metrics in the Prometheus text format.
notify
Package notify sends through the channels that are not the Feishu app: Pushover (iOS emergency alerts that repeat until acknowledged), Bark (an iOS push that rings), the Feishu group's custom bot (plain messages that need no app and spend no API quota), and healthchecks.io pings.
Package notify sends through the channels that are not the Feishu app: Pushover (iOS emergency alerts that repeat until acknowledged), Bark (an iOS push that rings), the Feishu group's custom bot (plain messages that need no app and spend no API quota), and healthchecks.io pings.
probe
Package probe checks targets from a probe location, the way the Prometheus Blackbox Exporter does and with the same metric names (probe_success, probe_duration_seconds, probe_http_status_code, probe_ssl_earliest_cert_expiry), so that alert rules work with either.
Package probe checks targets from a probe location, the way the Prometheus Blackbox Exporter does and with the same metric names (probe_success, probe_duration_seconds, probe_http_status_code, probe_ssl_earliest_cert_expiry), so that alert rules work with either.
router
Package router does what Alertmanager did, inside the service: it takes alerts from the rule engine (vmalert or Prometheus, Alertmanager's API v2: POST /api/v2/alerts), groups them, mutes alerts that a firing alert inhibits or that a silence matches, and hands each group to the bridge the way Alertmanager's webhook did.
Package router does what Alertmanager did, inside the service: it takes alerts from the rule engine (vmalert or Prometheus, Alertmanager's API v2: POST /api/v2/alerts), groups them, mutes alerts that a firing alert inhibits or that a silence matches, and hands each group to the bridge the way Alertmanager's webhook did.
server
Package server routes the service's HTTP requests: health and readiness, metrics (direct connections only), Feishu's HTTP callbacks, the drill check, the REST API, the MCP endpoint and the status page.
Package server routes the service's HTTP requests: health and readiness, metrics (direct connections only), Feishu's HTTP callbacks, the drill check, the REST API, the MCP endpoint and the status page.
store
Package store keeps the service's state in one bbolt file: alert groups (card, acknowledgement, silence, escalation progress), API tokens (only their SHA-256), the audit log and small counters.
Package store keeps the service's state in one bbolt file: alert groups (card, acknowledgement, silence, escalation progress), API tokens (only their SHA-256), the audit log and small counters.
targets
Package targets loads what the probes check: target groups in Prometheus file_sd form ({targets, labels}), in the YAML files of a directory.
Package targets loads what the probes check: target groups in Prometheus file_sd form ({targets, labels}), in the YAML files of a directory.
testutil
Package testutil builds a bridge with fake collaborators, for the tests of the packages above it.
Package testutil builds a bridge with fake collaborators, for the tests of the packages above it.
version
Package version holds the build information, set by the release pipeline with -ldflags -X.
Package version holds the build information, set by the release pipeline with -ldflags -X.
vm
Package vm queries VictoriaMetrics (or any Prometheus-compatible API) for instant vectors.
Package vm queries VictoriaMetrics (or any Prometheus-compatible API) for instant vectors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL