我正在尝试创建一个 AWS 仪表板可视化,显示一段时间内缓存命中与未命中的计数。为此,我正在设置一个log
类型仪表板,其中包含日志上的见解查询。为了尽可能简单,我的日志是:
{"cache.hit", true}
或{"cache.hit", false}
。
我希望我的仪表板在同一个图表上跟踪这两种可能性,但似乎我不能不将我的日志分成这些值的不同行。例如,如果我的日志只是:
{"cache.hit.true", true}
或者{"cache.hit.false", true}
,然后我可以创建 2 个单独的图表来在仪表板中独立跟踪这些值,但这并不那么干净。
为了让它们在一个破折号上,我试过了,但它所做的只是显示两个字段,并且两个显示字段的值是相同的,但它们绝对不应该是:
fields @timestamp, @message, cache.hit as cache_hits
| filter cache_hits IN [0, 1]
| display cache_hits = 0 as in_cache_false
| display cache_hits = 1 as in_cache_true
| stat count (in_cache_true), count(in_cache_false) by bin(30s)
| sort @timestamp desc
| limit 20