Files
Distributed-Prometheus/edge-agent/config/setup-remote-write.sh
Super User 95a09fd9d8 完善中央与边缘部署、远程写入与监控文档
- 增加中央与边缘完整配置和部署脚本
- 引入 VictoriaMetrics 数据源与 remote_write 故障排查说明
- 新增 edge-agent 配置脚本、ONVIF 自建 exporter 与 ping 监控示例

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-25 04:24:40 -05:00

64 lines
1.8 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# 设置远程推送地址脚本
# 使用方法: ./setup-remote-write.sh <中央服务器地址> [端口]
# 支持IP地址和域名
set -e
CENTRAL_HOST=${1:-"192.168.1.10"}
CENTRAL_PORT=${2:-"8428"}
CONFIG_FILE="../prometheus-edge/prometheus.yml"
echo "=== 设置Prometheus远程推送地址 ==="
echo ""
if [ -z "$1" ]; then
echo "使用方法: $0 <中央服务器地址> [端口]"
echo "示例: $0 192.168.1.10 8428"
echo " $0 prometheus.company.com"
echo " $0 prometheus.local 8428"
echo ""
read -p "请输入中央服务器地址 (IP或域名): " CENTRAL_HOST
read -p "请输入端口 (默认8428): " CENTRAL_PORT_INPUT
if [ -n "$CENTRAL_PORT_INPUT" ]; then
CENTRAL_PORT=$CENTRAL_PORT_INPUT
fi
fi
echo "🔧 配置信息:"
echo " 中央服务器地址: $CENTRAL_HOST"
echo " 端口: $CENTRAL_PORT"
echo " 配置文件: $CONFIG_FILE"
echo ""
# 检查配置文件是否存在
if [ ! -f "$CONFIG_FILE" ]; then
echo "❌ 配置文件 $CONFIG_FILE 不存在"
exit 1
fi
# 备份原配置文件
cp "$CONFIG_FILE" "${CONFIG_FILE}.backup.$(date +%Y%m%d_%H%M%S)"
echo "📋 已备份原配置文件"
# 更新配置文件中的远程推送地址
sed -i "s|http://\${CENTRAL_SERVER_HOST}:\${CENTRAL_SERVER_PORT}|http://$CENTRAL_HOST:$CENTRAL_PORT|g" "$CONFIG_FILE"
echo "✅ 远程推送地址已更新"
echo ""
# 显示更新后的配置
echo "🔍 更新后的remote_write配置"
grep -A 5 "remote_write:" "$CONFIG_FILE"
echo ""
echo "🔄 重启Prometheus服务以应用新配置"
echo " docker-compose restart prometheus-edge"
echo ""
echo "📊 检查远程写入状态:"
echo " curl http://localhost:9090/api/v1/status/config"
echo ""
echo "🔗 查看远程写入目标:"
echo " curl http://localhost:9090/api/v1/status/tsdb"