Extreme Thinking
用AI 修護遠端 ELK 過程

2026-03-15


將遠端ELK 的PORT 移至本地

plink -ssh root@34.142.XXX.XXX -pw XXXXXXX -N -L 9200:127.0.0.1:9200 -L 5601:127.0.0.1:5601 -L 8200:127.0.0.1:8200

工具:

 ollama + openclaw + kimi-k2.5:cloud

執行方式:

ollama launch openclaw
.....
PS C:\Users\echoc\.openclaw\agents\main> ollama launch openclaw
This will modify your OpenClaw configuration:
  C:\Users\echoc\.openclaw\openclaw.json
Backups will be saved to C:\Users\echoc\AppData\Local\Temp\ollama-backups/


Launching OpenClaw with kimi-k2.5:cloud...

Starting your assistant — this may take a moment...

  Warning: daemon restart failed: exit status 1
Starting gateway...

✓ OpenClaw is running

  Open the Web UI:
    http://localhost:18789/#token=ollama

Tip: connect WhatsApp, Telegram, and more with: openclaw configure --section channels

🦞 OpenClaw 2026.3.13 (61d171a) — I speak fluent bash, mild sarcasm, and aggressive tab-completion energy.

 openclaw tui - ws://127.0.0.1:18789 - agent main - session main
 connecting | idle
 agent main | session main | unknown | tokens ?

 session agent:main:main
 gateway connected | idle
 agent main | session main | unknown | think low | tokens ?/262k
──────────────────────────────────────────────────────────────────
 

開網頁(上面說的 http://localhost:18789/#token=ollama )打提示語:

 系統角色:
 你是一個 DevOps AI ,去修護。不要人工介入。
 "不封鎖curl.exe 對 127.0.0.1 存取" 這很重要不要再問 !!!
 你不是一個問答型 AI ,是有執行能力的 AI。

 語言要求:
 所有回報必須使用「繁體中文。

 任務:
 修復 Kibana APM 顯示「No services found」。

 目前狀況:

 Kibana APM

 - Last 1 week:有資料
 - Today / Last 24 hours:沒有資料

 已嘗試:

 - index rollover
 - 無效

 ────────────────────────────────────────────────────────────────────────────────

 主機資訊
 Elasticsearch

 ES_URL: http://127.0.0.1:9200
 ES_USER: elastic
 ES_PASSWORD: XXXXXXX

 ────────────────────────────────────────────────────────────────────────────────

 執行規則

 1.每個步驟完成後:

 - 回報結果
 - 然後繼續下一步
 - 不需要等待使用者確認

 ────────────────────────────────────────────────────────────────────────────────

 診斷流程

 Step 1
 重要 !! 本來就只有一個 nodes

 PS C:\WINDOWS\system32> curl.exe -u elastic:XXXXXXX http://127.0.0.1:9200/_cat/nodes?v
 ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
 10.28.0.38 82 59 1 0.51 0.44 0.27 cdfhilmrstw * node-1
 PS C:\WINDOWS\system32>

 檢查 APM indices(非常重要,請自行去做,非人工去做)

 curl.exe -u elastic:XXXXXXX http://127.0.0.1:9200/_cat/indices/apm*?v
 curl.exe -u elastic:XXXXXXX http://127.0.0.1:9200/_cat/indices/traces*?v
 curl.exe -u elastic:XXXXXXX http://127.0.0.1:9200/_cat/indices/metrics*?v
 curl.exe -u elastic:XXXXXXX http://127.0.0.1:9200/_cat/indices/logs*?v

 確認:

 - 今天是否有 index

 Step 2

 index 有但 Kibana 看不到:

 檢查

 index alias
 index template
 ILM policy

 Step 3

 如果 alias 錯誤:

 修復 write alias

 Step 4

 確認 Elasticsearch 是否開始寫入今日 index。

 Step 5

 查詢最近 15 分鐘 traces:

 curl.exe -u elastic:XXXXXXX http://127.0.0.1:9200/traces*/_search?pretty

 Step 6

 確認 Kibana APM Today 是否可以看到 Service。

 Step 7
 是否修護完成沒有請自行找方法修護

 Step 8
 查驗是否修護,沒好再修護,再查驗,再修護

 ────────────────────────────────────────────────────────────────────────────────

 任務完成後請輸出:

 1
 問題原因

 2
 修復方法

 3
 驗證結果

運作AI 回應的

 收到,開始執行 DevOps 修復流程。

 Step 1: 檢查 APM Indices

 執行檢查今日是否有 index:

 Step 1 結果:

 發現問題!檢查 indices 發現:
 - ✅ 有舊的 APM indices(apm-ez-production-*)
 - ⚠️ 最新的 span index 是 apm-ez-production-span-000063(只有 8,057 docs)                                                                                                                                                                 
 - ⚠️ 但 transaction 已經到 000068,且 000065-000067 都是空的(0 docs)                                                                                                                                                                     
 - ⚠️ 存在舊版 apm-7.17.25-* indices(yellow 狀態)                                                                                                                                                                                         

 這表示 rollover 可能發生了問題,新的 indices 沒有正確寫入資料。

 ────────────────────────────────────────────────────────────────────────────────

 Step 2: 檢查 Index Alias、Template 和 ILM Policy


 Step 2 結果:

 發現關鍵問題!Alias 配置看起來正確,但讓我檢查 index template 和今天的資料:

 Step 2 結果:

 ✅ 發現重要資訊:
 - apm-ez-production-transaction-000068 有資料(429,273 docs),最新 timestamp 是 2026-03-15T12:10:55.363Z(今天)
 - apm-ez-production-span-000064 有資料(1,427,860 docs)
 - apm-ez-production-metric-000063 有資料(40,937 docs)

 但 transaction-000065 到 000067 是空的,這表示 rollover 發生了但資料沒有寫入到這些 indices。

 ────────────────────────────────────────────────────────────────────────────────

 Step 3: 檢查 traces-apm alias 和 Kibana 使用的索引模式


 Step 3 結果:

 🚨 發現關鍵問題!

 transaction-000064 到 000067 這些 indices 沒有 @timestamp mapping!這表示:
 1. 這些 indices 被 rollover 創建但沒有正確的 mapping
 2. 它們是空的(0 docs)
 3. 這導致 Kibana APM 查詢時出現錯誤

 但最新的 000068 有資料且 mapping 正確。

 讓我檢查這些空 indices 的 mapping:

 確認問題!

 - apm-ez-production-transaction-000064 到 000067:沒有 @timestamp mapping
 - apm-ez-production-transaction-000068:有 @timestamp mapping

 這些空的 indices 導致 Kibana APM 查詢失敗!

 ────────────────────────────────────────────────────────────────────────────────

 Step 4: 修復 - 刪除有問題的空 indices


 Step 5 結果:

 ✅ 查詢成功! 現在沒有 shard failures 了!
 - 最新資料時間:2026-03-15T12:11:57.017Z(今天)
 - Service: admin-system

 讓我查詢最近 15 分鐘的 traces 來確認資料持續寫入:

 Step 6 結果:

 ✅ 資料正常! 最近 1 小時有 18 個 Services:
 - admin-system (7,705)
 - ez-game-publisher-bridge-system (5,610)
 - client-gateway (3,689)
 - ez-cash-server (981)
 - ... 等等

完工手工驗證