beacon

module
v0.3.0-rc.10 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0

README

Beacon · 烽火

English | 简体中文

CI Release Go Report Card

Documentation: beacon.openlinkos.com

Beacon is infrastructure for AI agents that run operations. It tells whether your services work for your users, checked from where they are; it lets agents reach your machines over SSH without ever holding a key, and records every session; and it puts the people on call and their agents on one platform. A Go service and a small probe agent, on top of VictoriaMetrics and vmalert. What it aims at, and what it leaves out, is in docs/goals.md.

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. Agents already work through it in production: they see alerts with their evidence, reach enrolled machines with their own ssh and the MCP tools without holding a key, and every session is on record; probes from several locations feed the alerts. Being built now: the first agent on call end to end (a reference harness and probing on demand), the pages people open from a card, machines behind NAT, and a reference deployment for other teams.

What it does

Sees: monitoring
  • 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, probe modules and settings (a longer timeout for a machine on a lossy path, say), 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.
  • 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), when a standby node steps in, and when the rotation holds a node nobody watches.
Reaches: the SSH channel
  • Agents use the tools they know. ssh, scp, sftp, rsync and port forwarding go through Beacon unchanged, and MCP tools run commands and read and edit files with clean, structured results.
  • No keys for agents. Beacon holds the credentials and signs a certificate valid for a few minutes for each connection; machines trust only Beacon's certificate authority.
  • Every session on record. Sessions are recorded for replay, and interactive shells are broken down into commands with their exit status. Deciding what to run is the agent's own business; people see everything it does and can pause agents at once.
  • Machines behind NAT connect out. A machine Beacon cannot reach runs plain ssh -R to the channel with a key enrolled for it, and Beacon reaches its sshd through that connection; nothing is installed on the machine.
Connects: the platform
  • An API and MCP for agents. List alerts, acknowledge, silence and end silences, leave notes, with scoped tokens that expire. Every write is audited and echoed to the alert chat, so what an agent did is visible to everyone.
  • Agents woken, with the evidence at hand. A new alert can wake an agent: a signed webhook or a GitHub workflow, told where the evidence is. One call returns it: each probe location's result and why it fails, the alerts in the same failure domain, the changes just before (deployments, Flux), and what was done. Notes an agent leaves show on the card, and one timeline joins alerts, notes, agents woken, changes and sessions. Beacon calls no model: the agent decides. See docs/agents.md.
  • An agent on call, end to end. linkos-oncall, a small third binary, catches the hook, checks its signature and starts the agent program you name, with wrappers for Claude Code and Codex and a GitHub Actions example. When the agent has fixed something, probe_now has every location probe the target again and shows each answer within a minute, and the alert resolves sooner. Agents' tokens renew themselves before they expire, so nobody hands out long-lived ones.
  • One place for people: the console. Sign in at / with a token and see everything: alerts with their evidence and timeline, machines and the channel's pause switch, every session with its replay, tokens, the configuration and its history, the agents woken, the audit log. From the card in the chat, a signed link opens the alert's page without signing in. No login system of Beacon's own: the token is the identity, and it is the same design system as the rest of the OpenLinkOS family. See docs/pages.md.
  • Configured through Beacon. Probe locations, heartbeats, expiring resources, probe targets and modules live in Beacon's database and are changed through the API, MCP and the command line, checked and in force at once. Every change is a version with who made it and the values before and after, and can be reverted; files are for import and export, so they can still live in git.
  • 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
                                                                                                    ├─▶ agents' hooks (webhook, GitHub workflow)
                                   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 -p 17002:17002 \
  -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, all described in docs/catalog.md. The first start imports those files into the database, where they are changed from then on; the two mounts are needed only for that, for SIGHUP and for config import. Port 17001 serves the API and MCP, and the console people sign in to with a token at / (over HTTPS, or on localhost), with the pages a card links to (/alerts/{id}, /sessions/{id} with the replay; signed links; docs/pages.md); port 17006 is the gateway for machines; port 17002 is the SSH channel, set up as in docs/ssh.md.

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, machines 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,machines:ssh -expires 90d \
  -ssh-key "$(cat ~/.ssh/id_ed25519.pub)"                 # the key it signs in to the SSH channel with
