Skip to content

Instantly share code, notes, and snippets.

@vgersh99
Last active August 3, 2018 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vgersh99/98af2d19cf747f100c4bf2f21d6dd10f to your computer and use it in GitHub Desktop.
Save vgersh99/98af2d19cf747f100c4bf2f21d6dd10f to your computer and use it in GitHub Desktop.
es_watcher_forwader_io_event_count parseError/Null-point exception
{
"_id": "es_watcher_forwader_io_event_count_88647390-c984-4480-ab08-a2b4bddea247-2018-08-03T14:28:36.420Z",
"watch_record": {
"watch_id": "es_watcher_forwader_io_event_count",
"state": "failed",
"_status": {
"state": {
"active": true,
"timestamp": "2018-08-03T14:21:05.103Z"
},
"actions": {
"forward_to_notification_service": {
"ack": {
"timestamp": "2018-08-03T14:21:05.103Z",
"state": "awaits_successful_execution"
}
}
}
},
"trigger_event": {
"type": "manual",
"triggered_time": "2018-08-03T14:28:36.420Z",
"manual": {
"schedule": {
"scheduled_time": "2018-08-03T14:28:36.420Z"
}
}
},
"input": {
"http": {
"request": {
"scheme": "https",
"host": "elasticsearch.dev.FOO.io",
"port": 9200,
"method": "get",
"path": "metrics/logs/_search",
"params": {},
"headers": {},
"auth": {
"basic": {
"username": "nms_elastic_stack_admin"
}
},
"body": """
{
"size": 0,
"query":{
"bool":{
"must": [
{
"query_string": {
"query": "role:idb-syslog-to-elk",
"analyze_wildcard": true
}
}
],
"filter": [
{
"range": {
"@timestamp":{
"from": "now-5m",
"to": "now",
"include_lower": true,
"include_upper": true,
"boost": 1
}
}
}
],
"disable_coord": false,
"adjust_pure_negative": true,
"boost": 1
}
},
"aggregations":{
"minutes":{
"date_histogram":{
"field": "@timestamp",
"interval": "minute",
"offset": 0,
"order":{
"_key": "asc"
},
"keyed": false,
"min_doc_count": 0
},
"aggregations":{
"nodes":{
"terms":{
"field": "hostname.keyword",
"size": 10,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"show_term_doc_count_error": false,
"order": [
{
"eventCnt": "desc"
},
{
"_term": "asc"
}
]
},
"aggregations: {
"dir": {
"terms":{
"field": "direction.keyword",
"size": 10,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"show_term_doc_count_error": false,
},
"aggregations":{
"eventCnt":{
"sum":{
"field": "events.count"
}
}
}
}
}
}
}
}
},
"ext":{}
}
"""
}
}
},
"condition": {
"script": {
"inline": """
if (ctx.payload.aggregations.minutes.buckets.size() == 0) return false;
for (def i = 0 ; i < ctx.payload.aggregations.minutes.buckets.size() ; i++ ) {
def b = ctx.payload.aggregations.minutes.buckets[i];
for (def x = 0 ; x < b.nodes.buckets.size() ; x++ ) {
def b2 = b.nodes.buckets[x];
def input = b2.dir.buckets.stream().filter(bucket -> bucket.key == 'in').findFirst().get().eventCnt.value;
def out = b2.dir.buckets.stream().filter(bucket -> bucket.key == 'out').findFirst().get().eventCnt.value;
def result = (out/input)*100 > 10;
if (result == true) {
return true
}
}
}
return false;
""",
"lang": "painless"
}
},
"result": {
"execution_time": "2018-08-03T14:28:36.420Z",
"execution_duration": 13,
"input": {
"type": "http",
"status": "success",
"payload": {
"_headers": {
"content-length": [
"539"
],
"content-type": [
"application/json; charset=UTF-8"
]
},
"error": {
"root_cause": [
{
"type": "json_parse_exception",
"reason": "Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in name\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@72a4f9da; line: 60, column: 40]"
}
],
"type": "json_parse_exception",
"reason": "Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in name\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@72a4f9da; line: 60, column: 40]"
},
"_status_code": 500,
"status": 500
},
"http": {
"request": {
"host": "elasticsearch.dev.FOO.io",
"port": 9200,
"scheme": "https",
"method": "get",
"path": "metrics/logs/_search",
"auth": {
"basic": {
"username": "nms_elastic_stack_admin"
}
},
"body": """
{
"size": 0,
"query":{
"bool":{
"must": [
{
"query_string": {
"query": "role:idb-syslog-to-elk",
"analyze_wildcard": true
}
}
],
"filter": [
{
"range": {
"@timestamp":{
"from": "now-5m",
"to": "now",
"include_lower": true,
"include_upper": true,
"boost": 1
}
}
}
],
"disable_coord": false,
"adjust_pure_negative": true,
"boost": 1
}
},
"aggregations":{
"minutes":{
"date_histogram":{
"field": "@timestamp",
"interval": "minute",
"offset": 0,
"order":{
"_key": "asc"
},
"keyed": false,
"min_doc_count": 0
},
"aggregations":{
"nodes":{
"terms":{
"field": "hostname.keyword",
"size": 10,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"show_term_doc_count_error": false,
"order": [
{
"eventCnt": "desc"
},
{
"_term": "asc"
}
]
},
"aggregations: {
"dir": {
"terms":{
"field": "direction.keyword",
"size": 10,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"show_term_doc_count_error": false,
},
"aggregations":{
"eventCnt":{
"sum":{
"field": "events.count"
}
}
}
}
}
}
}
}
},
"ext":{}
}
"""
},
"status_code": 500
}
},
"actions": []
},
"exception": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"if (ctx.payload.aggregations.minutes.buckets.size() == 0) ",
" ^---- HERE"
],
"script": """
if (ctx.payload.aggregations.minutes.buckets.size() == 0) return false;
for (def i = 0 ; i < ctx.payload.aggregations.minutes.buckets.size() ; i++ ) {
def b = ctx.payload.aggregations.minutes.buckets[i];
for (def x = 0 ; x < b.nodes.buckets.size() ; x++ ) {
def b2 = b.nodes.buckets[x];
def input = b2.dir.buckets.stream().filter(bucket -> bucket.key == 'in').findFirst().get().eventCnt.value;
def out = b2.dir.buckets.stream().filter(bucket -> bucket.key == 'out').findFirst().get().eventCnt.value;
def result = (out/input)*100 > 10;
if (result == true) {
return true
}
}
}
return false;
""",
"lang": "painless",
"caused_by": {
"type": "null_pointer_exception",
"reason": null,
"stack_trace": """
java.lang.NullPointerException
at org.elasticsearch.painless.DefBootstrap$PIC.fallback(DefBootstrap.java:202)
at org.elasticsearch.painless.PainlessScript$Script.execute(
if (ctx.payload.aggregations.minutes.buckets.size() == 0) return false;
for (def i = 0 ; i < ctx.payload.aggregations.minutes.buckets.size() ; i++ ) {
def b = ctx.payload.aggregations.minutes.buckets[i];
for (def x = 0 ; x < b. ...:36)
at org.elasticsearch.painless.ScriptImpl.run(ScriptImpl.java:133)
at org.elasticsearch.xpack.watcher.condition.ScriptCondition.doExecute(ScriptCondition.java:94)
at org.elasticsearch.xpack.watcher.condition.ScriptCondition.execute(ScriptCondition.java:84)
at org.elasticsearch.xpack.watcher.execution.ExecutionService.executeInner(ExecutionService.java:391)
at org.elasticsearch.xpack.watcher.execution.ExecutionService.execute(ExecutionService.java:275)
at org.elasticsearch.xpack.watcher.transport.actions.execute.TransportExecuteWatchAction.masterOperation(TransportExecuteWatchAction.java:143)
at org.elasticsearch.xpack.watcher.transport.actions.execute.TransportExecuteWatchAction.masterOperation(TransportExecuteWatchAction.java:65)
at org.elasticsearch.action.support.master.TransportMasterNodeAction.masterOperation(TransportMasterNodeAction.java:87)
at org.elasticsearch.action.support.master.TransportMasterNodeAction$AsyncSingleAction$2.doRun(TransportMasterNodeAction.java:166)
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:638)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
"""
},
"stack_trace": """
ScriptException[runtime error]; nested: NullPointerException;
at org.elasticsearch.painless.PainlessScript.convertToScriptException(PainlessScript.java:101)
at org.elasticsearch.painless.PainlessScript$Script.execute(
if (ctx.payload.aggregations.minutes.buckets.size() == 0) return false;
for (def i = 0 ; i < ctx.payload.aggregations.minutes.buckets.size() ; i++ ) {
def b = ctx.payload.aggregations.minutes.buckets[i];
for (def x = 0 ; x < b. ...:704)
at org.elasticsearch.painless.ScriptImpl.run(ScriptImpl.java:133)
at org.elasticsearch.xpack.watcher.condition.ScriptCondition.doExecute(ScriptCondition.java:94)
at org.elasticsearch.xpack.watcher.condition.ScriptCondition.execute(ScriptCondition.java:84)
at org.elasticsearch.xpack.watcher.execution.ExecutionService.executeInner(ExecutionService.java:391)
at org.elasticsearch.xpack.watcher.execution.ExecutionService.execute(ExecutionService.java:275)
at org.elasticsearch.xpack.watcher.transport.actions.execute.TransportExecuteWatchAction.masterOperation(TransportExecuteWatchAction.java:143)
at org.elasticsearch.xpack.watcher.transport.actions.execute.TransportExecuteWatchAction.masterOperation(TransportExecuteWatchAction.java:65)
at org.elasticsearch.action.support.master.TransportMasterNodeAction.masterOperation(TransportMasterNodeAction.java:87)
at org.elasticsearch.action.support.master.TransportMasterNodeAction$AsyncSingleAction$2.doRun(TransportMasterNodeAction.java:166)
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:638)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at org.elasticsearch.painless.DefBootstrap$PIC.fallback(DefBootstrap.java:202)
at org.elasticsearch.painless.PainlessScript$Script.execute(
if (ctx.payload.aggregations.minutes.buckets.size() == 0) return false;
for (def i = 0 ; i < ctx.payload.aggregations.minutes.buckets.size() ; i++ ) {
def b = ctx.payload.aggregations.minutes.buckets[i];
for (def x = 0 ; x < b. ...:36)
... 14 more
"""
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment