elasticsearch 按键和值筛选Grafana查询

q3aa0525  于 2022-11-22  发布在  ElasticSearch
关注(0)|答案(1)|浏览(207)

在我的Grafana ElasticSearch数据源中,我有一个如下所示的属性:

=== object_attributes.variables ====
[ 
  { "key": "fruit", "value": "apple" }, 
  { "key": "fruit", "value": "banana" }, 
  { "key": "game", "value": "cricket" }, 
  { "key": "game", "value": "football" }
]

=== object_attributes.status =====
["failed","all","xxx"] or ["passed","all","xxx"]

因此,当我这样查询时

  1. * AND object_attributes.status:"passed"我得到预期结果
  2. * AND object_attributes.status:"passed" AND object_attributes.variable:{ "key": "fruit", "value": "banana" }没有结果。
    基本上,我想通过fruit: bananapassed过滤所有属性。那么,我如何修改第2点以获得结果?
ipakzgxi

ipakzgxi1#

我自己想出来的。
我正在运行下面的查询,并能够获得预期的结果。

* AND object_attributes.status:"passed" AND object_attributes.variable.key:"fruit" AND object_attributes.variable.value:"banana"

所以,我没有运行object_attributes.variable:{ "key": "fruit", "value": "banana" },而是同时运行object_attributes.variable.key:"fruit" AND object_attributes.variable.value:"banana",它的工作就像一个魅力。

相关问题