docker exec linkos-beacon linkos-beacon token list
docker exec linkos-beacon linkos-beacon machine add edge-1 edge-1.example.net   # pins its host key, prints what the machine needs
docker exec linkos-beacon linkos-beacon machine add nas-1 connector -key "ssh-ed25519 AAAA…"   # behind NAT: it connects out with ssh -R
docker exec linkos-beacon linkos-beacon ssh pause         # closes agents' sessions on machines until "ssh resume"
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
docker exec linkos-beacon linkos-beacon config import /etc/linkos-beacon -dry-run   # catalog/, targets/: what would change
docker exec linkos-beacon linkos-beacon config export /tmp/beacon   # the configuration as files, in the same layout
docker exec linkos-beacon linkos-beacon config history    # who changed what; config revert VERSION undoes one change

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 for alerts: status_summary, list_alerts, get_alert, list_silences, list_audit, ack_alert, silence_alert, expire_silence. For working an alert: get_evidence, get_timeline, add_note, list_changes, probe_now. For machines: list_machines, run_command, read_file, write_file, edit_file, list_sessions, get_session, add_machine, set_machine_connector, remove_machine, pause_ssh, resume_ssh. For the configuration (scope config:write to change it): get_config, put_config, delete_config, list_config_changes, get_config_change, revert_config_change. For the agent's own token: whoami, renew_token.
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, GET /api/v1/agent probe:write What the probe checks, how, and its location's settings
GET /api/v1/agent/requests, POST /api/v1/agent/requests/{id} probe:write Probing on demand: the probe long-polls for targets to probe now, and posts what it found; see docs/agents.md
POST /api/v2/alerts the rule engine's token, alerts:send Alerts, in Alertmanager's API v2 form
POST /api/v1/changes, POST /api/v1/changes/flux changes:write Change events: deployments and the like, and Flux's events (its generic provider); see docs/agents.md
GET /api/v1/query, query_range, series, … metrics:read Metric queries for agents

The SSH channel (port 17002) takes keys given to tokens with the machines:ssh scope; the user name is the machine. See docs/ssh.md.

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: monitoring with alert delivery on Feishu and phones, the SSH channel through which agents reach machines, a REST API and an MCP server.
Command linkos-beacon is Beacon's service: monitoring with alert delivery on Feishu and phones, the SSH channel through which agents reach machines, a REST API and an MCP server.
linkos-oncall command
Command linkos-oncall is the reference harness that runs an agent when Beacon wakes it.
Command linkos-oncall is the reference harness that runs an agent when Beacon wakes it.
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 the alerts and the people on call.
Package bridge closes the loop between the alerts and the people on call.
catalog
Package catalog is 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 is 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.
configdb
Package configdb keeps what Beacon monitors in its database: the catalogue (probe locations, heartbeats, expiring resources), the probe targets in named sets that keep the meaning of the file names they came from (all-, overseas-, mainland-, <location>-), and the probe module file.
Package configdb keeps what Beacon monitors in its database: the catalogue (probe locations, heartbeats, expiring resources), the probe targets in named sets that keep the meaning of the file names they came from (all-, overseas-, mainland-, <location>-), and the probe module file.
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 …`, `machine …`, `ssh …`, `config …` and `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 …`, `machine …`, `ssh …`, `config …` and `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, the rule engine and Flux post alerts (Alertmanager's API v2, taken by the router), and CI and Flux post change events (deployments, reconciliations).
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, the rule engine and Flux post alerts (Alertmanager's API v2, taken by the router), and CI and Flux post change events (deployments, reconciliations).
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.
oncall
Package oncall is the reference harness that runs an agent program when Beacon wakes it.
Package oncall is the reference harness that runs an agent program when Beacon wakes it.
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.
probenow
Package probenow is probing on demand: an agent asks the centre to have a target probed again at once, every probe location that has the target assigned is woken through the gateway's long-poll route, probes it with its usual modules and settings and posts what it found, and the agent sees each location's answer within a minute instead of waiting for the next cycle and the rule engine.
Package probenow is probing on demand: an agent asks the centre to have a target probed again at once, every probe location that has the target assigned is woken through the gateway's long-poll route, probes it with its usual modules and settings and posts what it found, and the agent sees each location's answer within a minute instead of waiting for the next cycle and the rule engine.
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.
sshgate
Package sshgate is the SSH channel: agents reach the machines Beacon knows with the tools they already use (ssh, scp, sftp, rsync, port forwarding) or with the MCP and REST tools, and never hold a key.
Package sshgate is the SSH channel: agents reach the machines Beacon knows with the tools they already use (ssh, scp, sftp, rsync, port forwarding) or with the MCP and REST tools, and never hold a key.
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 machines the SSH channel reaches, the index of SSH sessions, 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 machines the SSH channel reaches, the index of SSH sessions, the audit log and small counters.
targets
Package targets is what the probes check: target groups in Prometheus file_sd form ({targets, labels}), in named files (sets, once they are in Beacon's database; see package configdb).
Package targets is what the probes check: target groups in Prometheus file_sd form ({targets, labels}), in named files (sets, once they are in Beacon's database; see package configdb).
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.
web
Package web serves what people look at: the console, Beacon's own workbench, and the pages people open from the chat (an alert's page, with its timeline and the sessions on its machines, and a session's page, with its replay).
Package web serves what people look at: the console, Beacon's own workbench, and the pages people open from the chat (an alert's page, with its timeline and the sessions on its machines, and a session's page, with its replay).
web/link
Package link signs the links to the pages people open from the chat, and checks them.
Package link signs the links to the pages people open from the chat, and checks them.

Jump to

Keyboard shortcuts

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