Compare commits
19 Commits
ee13c8d094
...
dev_1.0.0_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6d49ea562 | ||
|
|
5211769ba8 | ||
|
|
28ef5df6e4 | ||
|
|
687d29993a | ||
|
|
54185101f0 | ||
|
|
018cdb40cc | ||
|
|
36290bb08f | ||
|
|
d514283cda | ||
|
|
bfa1d71c49 | ||
|
|
cb659f581b | ||
|
|
55f9317a1b | ||
|
|
f305a65abf | ||
|
|
46c34f3de6 | ||
|
|
8e2d751c2c | ||
|
|
ab44edc22f | ||
|
|
586740a17a | ||
|
|
5fa6e80578 | ||
|
|
e941537dd5 | ||
|
|
4fb8652177 |
@@ -2,7 +2,7 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
ES_HOST="${ELASTICSEARCH_HOSTS:-http://es:9200}"
|
ES_HOST="${ELASTICSEARCH_HOSTS:-http://es:9200}"
|
||||||
KB_HOST="${KB_HOST:-http://127.0.0.1:5601}"
|
KB_HOST="http://localhost:5601"
|
||||||
|
|
||||||
echo "[INFO] Starting Kibana post-start configuration..."
|
echo "[INFO] Starting Kibana post-start configuration..."
|
||||||
|
|
||||||
@@ -83,37 +83,50 @@ fix_replicas_idempotent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# 幂等创建数据视图
|
# 幂等创建数据视图
|
||||||
create_or_ensure_data_view() {
|
|
||||||
local name="$1"
|
|
||||||
local title="$2"
|
|
||||||
|
|
||||||
local list_response
|
|
||||||
list_response=$(curl -fsS "$KB_HOST/api/data_views" -H 'kbn-xsrf: true' 2>/dev/null || echo "")
|
|
||||||
|
|
||||||
if [ -z "$list_response" ]; then
|
|
||||||
echo "[WARN] Failed to list data views, skipping creation check for $title"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if echo "$list_response" | grep -Fq "\"title\":\"$title\""; then
|
|
||||||
echo "[INFO] Data view $title already exists, skipping"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "[INFO] Creating data view for $title indices (allowNoIndex)"
|
|
||||||
|
|
||||||
curl -fsS -X POST "$KB_HOST/api/data_views/data_view?allowNoIndex=true" \
|
|
||||||
-H 'kbn-xsrf: true' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d "{\"data_view\":{\"name\":\"$name\",\"title\":\"$title\",\"timeFieldName\":\"@timestamp\",\"allowNoIndex\":true}}" \
|
|
||||||
>/dev/null && echo "[OK] Created $name data view" || echo "[WARN] Failed to create $name data view"
|
|
||||||
}
|
|
||||||
|
|
||||||
create_data_views_idempotent() {
|
create_data_views_idempotent() {
|
||||||
echo "[INFO] Checking and creating data views..."
|
echo "[INFO] Checking and creating data views..."
|
||||||
|
|
||||||
create_or_ensure_data_view "train" "train-*"
|
# 检查是否存在匹配的索引
|
||||||
create_or_ensure_data_view "infer" "infer-*"
|
local train_indices=$(curl -s "$ES_HOST/_cat/indices/train-*?h=index" 2>/dev/null | wc -l || echo "0")
|
||||||
|
local infer_indices=$(curl -s "$ES_HOST/_cat/indices/infer-*?h=index" 2>/dev/null | wc -l || echo "0")
|
||||||
|
|
||||||
|
# 创建 train 数据视图
|
||||||
|
if [ "$train_indices" -gt 0 ]; then
|
||||||
|
# 检查数据视图是否已存在
|
||||||
|
local train_exists=$(curl -s "$KB_HOST/api/data_views" -H 'kbn-xsrf: true' 2>/dev/null | grep '"title":"train-\*"' | wc -l )
|
||||||
|
|
||||||
|
if [ "$train_exists" -eq 0 ]; then
|
||||||
|
echo "[INFO] Creating data view for train-* indices"
|
||||||
|
curl -fsS -X POST "$KB_HOST/api/data_views/data_view" \
|
||||||
|
-H 'kbn-xsrf: true' \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '{"data_view":{"name":"train","title":"train-*","timeFieldName":"@timestamp"}}' \
|
||||||
|
>/dev/null && echo "[OK] Created train data view" || echo "[WARN] Failed to create train data view"
|
||||||
|
else
|
||||||
|
echo "[INFO] Train data view already exists, skipping"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "[INFO] No train-* indices found, skipping train data view creation"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 创建 infer 数据视图
|
||||||
|
if [ "$infer_indices" -gt 0 ]; then
|
||||||
|
# 检查数据视图是否已存在
|
||||||
|
local infer_exists=$(curl -s "$KB_HOST/api/data_views" -H 'kbn-xsrf: true' 2>/dev/null | grep '"title":"infer-\*"' | wc -l )
|
||||||
|
|
||||||
|
if [ "$infer_exists" -eq 0 ]; then
|
||||||
|
echo "[INFO] Creating data view for infer-* indices"
|
||||||
|
curl -fsS -X POST "$KB_HOST/api/data_views/data_view" \
|
||||||
|
-H 'kbn-xsrf: true' \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '{"data_view":{"name":"infer","title":"infer-*","timeFieldName":"@timestamp"}}' \
|
||||||
|
>/dev/null && echo "[OK] Created infer data view" || echo "[WARN] Failed to create infer data view"
|
||||||
|
else
|
||||||
|
echo "[INFO] Infer data view already exists, skipping"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "[INFO] No infer-* indices found, skipping infer data view creation"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# 主逻辑
|
# 主逻辑
|
||||||
|
|||||||
@@ -115,32 +115,20 @@ show_step "Health" "Check service health"
|
|||||||
echo "[INFO] Checking service health..."
|
echo "[INFO] Checking service health..."
|
||||||
|
|
||||||
# 检查 Elasticsearch 健康状态
|
# 检查 Elasticsearch 健康状态
|
||||||
health_check_ok=1
|
|
||||||
es_health=$(curl -s "http://localhost:9200/_cluster/health" | grep -o '"status":"[^"]*"' | cut -d'"' -f4)
|
es_health=$(curl -s "http://localhost:9200/_cluster/health" | grep -o '"status":"[^"]*"' | cut -d'"' -f4)
|
||||||
if [ "$es_health" = "green" ] || [ "$es_health" = "yellow" ]; then
|
if [ "$es_health" = "green" ] || [ "$es_health" = "yellow" ]; then
|
||||||
echo "✅ Elasticsearch health: $es_health"
|
echo "✅ Elasticsearch health: $es_health"
|
||||||
else
|
else
|
||||||
echo "❌ Elasticsearch health: $es_health"
|
echo "❌ Elasticsearch health: $es_health"
|
||||||
health_check_ok=0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 检查 Kibana 状态
|
# 检查 Kibana 状态
|
||||||
if curl -fs "http://localhost:5601/api/status" >/dev/null 2>&1; then
|
if curl -fs "http://localhost:5601/api/status" >/dev/null 2>&1; then
|
||||||
kb_status="available"
|
kb_status="available"
|
||||||
echo "✅ Kibana status: $kb_status"
|
echo "✅ Kibana status: $kb_status"
|
||||||
|
|
||||||
data_views_json=$(curl -fs "http://localhost:5601/api/data_views" -H 'kbn-xsrf: true' 2>/dev/null || true)
|
|
||||||
if echo "$data_views_json" | grep -F '"title":"train-*"' >/dev/null 2>&1 && \
|
|
||||||
echo "$data_views_json" | grep -F '"title":"infer-*"' >/dev/null 2>&1; then
|
|
||||||
echo "✅ Kibana data views: train-* and infer-* present"
|
|
||||||
else
|
|
||||||
echo "❌ Kibana data views missing: train-* or infer-*"
|
|
||||||
health_check_ok=0
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
kb_status="unavailable"
|
kb_status="unavailable"
|
||||||
echo "⚠️ Kibana status: $kb_status"
|
echo "⚠️ Kibana status: $kb_status"
|
||||||
health_check_ok=0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 检查 Fluent-Bit 指标
|
# 检查 Fluent-Bit 指标
|
||||||
@@ -151,13 +139,6 @@ if [ "$fb_host01_uptime" -gt 0 ] && [ "$fb_host02_uptime" -gt 0 ]; then
|
|||||||
echo "✅ Fluent-Bit services: host01 uptime=${fb_host01_uptime}s, host02 uptime=${fb_host02_uptime}s"
|
echo "✅ Fluent-Bit services: host01 uptime=${fb_host01_uptime}s, host02 uptime=${fb_host02_uptime}s"
|
||||||
else
|
else
|
||||||
echo "⚠️ Fluent-Bit services: host01 uptime=${fb_host01_uptime}s, host02 uptime=${fb_host02_uptime}s"
|
echo "⚠️ Fluent-Bit services: host01 uptime=${fb_host01_uptime}s, host02 uptime=${fb_host02_uptime}s"
|
||||||
health_check_ok=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$health_check_ok" -eq 1 ]; then
|
|
||||||
true
|
|
||||||
else
|
|
||||||
false
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
verify_step "Service health check"
|
verify_step "Service health check"
|
||||||
|
|||||||
Reference in New Issue
Block a user