【问题标题】:How to compare the value of two fields in KibanaKibana中如何比较两个字段的值
【发布时间】:2016-05-23 07:57:31
【问题描述】:

我在ES中有两种日志(rtmp和apache),apache有clientip.raw,rtmp有ipclient.raw。问题是:我怎样才能在我的 Kibana 面板中只看到符合条件 "ipclient"="clientip" 的数据?

我尝试在我的搜索栏中写这个,但没有用:

{
"query": {
    "filtered": {
        "filter": {
            "script": {"script": "doc['clientip.raw'].value == doc['ipclient.raw'].value"}
            }
        }
    }
} 

【问题讨论】:

    标签: dsl kibana-4 elastic-stack


    【解决方案1】:

    您可以编写以下查询:-

    {"constant_score":{"filter":{"script" : { "script" : "doc['clientip.raw'].value == doc['ipclient.raw'].value"}}}}
    

    您在使用上述查询时可能会看到错误,例如:-

    ScriptException[类型 [inline]、操作 [search] 和 lang [groovy] 的脚本被禁用]

    要解决此错误,请编辑您的 elasticsearch.yml 文件并在末尾输入以下属性:-

     script.inline:on
    

    然后您可以重新启动您的 Elasticsearch 节点或集群,然后在 Kibana 上查询相同的内容,这将获取您想要的记录。

    【讨论】:

    • 嗨!首先感谢您的回答,但是它不起作用,出现错误,并且在我的 elasticsearch.yml 中我已经放置了这个配置: script.groovy.sandbox.enabled: true script.engine.groovy.file.search: true script。 engine.groovy.inline.aggs:在 script.engine.groovy.inline.search:在 script.search:在 script.indexed:在 script.inline:在
    • 只需将 script.inline:on 放在最后,删除您提到的所有其他属性并重新启动您的 elasticsearch 节点。重新启动后还要检查 elasticsearch 是否正常工作。如果在添加此属性后 elasticsearch 正常启动,那么它也可以在 Kibana 中运行。
    • 脚本有效,但我没有得到满足条件的记录... =S
    • 我已经验证了,我能找到符合条件的记录。
    • 可能是映射问题?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-05
    • 2017-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多