elasticsearch 观察者无法解析搜索输入
elasticsearch watcher could not parse search input
我正在尝试配置 Elasticsearch Watcher Watch 以提醒某些消息,但我无法让我的搜索输入起作用。
我尝试同时使用 Sense 和 elasticsearch-watcher-py,但 Watcher 总是 returns a "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 和完全相同的搜索查询 returns 186 结果很好,但 Watcher 不断返回状态 400 和 parse_exception,原因 "could not parse [search] input for watch [testwatch]. unexpected token [START_OBJECT]"
正如 elastic forum 上有人向我指出的那样,这只是一个错字。
'requests': {
真的应该
'request': {
另外,为了完整起见,我的操作有误,以下是正确的。
'actions': {
'log' : {
'logging' : {
'text': 'Watch triggered!'
}
}
}
我正在尝试配置 Elasticsearch Watcher Watch 以提醒某些消息,但我无法让我的搜索输入起作用。 我尝试同时使用 Sense 和 elasticsearch-watcher-py,但 Watcher 总是 returns a "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 和完全相同的搜索查询 returns 186 结果很好,但 Watcher 不断返回状态 400 和 parse_exception,原因 "could not parse [search] input for watch [testwatch]. unexpected token [START_OBJECT]"
正如 elastic forum 上有人向我指出的那样,这只是一个错字。
'requests': {
真的应该
'request': {
另外,为了完整起见,我的操作有误,以下是正确的。
'actions': {
'log' : {
'logging' : {
'text': 'Watch triggered!'
}
}
}