spl-to-apl
它能做什么
这项技能把 Splunk SPL 搜索转换为 Axiom APL。适合从 Splunk 迁移到 Axiom,或希望借助熟悉的 SPL 模式学习 APL 的团队。
适用场景
- ✓当你要把日志搜索从 Splunk 迁移到 Axiom 时。
- ✓当你有一条 Splunk 搜索,并需要对应的 Axiom 查询时。
- ✓当你想了解某个常见 Splunk 命令在 APL 中如何编写时。
技能链接
https://github.com/openclaw/clawhub/blob/main/.agents/skills/spl-to-apl/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请把这条 Splunk 搜索转换为 Axiom 查询:index=web status>=500 | stats count by host。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会把每个 Splunk 命令映射为对应的 APL 命令,例如 stats 对应汇总,eval 对应扩展字段。它还会补上 Axiom 所需的时间范围,并在比较运算需要时把文本字段转换为数字。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
SPL to APL Translator
Type safety: Fields like status are often stored as strings. Always cast before numeric comparison: toint(status) >= 500, not status >= 500.
Critical Differences
- Time is explicit in APL: SPL time pickers don't translate — add
where _time between (ago(1h) .. now()) - Structure: SPL
index=... | command→ APL['dataset'] | operator - Join is preview: limited to 50k rows, inner/innerunique/leftouter only
- cidrmatch args reversed: SPL
cidrmatch(cidr, ip)→ APLipv4_is_in_range(ip, cidr)
Core Command Mappings
| SPL | APL | Notes |
|---|---|---|
search index=... |
['dataset'] |
Dataset replaces index |
search field=value |
where field == "value" |
Explicit where |
where |
where |
Same |
stats |
summarize |
Different aggregation syntax |
eval |
extend |
Create/modify fields |
table / fields |
project |
Select columns |
fields - |
project-away |
Remove columns |
rename x as y |
project-rename y = x |
Rename |
sort / sort - |
order by ... asc/desc |
Sort |
head N |
take N |
Limit rows |
top N field |
summarize count() by field | top N by count_ |
Two-step |
dedup field |
summarize arg_max(_time, *) by field |
Keep latest |
rex |
parse or extract() |
Regex extraction |
join |
join |
Preview feature |
append |
union |
Combine datasets |
mvexpand |
mv-expand |
Expand arrays |
timechart span=X |
summarize ... by bin(_time, X) |
Manual binning |
rare N field |
summarize count() by field | order by count_ asc | take N |
Bottom N |
spath |
parse_json() or json['path'] |
JSON access |
transaction |
No direct equivalent | Use summarize + make_list |
Complete mappings: reference/command-mapping.md
Stats → Summarize
# SPL
| stats count by status
# APL
| summarize count() by status
Key function mappings
| SPL | APL |
|---|---|
count |
count() |
count(field) |
countif(isnotnull(field)) |
dc(field) |
dcount(field) |
avg/sum/min/max |
Same |
median(field) |
percentile(field, 50) |
perc95(field) |
percentile(field, 95) |
first/last |
arg_min/arg_max(_time, field) |
list(field) |
make_list(field) |
values(field) |
make_set(field) |
Conditional count pattern
# SPL
| stats count(eval(status>=500)) as errors by host
# APL
| summarize errors = countif(status >= 500) by host
Complete function list: reference/function-mapping.md
Eval → Extend
# SPL
| eval new_field = old_field * 2
# APL
| extend new_field = old_field * 2
Key function mappings
| SPL | APL | Notes |
|---|---|---|
if(c, t, f) |
iff(c, t, f) |
Double 'f' |
case(c1,v1,...) |
case(c1,v1,...,default) |
Requires default |
len(str) |
strlen(str) |
|
lower/upper |
tolower/toupper |
|
substr |
substring |
0-indexed in APL |
replace |
replace_string |
|
tonumber |
toint/tolong/toreal |
Explicit types |
match(s,r) |
s matches regex "r" |
Operator |
split(s, d) |
split(s, d) |
Same |
mvjoin(mv, d) |
strcat_array(arr, d) |
Join array |
mvcount(mv) |
array_length(arr) |
Array length |
Case statement pattern
# SPL
| eval level = case(
status >= 500, "error",
status >= 400, "warning",
1==1, "ok"
)
# APL
| extend level = case(
status >= 500, "error",
status >= 400, "warning",
"ok"
)
Note: SPL's 1==1 catch-all becomes implicit default in APL.
Rex → Parse/Extract
# SPL
| rex field=message "user=(?<username>\w+)"
# APL - parse with regex
| parse kind=regex message with @"user=(?P<username>\w+)"
# APL - extract function
| extend username = extract("user=(\\w+)", 1, message)
Simple pattern (non-regex)
# SPL
| rex field=uri "^/api/(?<version>v\d+)/(?<endpoint>\w+)"
# APL
| parse uri with "/api/" version "/" endpoint
Time Handling
SPL time pickers don't translate. Always add explicit time range:
# SPL (time picker: Last 24 hours)
index=logs
# APL
['logs'] | where _time between (ago(24h) .. now())
Timechart translation
# SPL
| timechart span=5m count by status
# APL
| summarize count() by bin(_time, 5m), status
Common Patterns
Error rate calculation
# SPL
| stats count(eval(status>=500)) as errors, count as total by host
| eval error_rate = errors/total*1
常见问题
Splunk 中的时间选择器会被保留吗?
不会。在 APL 中,时间范围必须写入查询语句,因此这项技能会将其添加进去。
所有 Splunk 命令都受支持吗?
这项技能列出了常见的映射关系,并注明差异,例如 join 在 APL 中仍是预览功能。
为什么有些字段要转换为数字?
状态等类似字段通常以文本形式存储,因此在进行数值比较之前需要先转换。
详情
作者的原始描述
Translates Splunk SPL queries to Axiom APL. Provides command mappings, function equivalents, and syntax transformations. Use when migrating from Splunk, converting SPL queries, or learning APL equivalents of SPL patterns.
repo: openclaw/clawhub
热度
- GitHub 星标
- 9.5k
- 排名
- #12265
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
axiom-alerting
9.5k帮你的智能体通过 Axiom API 创建和管理监控器与通知路由,并检查告警是否按预期运行。
axiom-sre
9.5k帮你的智能体逐步调查生产事故和缺陷,在得出结论之前,用 Axiom 日志验证每一个猜测。
building-dashboards
9.5k帮你的智能体从仪表盘必须支持的决策出发,设计配有合适图表、查询和筛选器的 Axiom 仪表盘。
controlling-costs
9.5k帮你的智能体在 Axiom 中找出未被使用的数据,并构建用于追踪和削减日志成本的仪表盘与监控器。