我正在尝试分析Athena中的AWS云跟踪日志,因为如果我选择安全组添加入站规则事件,它将在元素列中返回以下字符串。
{"groupId":"sg-XXXX","ipPermissions":{"items":[{"ipProtocol":"tcp","fromPort":22,"toPort":22,"groups":{},"ipRanges":{"items":[{"cidrIp":"0.0.0.0/0"}]},"prefixListIds":{}}]}}
但我从json结果中仅需要groupId
。那我该怎么办呢?
注意:表格是外部表格
答案 0 :(得分:0)
select json_extract_scalar('{"groupId":"sg-XXXX","ipPermissions":{"items":[{"ipProtocol":"tcp","fromPort":22,"toPort":22,"groups":{},"ipRanges":{"items":[{"cidrIp":"0.0.0.0/0"}]},"prefixListIds":{}}]}}','$.groupId');
OK
sg-XXXX