【发布时间】:2015-12-22 23:08:52
【问题描述】:
我正在尝试解析我们的一个 es 集群的 json 输出以收集过滤器缓存统计信息,并希望使用 Jq 来做到这一点。这是curl 命令的输出:
{
"_shards": {
"total": 5662,
"successful": 5662,
"failed": 0
},
"_all": {
"primaries": {
"filter_cache": {
"memory_size": "32.8gb",
"memory_size_in_bytes": 35245081088,
"evictions": 31347095
}
},
"total": {
"filter_cache": {
"memory_size": "94.3gb",
"memory_size_in_bytes": 101307321504,
"evictions": 79329152
}
}
},
"indices": {
"oreserverdk04180047": {
"primaries": {
"filter_cache": {
"memory_size": "0b",
"memory_size_in_bytes": 0,
"evictions": 11
}
},
"total": {
"filter_cache": {
"memory_size": "0b",
"memory_size_in_bytes": 0,
"evictions": 132
}
}
},
"janbe10200002": {
"primaries": {
"filter_cache": {
"memory_size": "0b",
"memory_size_in_bytes": 0,
"evictions": 88
}
},
"total": {
"filter_cache": {
"memory_size": "0b",
"memory_size_in_bytes": 0,
"evictions": 119
}
}
}
}
}
基本上我想让输出看起来像这样:
oreserverdk04180047 0b
janbe10200002 0b
我只想要“total”中的索引名称和 memory_size 列。如果我通过硬编码索引名称来运行它,我可以得到它:
jq '. | {memory_size: .indices.janbe10200002.total.filter_cache.memory_size}'
但我希望迭代使用某种通配符作为索引名称。
【问题讨论】: