重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
alicloud-observability-openclaw-sls-integration by cinience/alicloud-skills
npx skills add https://github.com/cinience/alicloud-skills --skill alicloud-observability-openclaw-sls-integration此技能为 Linux 上的 OpenClaw 配置阿里云 SLS 可观测性,并确保重运行安全。
总体而言,执行以下流程:
aliyun CLI(缺失时安装最新版本)LoongCollector(若已运行则跳过)logstore 索引和仪表板logstore 采集配置运行命令前,请确保用户意图完整:
PROJECT 和 LOGSTORE。sudo 权限。广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
必需项:
PROJECT: SLS 项目名称LOGSTORE: SLS 日志库名称从环境变量读取:
ALIBABA_CLOUD_ACCESS_KEY_IDALIBABA_CLOUD_ACCESS_KEY_SECRETALIYUN_UID(用于 /etc/ilogtail/users 下的本地 UID 文件)推荐的可选项:
ALIBABA_CLOUD_REGION_ID(未设置时从 PROJECT 自动解析)如果您使用不同的 AK/SK 变量名,请先将它们导出为这些标准名称。
成功执行后,环境应包含:
LoongCollector(或 ilogtaild)openclaw-sls-collectorLOGSTORE 上创建的日志库索引openclaw-audit 和 openclaw-gatewayopenclaw-audit_${LOGSTORE}openclaw-audit_${LOGSTORE} 与 openclaw-sls-collector 之间的配置绑定以下命令设计为“存在则跳过”模式,可安全地重新运行。严格模板模式:对于索引/配置/仪表板的有效载荷,始终从
references/目录下的文件读取。不要手工制作或简化 JSON 主体,只需替换必要的占位符。
set -euo pipefail
# ===== 用户输入 =====
: "${PROJECT:?请导出 PROJECT}"
: "${LOGSTORE:?请导出 LOGSTORE}"
: "${ALIBABA_CLOUD_ACCESS_KEY_ID:?请导出 ALIBABA_CLOUD_ACCESS_KEY_ID}"
: "${ALIBABA_CLOUD_ACCESS_KEY_SECRET:?请导出 ALIBABA_CLOUD_ACCESS_KEY_SECRET}"
: "${ALIYUN_UID:?请导出 ALIYUN_UID}"
MACHINE_GROUP="openclaw-sls-collector"
CONFIG_NAME="openclaw-audit_${LOGSTORE}"
# 1) 如果缺失则安装 aliyun CLI(Linux)
if ! command -v aliyun >/dev/null 2>&1; then
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y aliyun-cli
elif command -v dnf >/dev/null 2>&1; then
sudo dnf install -y aliyun-cli
elif command -v yum >/dev/null 2>&1; then
sudo yum install -y aliyun-cli
elif command -v zypper >/dev/null 2>&1; then
sudo zypper -n install aliyun-cli
else
echo "未找到 aliyun CLI。请为您的 Linux 发行版手动安装 aliyun-cli。" >&2
exit 1
fi
fi
# 为 aliyun CLI 导出认证变量
export ALIBABA_CLOUD_ACCESS_KEY_ID
export ALIBABA_CLOUD_ACCESS_KEY_SECRET
is_loong_running() {
if sudo /etc/init.d/loongcollectord status 2>/dev/null | grep -qi "running"; then
return 0
fi
if sudo /etc/init.d/ilogtaild status 2>/dev/null | grep -qi "running"; then
return 0
fi
return 1
}
# 2) 解析区域并安装 LoongCollector(若已运行则跳过)
REGION_ID="${ALIBABA_CLOUD_REGION_ID:-}"
if [ -z "$REGION_ID" ]; then
REGION_ID="$(aliyun sls GetProject --project "$PROJECT" --cli-query 'region' --quiet 2>/dev/null | tr -d '\"' || true)"
fi
if [ -z "$REGION_ID" ]; then
echo "无法从项目解析区域: $PROJECT。请设置 ALIBABA_CLOUD_REGION_ID。" >&2
exit 1
fi
if ! is_loong_running; then
wget "https://aliyun-observability-release-${REGION_ID}.oss-${REGION_ID}.aliyuncs.com/loongcollector/linux64/latest/loongcollector.sh" -O loongcollector.sh
chmod +x loongcollector.sh
./loongcollector.sh install "${REGION_ID}"
fi
# 安装后验证:loongcollectord/ilogtaild 之一必须正在运行。
if ! is_loong_running; then
sudo /etc/init.d/loongcollectord start >/dev/null 2>&1 || true
sudo /etc/init.d/ilogtaild start >/dev/null 2>&1 || true
fi
if ! is_loong_running; then
echo "LoongCollector 安装检查失败:loongcollectord 和 ilogtaild 均未运行。" >&2
exit 1
fi
# 3) 本地用户定义标识符 + 创建机器组
sudo mkdir -p /etc/ilogtail
sudo mkdir -p /etc/ilogtail/users
if [ ! -f /etc/ilogtail/user_defined_id ]; then
sudo touch /etc/ilogtail/user_defined_id
fi
RAND8="$(LC_ALL=C tr -dc 'a-z0-9' </dev/urandom | head -c 8)"
USER_DEFINED_ID_PREFIX="${PROJECT}_openclaw_sls_collector_"
EXISTING_USER_DEFINED_ID="$(sudo awk -v p="${USER_DEFINED_ID_PREFIX}" 'index($0,p)==1 {print; exit}' /etc/ilogtail/user_defined_id 2>/dev/null || true)"
if [ -n "${EXISTING_USER_DEFINED_ID}" ]; then
USER_DEFINED_ID="${EXISTING_USER_DEFINED_ID}"
else
USER_DEFINED_ID="${USER_DEFINED_ID_PREFIX}${RAND8}"
echo "${USER_DEFINED_ID}" | sudo tee -a /etc/ilogtail/user_defined_id >/dev/null
fi
if ! sudo grep -Fxq "${USER_DEFINED_ID}" /etc/ilogtail/user_defined_id 2>/dev/null; then
echo "无法将 USER_DEFINED_ID 持久化到 /etc/ilogtail/user_defined_id" >&2
exit 1
fi
if [ ! -f "/etc/ilogtail/users/${ALIYUN_UID}" ]; then
sudo touch "/etc/ilogtail/users/${ALIYUN_UID}"
fi
if [ ! -f "/etc/ilogtail/users/${ALIYUN_UID}" ]; then
echo "无法创建 UID 标记文件: /etc/ilogtail/users/${ALIYUN_UID}" >&2
exit 1
fi
if ! aliyun sls GetMachineGroup --project "$PROJECT" --machineGroup "$MACHINE_GROUP" >/dev/null 2>&1; then
cat > /tmp/openclaw-machine-group.json <<EOF
{
"groupName": "${MACHINE_GROUP}",
"groupType": "",
"machineIdentifyType": "userdefined",
"machineList": ["${USER_DEFINED_ID}"]
}
EOF
aliyun sls CreateMachineGroup \
--project "$PROJECT" \
--body "$(cat /tmp/openclaw-machine-group.json)"
fi
if ! aliyun sls GetMachineGroup --project "$PROJECT" --machineGroup "$MACHINE_GROUP" >/dev/null 2>&1; then
echo "机器组创建不成功: ${MACHINE_GROUP}" >&2
exit 1
fi
# 4) 创建日志库(如果缺失)+ 索引 + 多个仪表板
if ! aliyun sls GetLogStore --project "$PROJECT" --logstore "$LOGSTORE" >/dev/null 2>&1; then
aliyun sls CreateLogStore --project "$PROJECT" \
--body "{\"logstoreName\":\"${LOGSTORE}\",\"ttl\":30,\"shardCount\":2}"
fi
if ! aliyun sls GetIndex --project "$PROJECT" --logstore "$LOGSTORE" >/dev/null 2>&1; then
# 直接使用 references/index.json 中的索引模板
aliyun sls CreateIndex \
--project "$PROJECT" \
--logstore "$LOGSTORE" \
--body "$(cat references/index.json)"
fi
sed "s/\${logstoreName}/${LOGSTORE}/g" references/dashboard-audit.json > /tmp/openclaw-audit-dashboard.json
sed "s/\${logstoreName}/${LOGSTORE}/g" references/dashboard-gateway.json > /tmp/openclaw-gateway-dashboard.json
# 创建仪表板使用 project + body(detail)。更新使用 path + project + body。
if aliyun sls GET "/dashboards/openclaw-audit" --project "$PROJECT" >/dev/null 2>&1; then
aliyun sls PUT "/dashboards/openclaw-audit" \
--project "$PROJECT" \
--body "$(cat /tmp/openclaw-audit-dashboard.json)"
else
aliyun sls POST "/dashboards" \
--project "$PROJECT" \
--body "$(cat /tmp/openclaw-audit-dashboard.json)"
fi
if aliyun sls GET "/dashboards/openclaw-gateway" --project "$PROJECT" >/dev/null 2>&1; then
aliyun sls PUT "/dashboards/openclaw-gateway" \
--project "$PROJECT" \
--body "$(cat /tmp/openclaw-gateway-dashboard.json)"
else
aliyun sls POST "/dashboards" \
--project "$PROJECT" \
--body "$(cat /tmp/openclaw-gateway-dashboard.json)"
fi
# 5) 创建采集配置(已存在时更新)
# 严格从 references/collector-config.json 渲染采集器配置
sed \
-e "s/\${configName}/${CONFIG_NAME}/g" \
-e "s/\${logstoreName}/${LOGSTORE}/g" \
-e "s/\${region_id}/${REGION_ID}/g" \
references/collector-config.json > /tmp/openclaw-collector-config.json
if aliyun sls GetConfig --project "$PROJECT" --configName "$CONFIG_NAME" >/dev/null 2>&1; then
aliyun sls UpdateConfig \
--project "$PROJECT" \
--configName "$CONFIG_NAME" \
--body "$(cat /tmp/openclaw-collector-config.json)"
else
aliyun sls CreateConfig \
--project "$PROJECT" \
--body "$(cat /tmp/openclaw-collector-config.json)"
fi
# 6) 将采集配置绑定到机器组
aliyun sls ApplyConfigToMachineGroup \
--project "$PROJECT" \
--machineGroup "$MACHINE_GROUP" \
--configName "$CONFIG_NAME"
echo "OpenClaw SLS 可观测性设置完成。"
当此技能完成时,返回一份简洁的状态报告,包含:
PROJECT、LOGSTORE、解析出的 REGION_IDaliyun sls GetMachineGroup --project "$PROJECT" --machineGroup openclaw-sls-collector
aliyun sls GetIndex --project "$PROJECT" --logstore "$LOGSTORE"
aliyun sls GetDashboard --project "$PROJECT" --dashboardName openclaw-audit
aliyun sls GetDashboard --project "$PROJECT" --dashboardName openclaw-gateway
aliyun sls GetConfig --project "$PROJECT" --configName "openclaw-audit_${LOGSTORE}"
references/cli-commands.mdreferences/index.jsonreferences/dashboard-audit.json、references/dashboard-gateway.jsonreferences/collector-config.json仅在需要时读取参考文件:
cli-commands.md 进行逐步故障排除。每周安装次数
66
仓库
GitHub 星标数
364
首次出现
12 天前
安全审计
安装于
gemini-cli64
github-copilot64
codex64
kimi-cli64
cursor64
amp64
This skill provisions Alibaba Cloud SLS observability for OpenClaw on Linux and keeps reruns safe.
At a high level, execute this flow:
aliyun CLI (install latest when missing)LoongCollector by project region (skip if already running)logstore index and dashboardslogstore collection configBefore running commands, make sure the user intent is complete:
PROJECT and LOGSTORE.sudo available.Required:
PROJECT: SLS project nameLOGSTORE: SLS logstore nameRead from environment variables:
ALIBABA_CLOUD_ACCESS_KEY_IDALIBABA_CLOUD_ACCESS_KEY_SECRETALIYUN_UID (used for the local UID file under /etc/ilogtail/users)Recommended optional:
ALIBABA_CLOUD_REGION_ID (auto-resolved from PROJECT when not set)If you use different AK/SK variable names, export them to these standard names first.
After successful execution, the environment should contain:
LoongCollector (or ilogtaild) on the hostopenclaw-sls-collectorLOGSTOREopenclaw-audit and openclaw-gatewayopenclaw-audit_${LOGSTORE}openclaw-audit_${LOGSTORE} and openclaw-sls-collectorThe commands below are designed as "exists -> skip" and are safe to rerun. Strict template mode: for index/config/dashboard payloads, always read from files in
references/. Do not handcraft or simplify JSON bodies beyond required placeholder replacement.
set -euo pipefail
# ===== User inputs =====
: "${PROJECT:?Please export PROJECT}"
: "${LOGSTORE:?Please export LOGSTORE}"
: "${ALIBABA_CLOUD_ACCESS_KEY_ID:?Please export ALIBABA_CLOUD_ACCESS_KEY_ID}"
: "${ALIBABA_CLOUD_ACCESS_KEY_SECRET:?Please export ALIBABA_CLOUD_ACCESS_KEY_SECRET}"
: "${ALIYUN_UID:?Please export ALIYUN_UID}"
MACHINE_GROUP="openclaw-sls-collector"
CONFIG_NAME="openclaw-audit_${LOGSTORE}"
# 1) Install aliyun CLI if missing (Linux)
if ! command -v aliyun >/dev/null 2>&1; then
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y aliyun-cli
elif command -v dnf >/dev/null 2>&1; then
sudo dnf install -y aliyun-cli
elif command -v yum >/dev/null 2>&1; then
sudo yum install -y aliyun-cli
elif command -v zypper >/dev/null 2>&1; then
sudo zypper -n install aliyun-cli
else
echo "aliyun CLI not found. Install aliyun-cli manually for your Linux distribution." >&2
exit 1
fi
fi
# Export auth variables for aliyun CLI
export ALIBABA_CLOUD_ACCESS_KEY_ID
export ALIBABA_CLOUD_ACCESS_KEY_SECRET
is_loong_running() {
if sudo /etc/init.d/loongcollectord status 2>/dev/null | grep -qi "running"; then
return 0
fi
if sudo /etc/init.d/ilogtaild status 2>/dev/null | grep -qi "running"; then
return 0
fi
return 1
}
# 2) Resolve region and install LoongCollector (skip when already running)
REGION_ID="${ALIBABA_CLOUD_REGION_ID:-}"
if [ -z "$REGION_ID" ]; then
REGION_ID="$(aliyun sls GetProject --project "$PROJECT" --cli-query 'region' --quiet 2>/dev/null | tr -d '\"' || true)"
fi
if [ -z "$REGION_ID" ]; then
echo "Cannot resolve region from project: $PROJECT. Please set ALIBABA_CLOUD_REGION_ID." >&2
exit 1
fi
if ! is_loong_running; then
wget "https://aliyun-observability-release-${REGION_ID}.oss-${REGION_ID}.aliyuncs.com/loongcollector/linux64/latest/loongcollector.sh" -O loongcollector.sh
chmod +x loongcollector.sh
./loongcollector.sh install "${REGION_ID}"
fi
# Post-install verification: one of loongcollectord/ilogtaild must be running.
if ! is_loong_running; then
sudo /etc/init.d/loongcollectord start >/dev/null 2>&1 || true
sudo /etc/init.d/ilogtaild start >/dev/null 2>&1 || true
fi
if ! is_loong_running; then
echo "LoongCollector installation check failed: neither loongcollectord nor ilogtaild is running." >&2
exit 1
fi
# 3) Local user-defined identifier + create machine group
sudo mkdir -p /etc/ilogtail
sudo mkdir -p /etc/ilogtail/users
if [ ! -f /etc/ilogtail/user_defined_id ]; then
sudo touch /etc/ilogtail/user_defined_id
fi
RAND8="$(LC_ALL=C tr -dc 'a-z0-9' </dev/urandom | head -c 8)"
USER_DEFINED_ID_PREFIX="${PROJECT}_openclaw_sls_collector_"
EXISTING_USER_DEFINED_ID="$(sudo awk -v p="${USER_DEFINED_ID_PREFIX}" 'index($0,p)==1 {print; exit}' /etc/ilogtail/user_defined_id 2>/dev/null || true)"
if [ -n "${EXISTING_USER_DEFINED_ID}" ]; then
USER_DEFINED_ID="${EXISTING_USER_DEFINED_ID}"
else
USER_DEFINED_ID="${USER_DEFINED_ID_PREFIX}${RAND8}"
echo "${USER_DEFINED_ID}" | sudo tee -a /etc/ilogtail/user_defined_id >/dev/null
fi
if ! sudo grep -Fxq "${USER_DEFINED_ID}" /etc/ilogtail/user_defined_id 2>/dev/null; then
echo "Failed to persist USER_DEFINED_ID to /etc/ilogtail/user_defined_id" >&2
exit 1
fi
if [ ! -f "/etc/ilogtail/users/${ALIYUN_UID}" ]; then
sudo touch "/etc/ilogtail/users/${ALIYUN_UID}"
fi
if [ ! -f "/etc/ilogtail/users/${ALIYUN_UID}" ]; then
echo "Failed to create UID marker file: /etc/ilogtail/users/${ALIYUN_UID}" >&2
exit 1
fi
if ! aliyun sls GetMachineGroup --project "$PROJECT" --machineGroup "$MACHINE_GROUP" >/dev/null 2>&1; then
cat > /tmp/openclaw-machine-group.json <<EOF
{
"groupName": "${MACHINE_GROUP}",
"groupType": "",
"machineIdentifyType": "userdefined",
"machineList": ["${USER_DEFINED_ID}"]
}
EOF
aliyun sls CreateMachineGroup \
--project "$PROJECT" \
--body "$(cat /tmp/openclaw-machine-group.json)"
fi
if ! aliyun sls GetMachineGroup --project "$PROJECT" --machineGroup "$MACHINE_GROUP" >/dev/null 2>&1; then
echo "Machine group was not created successfully: ${MACHINE_GROUP}" >&2
exit 1
fi
# 4) Create logstore (if missing) + index + multiple dashboards
if ! aliyun sls GetLogStore --project "$PROJECT" --logstore "$LOGSTORE" >/dev/null 2>&1; then
aliyun sls CreateLogStore --project "$PROJECT" \
--body "{\"logstoreName\":\"${LOGSTORE}\",\"ttl\":30,\"shardCount\":2}"
fi
if ! aliyun sls GetIndex --project "$PROJECT" --logstore "$LOGSTORE" >/dev/null 2>&1; then
# Use the index template as-is from references/index.json
aliyun sls CreateIndex \
--project "$PROJECT" \
--logstore "$LOGSTORE" \
--body "$(cat references/index.json)"
fi
sed "s/\${logstoreName}/${LOGSTORE}/g" references/dashboard-audit.json > /tmp/openclaw-audit-dashboard.json
sed "s/\${logstoreName}/${LOGSTORE}/g" references/dashboard-gateway.json > /tmp/openclaw-gateway-dashboard.json
# Create dashboard uses project + body(detail). Update uses path + project + body.
if aliyun sls GET "/dashboards/openclaw-audit" --project "$PROJECT" >/dev/null 2>&1; then
aliyun sls PUT "/dashboards/openclaw-audit" \
--project "$PROJECT" \
--body "$(cat /tmp/openclaw-audit-dashboard.json)"
else
aliyun sls POST "/dashboards" \
--project "$PROJECT" \
--body "$(cat /tmp/openclaw-audit-dashboard.json)"
fi
if aliyun sls GET "/dashboards/openclaw-gateway" --project "$PROJECT" >/dev/null 2>&1; then
aliyun sls PUT "/dashboards/openclaw-gateway" \
--project "$PROJECT" \
--body "$(cat /tmp/openclaw-gateway-dashboard.json)"
else
aliyun sls POST "/dashboards" \
--project "$PROJECT" \
--body "$(cat /tmp/openclaw-gateway-dashboard.json)"
fi
# 5) Create collection config (update when already exists)
# Render collector config strictly from references/collector-config.json
sed \
-e "s/\${configName}/${CONFIG_NAME}/g" \
-e "s/\${logstoreName}/${LOGSTORE}/g" \
-e "s/\${region_id}/${REGION_ID}/g" \
references/collector-config.json > /tmp/openclaw-collector-config.json
if aliyun sls GetConfig --project "$PROJECT" --configName "$CONFIG_NAME" >/dev/null 2>&1; then
aliyun sls UpdateConfig \
--project "$PROJECT" \
--configName "$CONFIG_NAME" \
--body "$(cat /tmp/openclaw-collector-config.json)"
else
aliyun sls CreateConfig \
--project "$PROJECT" \
--body "$(cat /tmp/openclaw-collector-config.json)"
fi
# 6) Bind collection config to machine group
aliyun sls ApplyConfigToMachineGroup \
--project "$PROJECT" \
--machineGroup "$MACHINE_GROUP" \
--configName "$CONFIG_NAME"
echo "OpenClaw SLS observability setup completed."
When this skill completes, return a concise status report with:
PROJECT, LOGSTORE, resolved REGION_IDaliyun sls GetMachineGroup --project "$PROJECT" --machineGroup openclaw-sls-collector
aliyun sls GetIndex --project "$PROJECT" --logstore "$LOGSTORE"
aliyun sls GetDashboard --project "$PROJECT" --dashboardName openclaw-audit
aliyun sls GetDashboard --project "$PROJECT" --dashboardName openclaw-gateway
aliyun sls GetConfig --project "$PROJECT" --configName "openclaw-audit_${LOGSTORE}"
references/cli-commands.mdreferences/index.jsonreferences/dashboard-audit.json, references/dashboard-gateway.jsonreferences/collector-config.jsonRead reference files only when needed:
cli-commands.md for step-by-step troubleshooting.Weekly Installs
66
Repository
GitHub Stars
364
First Seen
12 days ago
Security Audits
Gen Agent Trust HubPassSocketWarnSnykWarn
Installed on
gemini-cli64
github-copilot64
codex64
kimi-cli64
cursor64
amp64
Azure 升级评估与自动化工具 - 轻松迁移 Functions 计划、托管层级和 SKU
111,700 周安装