Elasticsearch + Kibana +警报(X-Pack)用于能源监控系统

时间:2017-07-27 14:36:19

标签: elasticsearch monitoring kibana

有人可以通过X-Pack警报系统项目帮助我吗?这里的主要问题是我无法从数据库中收集“价值”数据,因为我想稍后将其与上限和下限进行比较。

所以这是索引:

PUT /test-1
{
  "mappings": {
    "Test1": {
      "properties": {
        "Value": {
          "type": "integer"
        },
        "date": {
          "type": "date",
          "format": "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
        },
         "UpperThreshold": {
          "type": "integer"
         },
         "LowerThreshold": {
          "type": "integer"
         }
      }
    }
  }
}

以下是输入示例:

POST /test-1/Test1
{
  "Value": "500",
  "date": "2017-06-13T16:20:00.000Z",
  "UpperThreshold":"450",
  "LowerThreshold": "380"
}

这是我的提醒代码

{
  "trigger": {
    "schedule": {
      "interval": "10s"
    }
  },
  "input": {
    "search": {
      "request": {
        "search_type": "query_then_fetch",
        "indices": [
          "logs"
        ],
        "types": [],
        "body": {
          "query": {
            "match": {
              "message": "error"
            }
          }
        }
      }
    }
  },
  "condition": {
    "compare": {
      "ctx.payload.hits.total": {
        "gt": 0
      }
    }
  },
  "actions": {
    "send_email": {
      "email": {
        "profile": "standard",
        "to": [
          "<account@gmail.com>"
        ],
        "subject": "Watcher Notification",
        "body": {
          "text": "{{ctx.payload.hits.total}} error logs found"
        }
      }
    }
  }
}

以下是我从警报插件

获得的回复

    {
    "watch_id": "Alerting-Test",
    "state": "execution_not_needed",
    "_status": {
    "state": {
    "active": true,
    "timestamp": "2017-07-26T15:27:35.497Z"
    },
    "last_checked": "2017-07-26T15:27:38.625Z",
    "actions": {
    "logging": {
    "ack": {
    "timestamp": "2017-07-26T15:27:35.497Z",
    "state": "awaits_successful_execution"
    }
    }
    }
    },
    "trigger_event": {
    "type": "schedule",
    "triggered_time": "2017-07-26T15:27:38.625Z",
    "schedule": {
    "scheduled_time": "2017-07-26T15:27:38.175Z"
    }
    },
    "input": {
    "search": {
    "request": {
    "search_type": "query_then_fetch",
    "indices": [
    "test-1"
    ],
    "types": [
    "Test1"
    ],
    "body": {
    "query": {
    "match_all": {}
    }
    }
    }
    }
    },
    "condition": {
    "compare": {
    "ctx.payload.hits.hits.0.Value": {
    "gt": 450
    }
    }
    },
    "metadata": {
    "name": "Alerting-Test"
    },
    "result": {
    "execution_time": "2017-07-26T15:27:38.625Z",
    "execution_duration": 0,
    "input": {
    "type": "search",
    "status": "success",
    "payload": {
    "_shards": {
    "total": 5,
    "failed": 0,
    "successful": 5
    },
    "hits": {
    "hits": [
    {
    "_index": "test-1",
    "_type": "Test1",
    "_source": {
    "date": "2017-07-22T12:00:00.000Z",
    "LowerThreshold": "380",
    "Value": "350",
    "UpperThreshold": "450"
    },
    "_id": "AV1-1P3lArbJ1tbnct4e",
    "_score": 1
    },
    {
    "_index": "test-1",
    "_type": "Test1",
    "_source": {
    "date": "2017-07-22T18:00:00.000Z",
    "LowerThreshold": "380",
    "Value": "4100",
    "UpperThreshold": "450"
    },
    "_id": "AV1-1Sq0ArbJ1tbnct4v",
    "_score": 1
    },
    {
    "_index": "test-1",
    "_type": "Test1",
    "_source": {
    "date": "2017-07-24T18:00:00.000Z",
    "LowerThreshold": "380",
    "Value": "450",
    "UpperThreshold": "450"
    },
    "_id": "AV1-1eLJArbJ1tbnct6G",
    "_score": 1
    },
    {
    "_index": "test-1",
    "_type": "Test1",
    "_source": {
    "date": "2017-07-23T00:00:00.000Z",
    "LowerThreshold": "380",
    "Value": "400",
    "UpperThreshold": "450"
    },
    "_id": "AV1-1VUzArbJ1tbnct5A",
    "_score": 1
    },
    {
    "_index": "test-1",
    "_type": "Test1",
    "_source": {
    "date": "2017-07-23T12:00:00.000Z",
    "LowerThreshold": "380",
    "Value": "390",
    "UpperThreshold": "450"
    },
    "_id": "AV1-1X4FArbJ1tbnct5R",
    "_score": 1
    },
    {
    "_index": "test-1",
    "_type": "Test1",
    "_source": {
    "date": "2017-07-23T18:00:00.000Z",
    "LowerThreshold": "380",
    "Value": "390",
    "UpperThreshold": "450"
    },
    "_id": "AV1-1YySArbJ1tbnct5T",
    "_score": 1
    },
    {
    "_index": "test-1",
    "_type": "Test1",
    "_source": {
    "date": "2017-07-26T00:00:00.000Z",
    "LowerThreshold": "380",
    "Value": "4700",
    "UpperThreshold": "450"
    },
    "_id": "AV1-1mflArbJ1tbnct67",
    "_score": 1
    },
    {
    "_index": "test-1",
    "_type": "Test1",
    "_source": {
    "date": "2017-07-26T06:00:00.000Z",
    "LowerThreshold": "380",
    "Value": "390",
    "UpperThreshold": "450"
    },
    "_id": "AV1-1oluArbJ1tbnct7M",
    "_score": 1
    },
    {
    "_index": "test-1",
    "_type": "Test1",
    "_source": {
    "date": "2017-07-21T12:00:00.000Z",
    "LowerThreshold": "380",
    "Value": "400",
    "UpperThreshold": "450"
    },
    "_id": "AV1-1IrZArbJ1tbnct3r",
    "_score": 1
    },
    {
    "_index": "test-1",
    "_type": "Test1",
    "_source": {
    "date": "2017-07-21T18:00:00.000Z",
    "LowerThreshold": "380",
    "Value": "440",
    "UpperThreshold": "450"
    },
    "_id": "AV1-1LwzArbJ1tbnct38",
    "_score": 1
    }
    ],
    "total": 20,
    "max_score": 1
    },
    "took": 1,
    "timed_out": false
    },
    "search": {
    "request": {
    "search_type": "query_then_fetch",
    "indices": [
    "test-1"
    ],
    "types": [
    "Test1"
    ],
    "body": {
    "query": {
    "match_all": {}
    }
    }
    }
    }
    },
    "condition": {
    "type": "compare",
    "status": "success",
    "met": false,
    "compare": {
    "resolved_values": {
    **"ctx.payload.hits.hits.0.Value": null**
    }
    }
    },
    "actions": []
    },
    "messages": []
    }

非常感谢您的帮助!!

0 个答案:

没有答案