1

我正在尝试配置 Elasticsearch Watcher Watch 以提醒某些消息,但我无法让我的搜索输入正常工作。我尝试同时使用 Sense 和elasticsearch-watcher-py,但 Watcher 总是返回“parse_exception”。

est.watcher.put_watch(
    id='a1b_error',
    body={
        # run the watch every night at midnight
        'trigger': { 'schedule': { 'daily': { 'at': 'midnight' }}},
        'condition': { 'script': { 'inline': 'ctx.payload.hits.total > 0' } },
        'input': {
            'search': {
                'requests': {
                    'indices': ['logstash-*'],
                    'body': {
                        'query': {
                            'bool': {
                                'must': [
                                    { 'match': { 'Projekt': 'ourproject' }},
                                    { 'match': { 'Modus': 'production' }},
                                    { 'match': { 'facility': 'somebackend.log' }},
                                    { 'wildcard': { 'message': 'SOMEERROR*' }},
                                    { 'range': { '@timestamp' : { 'gte': 'now-30d', 'lt': 'now' }}}
                                ]
                            }
                        }
                    }
                }
            }
        },
        'actions': {
            'log' : {
                'logging' : {
                    'test': 'Watch triggered!'
                }
            }
        }
    }
)

使用 elasticsearch-py 和完全相同的搜索查询,它返回 186 个结果就好了,但 Watcher 不断返回状态 400 和 parse_exception,原因是“无法解析 [search] 输入的 watch [testwatch]。意外令牌 [START_OBJECT]”

4

1 回答 1

2

正如弹性论坛上的某个人向我指出的那样,这只是一个错字。

'requests': {

真的应该

'request': {

另外,为了完整起见,我的操作有错误,以下是正确的。

'actions': {
    'log' : {
        'logging' : {
            'text': 'Watch triggered!'
        }
    }
}
于 2016-08-12T05:13:29.390 回答