返回顶部
a

aliyun-sls-openclaw-integration阿里云SLS集成

Use when the user needs to integrate OpenClaw with Alibaba Cloud SLS/Observability, including collector setup, machine groups, indexes, dashboards, collection configs, or Logtail bindings on Linux.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
110
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

aliyun-sls-openclaw-integration

OpenClaw SLS 集成

该技能为 Linux 上的 OpenClaw 配置阿里云 SLS 可观测性,并确保重跑安全。

在高级层面,执行以下流程:

  1. 1. 检查并安装 aliyun CLI(缺失时安装最新版本)
  2. 根据项目地域安装 LoongCollector(如果已在运行则跳过)
  3. 创建基于标识的机器组(本地标识 + 云端机器组)
  4. 创建 logstore 索引和仪表盘
  5. 创建 logstore 采集配置
  6. 将采集配置绑定到机器组

执行前确认意图

在运行命令之前,确保用户意图完整:

  1. 1. 确认目标 PROJECT 和 LOGSTORE。
  2. 确认 Linux 主机可访问且具有 sudo 权限。
  3. 确认 AK/SK 已在环境变量中导出。
  4. 如果缺少任何必要输入,请先询问,不要运行部分设置。

前提条件

必需:

  • - PROJECT:SLS 项目名称
  • LOGSTORE:SLS 日志库名称

从环境变量读取:

  • - ALIBABACLOUDACCESSKEYID
  • ALIBABACLOUDACCESSKEYSECRET
  • ALIYUN_UID(用于 /etc/ilogtail/users 下的本地 UID 文件)

推荐可选:

  • - ALIBABACLOUDREGION_ID(未设置时从 PROJECT 自动解析)

如果您使用不同的 AK/SK 变量名,请先将其导出为这些标准名称。


预期结果

成功执行后,环境应包含:

  • - 主机上正在运行的 LoongCollector(或 ilogtaild)
  • 机器组 openclaw-sls-collector
  • 在目标 LOGSTORE 上创建的日志库索引
  • 仪表盘 openclaw-audit 和 openclaw-gateway
  • 采集配置 openclaw-audit${LOGSTORE}
  • openclaw-audit${LOGSTORE} 与 openclaw-sls-collector 之间的配置绑定

一次性执行流程(幂等)

以下命令设计为存在则跳过,可安全重跑。
严格模板模式:对于索引/配置/仪表盘负载,始终从 references/ 中的文件读取。
除必要的占位符替换外,不要手工制作或简化 JSON 主体。

bash
set -euo pipefail

===== 用户输入 =====

: ${PROJECT:?请导出 PROJECT} : ${LOGSTORE:?请导出 LOGSTORE} : ${ALIBABACLOUDACCESSKEYID:?请导出 ALIBABACLOUDACCESSKEYID} : ${ALIBABACLOUDACCESSKEYSECRET:?请导出 ALIBABACLOUDACCESSKEYSECRET} : ${ALIYUNUID:?请导出 ALIYUNUID}

MACHINE_GROUP=openclaw-sls-collector
CONFIGNAME=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 ALIBABACLOUDACCESSKEYID export ALIBABACLOUDACCESSKEYSECRET

isloongrunning() {
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(已在运行时跳过)

REGIONID=${ALIBABACLOUDREGIONID:-} 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。请设置 ALIBABACLOUDREGION_ID。 >&2 exit 1 fi

if ! isloongrunning; then
wget https://aliyun-observability-release-${REGIONID}.oss-${REGIONID}.aliyuncs.com/loongcollector/linux64/latest/loongcollector.sh -O loongcollector.sh
chmod +x loongcollector.sh
./loongcollector.sh install ${REGION_ID}
fi

安装后验证:loongcollectord/ilogtaild 必须有一个在运行。

if ! isloongrunning; 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 ! isloongrunning; 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/userdefinedid ]; then sudo touch /etc/ilogtail/userdefinedid fi RAND8=$(LC_ALL=C tr -dc a-z0-9 DEFINEDIDPREFIX=${PROJECT}openclawslscollector_ EXISTINGUSERDEFINEDID=$(sudo awk -v p=${USERDEFINEDIDPREFIX} index($0,p)==1 {print; exit} /etc/ilogtail/userdefinedid 2>/dev/null || true) if [ -n ${EXISTINGUSERDEFINED_ID} ]; then USERDEFINEDID=${EXISTINGUSERDEFINED_ID} else USERDEFINEDID=${USERDEFINEDID_PREFIX}${RAND8} echo ${USERDEFINEDID} | sudo tee -a /etc/ilogtail/userdefinedid >/dev/null fi if ! sudo grep -Fxq ${USERDEFINEDID} /etc/ilogtail/userdefinedid 2>/dev/null; then echo 无法将 USERDEFINEDID 持久化到 /etc/ilogtail/userdefinedid >&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 < {
groupName: ${MACHINE_GROUP},
groupType: ,
machineIdentifyType: userdefined,
machineList: [${USERDEFINEDID}]
}
EOF
aliyun sls CreateMachineGroup \
--project $PROJECT \
--body $(cat /tmp/openclaw-machine-group.json)
fi
if ! aliyun sls GetMachineGroup --project $PROJECT --machineGroup $MACHINE_GROUP

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 aliyun-sls-openclaw-integration-1775877783 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 aliyun-sls-openclaw-integration-1775877783 技能

通过命令行安装

skillhub install aliyun-sls-openclaw-integration-1775877783

下载

⬇ 下载 aliyun-sls-openclaw-integration v1.0.0(免费)

文件大小: 8.01 KB | 发布时间: 2026-4-12 08:58

v1.0.0 最新 2026-4-12 08:58
aliyun-sls-openclaw-integration v1.0.0

- Initial release of OpenClaw integration with Alibaba Cloud SLS/Observability on Linux.
- Automates setup: installs aliyun CLI and LoongCollector, provisions machine groups, creates logstore, indexes, dashboards, collection configs, and binds them.
- Ensures idempotent, safe reruns, and checks all key inputs (PROJECT, LOGSTORE, credentials, sudo).
- Requires Linux host access and AK/SK environment variables already set.
- Uses strict template mode for SLS payloads (reads from reference files, supports placeholder replacement).

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部