Last9
官方無縫地將即時生產環境上下文——日誌、指標和追蹤——帶入您的本地環境,以更快地自動修復程式碼。
你可以用 Last9 MCP 做什麼?
請您的助理使用 Last9 的即時日誌、追蹤和指標來調查生產事故。
- 排名服務健康狀態 — 使用
get_service_summary查看整個服務群組的請求數、吞吐量以及 4xx/5xx 錯誤。 - 找出緩慢的資料庫查詢 — 使用
get_database_slow_queries提取實際最慢的執行記錄及其追蹤 ID,以便深入調查。 - 取得服務日誌 — 使用
get_service_logs根據嚴重性和內容篩選原始日誌行。 - 追蹤單一請求 — 使用
get_trace_waterfall查看特定追蹤 ID 的父/子瀑布圖。 - 檢查警示狀態 — 使用
get_alert_rule_state查看一段時間內每個警示規則的觸發歷史。 - 管理儀表板 — 使用
create_dashboard透過面板和查詢建立自訂儀表板。
文件
Last9 MCP Server

您的 AI 代理不知道生產環境哪裡出了問題。這個伺服器解決這個問題。
Last9 MCP Server 將 Claude、Cursor、Windsurf 以及任何其他支援 MCP 的 AI 助理直接連接到您的生產可觀測性資料 — 日誌、指標、追蹤、例外、資料庫查詢、警示和部署。代理不再猜測,而是開始讀取實際訊號。
30 秒內開始(託管版)
無需安裝二進位檔。無需管理權杖。一個 URL,在瀏覽器中完成 OAuth,搞定。
在您的 Last9 URL 中找到您的組織 slug:app.last9.io/<org_slug>/...
Claude Code
claude mcp add --transport http last9 https://app.last9.io/api/v4/organizations/<org_slug>/mcp
輸入 /mcp,選擇 last9,進行驗證。就這樣。
Cursor
設定 > MCP > 新增 MCP 伺服器:
{
"mcpServers": {
"last9": {
"type": "http",
"url": "https://app.last9.io/api/v4/organizations/<org_slug>/mcp"
}
}
}
點擊連線,完成 OAuth。
VS Code
需要 v1.99+。開啟命令面板 → MCP: 新增伺服器,貼上 URL,進行驗證。
或直接在 settings.json 中:
{
"mcp": {
"servers": {
"last9": {
"type": "http",
"url": "https://app.last9.io/api/v4/organizations/<org_slug>/mcp"
}
}
}
}
Windsurf
設定 > Cascade > 開啟 MCP Marketplace > 齒輪圖示(mcp_config.json):
{
"mcpServers": {
"last9": {
"serverUrl": "https://app.last9.io/api/v4/organizations/<org_slug>/mcp"
}
}
}
Claude Web/Desktop
設定 > 連接器 > 新增自訂連接器。 將其命名為 last9,貼上 URL,進行驗證。
需要您 Claude 組織的管理員存取權限。
自架(STDIO)
當您的 MCP 用戶端不支援 HTTP 傳輸,或您需要在本地執行伺服器時,請使用此方式。
安裝
Homebrew:
brew install last9/tap/last9-mcp
NPM:
npm install -g @last9/mcp-server@latest
# or directly:
npx -y @last9/mcp-server@latest
二進位版本(Windows / 手動):
從 GitHub Releases 下載:
| 平台 | 封存檔 |
|---|---|
| Windows (x64) | last9-mcp-server_Windows_x86_64.zip |
| Windows (ARM64) | last9-mcp-server_Windows_arm64.zip |
| Linux (x64) | last9-mcp-server_Linux_x86_64.tar.gz |
| Linux (ARM64) | last9-mcp-server_Linux_arm64.tar.gz |
| macOS (x64) | last9-mcp-server_Darwin_x86_64.tar.gz |
| macOS (ARM64) | last9-mcp-server_Darwin_arm64.tar.gz |
取得重新整理權杖
只有管理員可以建立權杖。
- 前往 API Access
- 點擊產生權杖並具有寫入權限
- 複製它
用戶端設定
Homebrew:
{
"mcpServers": {
"last9": {
"command": "/opt/homebrew/bin/last9-mcp",
"env": {
"LAST9_REFRESH_TOKEN": "<your_refresh_token>"
}
}
}
}
NPM:
{
"mcpServers": {
"last9": {
"command": "npx",
"args": ["-y", "@last9/mcp-server@latest"],
"env": {
"LAST9_REFRESH_TOKEN": "<your_refresh_token>"
}
}
}
}
要貼到哪裡:
| 用戶端 | 位置 |
|---|---|
| Claude Web/Desktop | 設定 > 開發人員 > 編輯設定(claude_desktop_config.json) |
| Cursor | 設定 > Cursor 設定 > MCP > 新增全域 MCP 伺服器 |
| Windsurf | 設定 > Cascade > MCP Marketplace > 齒輪圖示(mcp_config.json) |
| VS Code | 在 settings.json 中包裝在 { "mcp": { "servers": { ... } } } 中 — 詳細資訊 |
VS Code STDIO 設定
{
"mcp": {
"servers": {
"last9": {
"type": "stdio",
"command": "/opt/homebrew/bin/last9-mcp",
"env": {
"LAST9_REFRESH_TOKEN": "<your_refresh_token>"
}
}
}
}
}
對於 NPM:使用 "command": "npx" 並新增 "args": ["-y", "@last9/mcp-server@latest"]。
Windows
從 GitHub Releases 下載後,解壓縮並指向完整路徑:
{
"mcpServers": {
"last9": {
"command": "C:\\Users\\<user>\\AppData\\Local\\Programs\\last9-mcp-server.exe",
"env": {
"LAST9_REFRESH_TOKEN": "<your_refresh_token>"
}
}
}
}
在 Windows 上使用 NPM 方式更簡單 — 無需管理路徑。
環境變數
| 變數 | 預設值 | 說明 |
|---|---|---|
LAST9_REFRESH_TOKEN | (必填) | 來自 API Access 的重新整理權杖 |
LAST9_DATASOURCE | 組織預設值 | 資料來源/叢集名稱 — 當您有多個 Levitate 叢集時很有用 |
LAST9_API_HOST | app.last9.io | 覆寫 API 主機 |
LAST9_TOOLSETS | 所有工具 | 要公開的以逗號分隔的工具集(logs、traces、metrics、alerts、dashboards、investigate、all)。別名:LAST9_MCP_TOOLSETS |
LAST9_MAX_GET_LOGS_ENTRIES | 5000 | 分塊 get_logs 請求的最大條目數 |
LAST9_DEBUG_CHUNKING | false | 設定 true 以記錄 get_logs、get_service_logs、get_traces 的分塊規劃詳細資訊 |
LAST9_DISABLE_TELEMETRY | true | 設定 false 以啟用內部 OTel 追蹤 |
OTEL_SDK_DISABLED | — | 標準 OTel 環境變數。覆寫 LAST9_DISABLE_TELEMETRY |
OTEL_EXPORTER_OTLP_ENDPOINT | — | OTLP 收集器端點(僅在啟用遙測時) |
OTEL_EXPORTER_OTLP_HEADERS | — | OTLP 驗證標頭(僅在啟用遙測時) |
它能做什麼
服務健康狀態
get_service_summary— 排名艦隊(service, env)列:間隔 request_count、throughput_rpm、HTTP 4xx/5xx 計數和 gRPC 錯誤計數get_service_environments— 您服務的可用環境。先執行此工具 — 其他 APM 工具需要從這裡取得envget_service_performance_details— 完整細分:吞吐量、錯誤率、p50/p90/p95/平均/最大、apdex、可用性get_service_operations_summary— 按 HTTP 端點、資料庫呼叫、訊息傳遞、HTTP 用戶端分組的操作get_service_dependency_graph— 依賴關係圖,包含上游/下游/基礎設施的吞吐量、延遲和錯誤率get_apm_service_deviations— 將目前時間視窗與等時長基準進行比較:回歸/改善、Apdex 對帳和最終結果(艦隊或單一服務)get_exceptions— 具有服務和跨度篩選器的伺服器端例外
資料庫可觀測性
四個直接針對資料庫效能的工具,源自 OpenTelemetry 追蹤跨度。如果您已經在使用 OTel,則無需額外的儀器化。
get_databases— 探索您基礎設施中的所有資料庫:資料庫類型、主機、吞吐量(查詢/分鐘)、p95 延遲、錯誤率、依賴服務數量get_database_slow_queries— 實際最慢的查詢執行,按持續時間排序,附有追蹤 ID 以便深入查看完整追蹤get_database_queries— 查詢模式和聚合:查詢執行頻率、平均/p95 持續時間、錯誤率get_database_server_metrics— 來自資料庫主機本身的伺服器端指標(CPU、連線數、緩衝區命中率 — 取決於您的資料庫系統)
支援 PostgreSQL、MySQL、MongoDB、Redis、Aerospike,以及任何其他帶有 db_system 屬性的 OTel 追蹤。
Prometheus / PromQL
prometheus_range_query— 對任何指標執行 PromQL 範圍查詢prometheus_instant_query— 即時查詢;使用如avg_over_time、sum_over_time的彙總函數prometheus_label_values— 給定序列的標籤值prometheus_labels— 序列可用的所有標籤
透過設定 LAST9_DATASOURCE 將這些指向與預設不同的資料來源/叢集。
日誌
get_logs— 完整的 JSON 管線日誌查詢(聚合、篩選、欄位提取)get_service_logs— 服務的原始日誌行,可按嚴重性和內容進行篩選get_log_attributes— 時間視窗內日誌架構中屬性的全域目錄get_log_attributes_for_pipeline— 進行中管線實際存在的日誌欄位(範圍探索),每個都帶有其精確的filter_fieldget_drop_rules— 來自 Last9 Control Plane 的日誌丟棄規則add_drop_rule— 建立新的丟棄規則以從源頭減少日誌量
追蹤
get_traces— 用於廣泛搜尋和聚合的 JSON 管線追蹤查詢get_service_traces— 按精確追蹤 ID 或服務名稱查詢追蹤。當您有追蹤 ID 時使用此工具 — 速度更快get_trace_attributes— 追蹤架構中屬性的全域目錄get_trace_attributes_for_pipeline— 進行中管線實際存在的屬性(範圍探索),每個都帶有其精確的filter_fieldget_trace_attribute_values— 追蹤屬性的不同值,可選擇性地限定在管線範圍內get_trace_attribute_deviations— 對兩個有界跨度群組之間不同的屬性值進行排名(慢 vs 快、錯誤 vs 非錯誤,或兩個時間視窗)。相關性,而非因果關係get_trace_waterfall— 單一精確追蹤的父子瀑布圖,包含區間聯集自身時間、最慢跨度和圖形警告
變更事件與警示
get_change_events— 部署、設定變更、回滾。將事件與變更內容相關聯get_alert_config— 警示規則設定 — 可按名稱、嚴重性、類型、標籤搜尋get_alerts— 時間視窗內目前觸發的警示get_alert_rule_state— 時間範圍內每個警示規則的歷史觸發狀態(1/0),按rule_id分組。可按警示群組、規則名稱、標籤篩選器和狀態進行篩選。get_notification_channels— 已設定的通知管道(Slack、PagerDuty、電子郵件等)
自訂儀表板
list_dashboards— 您組織中的所有自訂儀表板:ID、名稱和中繼資料get_dashboard— 按 ID 取得完整儀表板定義,包括面板和查詢create_dashboard— 使用面板、查詢和中繼資料建立新的自訂儀表板update_dashboard— 按 ID 更新現有儀表板(唯讀系統儀表板會回傳錯誤)delete_dashboard— 按 ID 刪除自訂儀表板list_dashboard_snapshots— 儀表板的凍結時間點快照(僅中繼資料)get_dashboard_snapshot— 包含面板資料的完整凍結快照,用於 RCA / 可分享檢視delete_dashboard_snapshot— 按 ID 刪除凍結快照
模糊名稱解析
did_you_mean— 當代理不確定實體名稱時,此工具會從您的目錄中回傳最接近的相符項目(服務、環境、主機、資料庫、K8s 部署/命名空間、工作)。最多 3 個建議,附相似度分數。當名稱查詢回傳空結果時,伺服器會在大多數工具之前自動呼叫此工具。
運作方式
每個回應上的深層連結。 每個工具都會回傳 deep_link 欄位 — 一個直接指向 Last9 儀表板中該精確查詢和時間範圍的 URL。代理可以將連結交給您;您點擊它;您就到了。
工具集。 預設情況下,伺服器公開所有工具。只需要調查(日誌/追蹤/指標)的自動化主機可以設定 LAST9_TOOLSETS=investigate(或傳遞 --toolsets=investigate),這樣 tools/list 保持精簡,無需用戶端大量停用。命名套件:logs、traces、metrics、alerts、dashboards、investigate、all。未知名稱會快速失敗。僅 metrics 套件不包含 list_datasources 或 did_you_mean — 當您需要這些探索輔助工具時,請使用 investigate(或組合工具集)。
工具參考資源。 冗長的 logjson/tracejson/service-logs/metrics 手冊是 MCP 資源(last9://reference/logjson、last9://reference/tracejson、last9://reference/service_logs、last9://reference/metrics),而非常駐的工具描述文字。關鍵查詢規則保留在工具描述中,這樣從不呼叫 resources/read 的代理仍能獲得正確的建構指導。使用 get_log_attributes / get_log_attributes_for_pipeline(以及追蹤等效工具)探索組織特定欄位 — 它們不會被注入到描述中。
分塊大型結果。 get_logs 和 get_traces 透過分塊而非截斷來處理大型結果集。日誌的預設限制為 5000 條;可透過 LAST9_MAX_GET_LOGS_ENTRIES 設定。
開發
HTTP 模式、curl 測試、從原始碼建置
以 HTTP 模式執行
export LAST9_REFRESH_TOKEN="your_refresh_token"
export LAST9_HTTP=true
export LAST9_PORT=8080
./last9-mcp-server
伺服器在 http://localhost:8080/mcp 啟動。
使用 curl 測試
Streamable HTTP handler 以無狀態模式執行,因此任何請求皆獨立處理。initialize 握手與 Mcp-Session-Id 標頭皆為選用——发送這些內容的用戶端仍可正常運作(標頭會被接受並忽略),用戶端也可以直接跳到 tools/list / tools/call。每個工具都是獨立的請求/回應查詢;伺服器不會發出伺服器→用戶端的通知,因此 GET /mcp(SSE 串流)會回傳 405。
# List tools — a session handshake is optional in stateless mode
curl -s -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}'
# Call a tool
curl -s -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "get_service_logs",
"arguments": {
"service_name": "your-service-name",
"lookback_minutes": 30,
"limit": 10
}
}
}'
從原始碼建置
git clone https://github.com/last9/last9-mcp-server.git
cd last9-mcp-server
go build -o last9-mcp-server
LAST9_HTTP=true ./last9-mcp-server
LAST9_HTTP=true 僅供本機開發使用。實際使用時,託管 HTTP 端點 較為方便。
工具參考
所有參數、時間輸入標準與詳細資訊
時間輸入
- 絕對時間(
start_time_iso/end_time_iso或time_iso)優先於lookback_minutes。 - 相對時間視窗:使用
lookback_minutes。 - 絕對時間視窗:使用 RFC3339/ISO8601 ——
2026-02-09T15:04:05Z。 - 僅為相容性而接受舊版
YYYY-MM-DD HH:MM:SS。
get_exceptions
limit(整數,選用):例外事件上限。預設值:20。lookback_minutes(整數,選用):預設值:60。start_time_iso/end_time_iso(字串,選用):絕對時間範圍。service_name(字串,選用):依服務篩選。span_name(字串,選用):依 span 名稱篩選。env(字串,選用):依環境篩選。
get_service_summary
start_time_iso/end_time_iso(字串,選用)env(字串,選用):PromQL 正規表達式。預設值為.*。精確比對需使用錨點(例如^prod$)。sort_by(字串,選用):request_count(預設)、throughput_rpm、http_4xx_count、http_5xx_count或grpc_error_count。limit(整數,選用):排名列數上限。省略或 0 表示 10;超過 100 的值會限制為 100。
get_service_environments
start_time_iso/end_time_iso(字串,選用)
其他所有 APM 工具都要求提供
env值。若此函式回傳空值,請使用""。
get_service_performance_details
service_name(字串,必填)lookback_minutes(整數,選用):預設值:60。start_time_iso/end_time_iso(字串,選用)env(字串,選用):預設值為prod。
get_service_operations_summary
service_name(字串,必填)lookback_minutes(整數,選用):預設值:60。start_time_iso/end_time_iso(字串,選用)env(字串,選用):預設值為prod。
get_service_dependency_graph
service_name(字串,選用)lookback_minutes(整數,選用):預設值:60。start_time_iso/end_time_iso(字串,選用)env(字串,選用):預設值為prod。
get_apm_service_deviations
service_name(字串,選用):省略以涵蓋整個 fleet;提供則針對單一服務及其操作關聯。lookback_minutes(整數,選用):目前視窗。預設值:60。start_time_iso/end_time_iso(字串,選用):明確的目前視窗。baseline_start_time_iso/baseline_end_time_iso(字串,選用):明確的基準線。預設為緊鄰的前一個等時長視窗。datasource(字串,選用):將比較限制在單一資料來源。env(字串,選用):預設值為prod。max_services/max_operations(整數,選用):預設 10,各自上限 10。
get_databases
env(字串,選用):依環境篩選。預設:全部。lookback_minutes(整數,選用):預設值:60。start_time_iso/end_time_iso(字串,選用)
get_database_slow_queries
db_system(字串,選用):例如postgresql、mysql、mongodb、redis。host(字串,選用):資料庫主機(net_peer_name)。service_name(字串,選用):呼叫端服務名稱。env(字串,選用)min_duration_ms(浮點數,選用):查詢時間下限(毫秒)。lookback_minutes(整數,選用):預設值:60。start_time_iso/end_time_iso(字串,選用)limit(整數,選用):預設值:20。
get_database_queries
db_system(字串,選用)host(字串,選用)service_name(字串,選用)env(字串,選用)lookback_minutes(整數,選用):預設值:60。start_time_iso/end_time_iso(字串,選用)limit(整數,選用):預設值:20。
get_database_server_metrics
db_system(字串,必填):例如postgresql、mysql、mongodb、redis、aerospike。host(字串,選用)lookback_minutes(整數,選用):預設值:60。start_time_iso/end_time_iso(字串,選用)
prometheus_range_query
query(字串,必填):PromQL 查詢。start_time_iso/end_time_iso(字串,選用):預設為最近 60 分鐘。lookback_minutes(浮點數,選用):預設值:60。
prometheus_instant_query
query(字串,必填)time_iso(字串,選用):預設為目前時間。lookback_minutes(浮點數,選用)
prometheus_label_values
match_query(字串,選用):PromQL 篩選條件。label(字串,必填):標籤名稱。start_time_iso/end_time_iso(字串,選用)
prometheus_labels
match_query(字串,選用):PromQL 篩選條件。start_time_iso/end_time_iso(字串,選用)
get_logs
logjson_query(陣列,必填):JSON pipeline 查詢。lookback_minutes(整數,選用):預設值:5。start_time_iso/end_time_iso(字串,選用)limit(整數,選用):伺服器預設值:5000。index(字串,選用):physical_index:<name>或rehydration_index:<block_name>。
若要進行以日誌為基礎的服務清單,請先查詢 physical_index_service_count:
sum by (name, service_name, env) (physical_index_service_count{destination="logs"})
使用 service_name 作為 ServiceName,在存在時使用 env 作為環境,並使用 name 作為實體索引名稱。若 name="default",請省略 index;若使用者選取了非預設的實體索引,請傳入 index: "physical_index:<name>"。若後端拒絕明確的實體索引篩選,請在不使用 index 的情況下重試,並回報該後端不支援明確的實體索引篩選。
get_service_logs
service_name(字串,必填)lookback_minutes(整數,選用):預設值:60。limit(整數,選用):預設值:20。env(字串,選用)severity_filters(陣列,選用):例如["error", "warn"]。採 OR 邏輯。body_filters(陣列,選用):例如["timeout", "failed"]。採 OR 邏輯。start_time_iso/end_time_iso(字串,選用)index(字串,選用)
多種篩選類型以 AND 結合。每個陣列內部使用 OR。
請先使用 get_logs 取得廣泛的彙總計數;僅在縮小至特定服務/環境/索引與小型樣本集之後,才使用 get_service_logs。
get_log_attributes
lookback_minutes(整數,選用):預設值:15。start_time_iso/end_time_iso(字串,選用)region(字串,選用)index(字串,選用)
get_log_attributes_for_pipeline
pipeline(陣列,必填):先前用於限定探索範圍的篩選階段,例如[{"type":"filter","query":{"$eq":["ServiceName","<service>"]}}]。lookback_minutes(整數,選用):預設值:15。start_time_iso/end_time_iso(字串,選用)region(字串,選用)index(字串,選用)
get_drop_rules
無參數。透過 GET /otel_settings/drop?region=... 列出 drop rules。
add_drop_rule
name(字串,必填)filters(陣列,必填):每個篩選條件:key、value、operator(equals/not_equals)、conjunction(and)。- 篩選鍵必須使用
attributes["key_name"]或resource.attributes["key_name"](Last9 API 所要求)。 - 透過
POST /otel_settings/drop?region=...&cluster_id=...建立規則。
get_traces
用於廣泛搜尋與彙總。若要精確查詢 trace ID,請使用 get_service_traces。
tracejson_query(陣列,必填)start_time_iso/end_time_iso(字串,選用)lookback_minutes(整數,選用):預設值:60。limit(整數,選用):預設值:5000。
get_service_traces
trace_id 或 service_name 兩者中必填其一。
trace_id(字串,選用):預設回溯時間:72 小時。service_name(字串,選用):預設回溯時間:60 分鐘。lookback_minutes(整數,選用)start_time_iso/end_time_iso(字串,選用)limit(整數,選用):預設值:10。env(字串,選用)
get_trace_attributes
lookback_minutes(整數,選用):預設值:15。start_time_iso/end_time_iso(字串,選用)region(字串,選用)
get_trace_attributes_for_pipeline
pipeline(陣列,必填):先前用於限定探索範圍的篩選階段,例如[{"type":"filter","query":{"$eq":["ServiceName","<service>"]}}]。lookback_minutes(整數,選用):預設值:15。start_time_iso/end_time_iso(字串,選用)region(字串,選用)
get_trace_attribute_values
tag_name(字串,必填):來自get_trace_attributes的屬性名稱(例如resource_department或attributes['http.method'])。pipeline(陣列,選用):先前用於限定值範圍的篩選階段;省略則取得全域值。region(字串,選用)
get_trace_attribute_deviations
comparison_mode(字串,必填):latency、errors或time。service_name(字串,必填)environment(字串,必填):精確的deployment.environment值。operation(字串,選用)filters(陣列,選用):Trace JSON 篩選條件。candidate_attributes(陣列,選用):上限 8;省略則進行有界探索。latency_threshold_ms(數字,選用):latency模式必填;其他模式則拒絕。start_time_iso/end_time_iso(字串,選用)lookback_minutes(整數,選用):預設值:15。上限:15。baseline_start_time_iso/baseline_end_time_iso(字串,選用):time模式必填;須與目標視窗不重疊且時長相等。minimum_cohort_size(整數,選用):預設值:100。下限:20。minimum_value_support(整數,選用):預設值:20。下限:10。limit(整數,選用):預設值:10。上限:10。
需要啟用配套的後端功能。
get_trace_waterfall
trace_id(字串,必填)environment(字串,選用)start_time_iso/end_time_iso(字串,選用)lookback_minutes(整數,選用):預設值:4320(72 小時)。selected_span_id(字串,選用):僅回傳該 span 的屬性、事件與連結。max_spans(整數,選用):預設值:500。上限:1000。
回傳 investigation-evidence/v1 envelope;waterfall 位於 data 之下。
get_change_events
start_time_iso/end_time_iso(字串,選用)lookback_minutes(整數,選用):預設值:60。service_name(字串,選用)env(字串,選用)event_name(字串,選用):請先在不帶此參數的情況下呼叫,以取得available_event_names。
get_alert_config
search_term(string, optional): 跨名稱、群組、資料來源、標籤進行自由文字搜尋。rule_name(string, optional)severity(string, optional)rule_type(string, optional):static或anomaly。alert_group_name/alert_group_type/data_source_name(string, optional)tags(array, optional): 所有條件都必須符合(AND 邏輯)。
get_alerts
time_iso(string, optional): RFC3339 格式的評估時間。window(integer, optional): 回顧秒數。預設值:900。範圍:60–86400。lookback_minutes(integer, optional): 範圍:1–1440。
get_alert_rule_state
start_time(integer, required): 範圍的 Unix 紀元開始時間(含)。end_time(integer, required): 範圍的 Unix 紀元結束時間(含)。step(integer, required): 樣本之間的解析度(秒)。樣本數((end_time - start_time) / step + 1)上限為 100。alert_group_id(string, optional): 依警示群組 ID 篩選。rule_name(string, optional): 對規則名稱進行正則表達式篩選。alert_group_name(string, optional): 對警示群組名稱進行正則表達式篩選。label_filters(string, optional): 以逗號分隔的key=value標籤篩選。state(string, optional): 依狀態篩選(例如firing)。
傳回 rule_id -> [{timestamp, is_firing}] 的 JSON 對應。當規則在上游回應中缺席的時間戳記會回報為 is_firing=0 — 這表示「未觀察到觸發」,而非確認的正常狀態。
get_notification_channels
無參數。傳回所有已設定的通知管道(Slack、PagerDuty、電子郵件、Webhook 等)。
did_you_mean
query(string, required): 要搜尋的名稱 — 部分、拼錯或縮寫。type(string, optional): 限制實體類型:service、environment、host、database、k8s_deployment、k8s_namespace、job。
傳回最多 3 個最接近的相符項目及相似度分數。在實體名稱不確定的任何工具呼叫之前使用此功能。如果先前的呼叫傳回空結果,請在重試前嘗試此功能。
list_dashboards
無參數。傳回組織中所有自訂儀表板,以 JSON 陣列形式,包含 id、name 及中繼資料。
get_dashboard
id(string, required): 儀表板 UUID。region(string, optional): 面板查詢填入的區域。預設為已設定的資料來源區域。
create_dashboard
dashboard(object, required): 儀表板定義,包含name和panels[]。每個面板需要name、version、layout(x、y、w、h)、visualization.type和queries[]。metadata(object, optional): 儀表板中繼資料 —_category和_type欄位(例如{"_category":"custom","_type":"metrics"})。
update_dashboard
id(string, required): 要更新的儀表板 UUID。dashboard(object, required): 完整取代的儀表板主體(與 create 相同結構)。metadata(object, optional): 取代的中繼資料。唯讀系統儀表板會傳回 403 錯誤。
delete_dashboard
id(string, required): 要刪除的儀表板 UUID。唯讀系統儀表板無法刪除。
list_dashboard_snapshots
dashboard_id(string, required): 要列出快照的儀表板 UUID。
僅傳回中繼資料(id、name、expires_at 等)。如需凍結的面板資料,請使用 get_dashboard_snapshot。
get_dashboard_snapshot
id(string, required): 快照 UUID。
傳回完整的凍結快照,包含 dashboard_definition、panel_data、time_range 和 variables。
delete_dashboard_snapshot
id(string, required): 要刪除的快照 UUID。
測試
請參閱 TESTING.md 以了解整合測試設定與說明。
