how to apply condition on json response in NIFI

蓝咒 提交于 2021-02-05 11:55:23

问题


{


"alamrs": [
{ 
  "correlate": [
    " ", 
    " ", 
    " " 
  ], 
"event": " ", 
  "group": " ", 
  "history": [
    {
      "event": " ", 
      "href": " ", 
      "id": " ", 
      "resource": " abc ", 
      "status": " ", 
      "text": " ", 
      "type": " ", 
      "updateTime": " ", 
      "user": " ", 
      "value": "--"
    }
  ],

  "href": " ", 
  "id": "", 
  "rawData": null, 
  "receiveTime": " ", 
  "service": [
    " "
  ], 
"resource": "abc", 
  "status": " ", 
  "tags": [
    ""
  ], 
"text": " : ", 
  "timeout": , 
}, 
{ 
"correlate": [
    " ", 
    " ", 
    " " 
  ], 
"event": " ", 
  "group": " ", 
  "history": [
    {
      "event": " ", 
      "href": " ", 
      "id": " ", 
      "resource": " abc ", 
      "status": " ", 
      "text": " ", 
      "type": " ", 
      "updateTime": " ", 
      "user": " ", 
      "value": "--"
    }
  ],

  "href": " ", 
  "id": "", 
  "rawData": null, 
  "receiveTime": " ", 
  "service": [
    " "
  ],
"resource": "abc", 
  "status": " ", 
  "tags": [
    ""
  ], 
"text": " : ", 
  "timeout": , 
}, 
{ 
  "correlate": [
    " ", 
    " ", 
    " " 
  ], 
"event": " ", 
  "group": " ", 
  "history": [
    {
      "event": " ", 
      "href": " ", 
      "id": " ", 
      "resource": " abc ", 
      "status": " ", 
      "text": " ", 
      "type": " ", 
      "updateTime": " ", 
      "user": " ", 
      "value": "--"
    }
  ],
"href": " ", 
  "id": "", 
  "rawData": null, 
  "receiveTime": " ", 
  "service": [
    " "
  ], 
"resource": "abc", 
  "status": " ", 
  "tags": [
    ""
  ], 
  "text": " : ", 
  "timeout": , 
}

[here i have used http invoked processor which get alarm from web app ....the response of this processor is in json format ...actually i want this alarm get filter on the bases of resource =abc ..i meant to say the alarm that have the resource = abc which are store in text file ][routedonatrribute configration--property_name=condtion value=${alamrs.resource:equals('abc')}]1[evalutejsonpath---(property=destination- value=flowfile-attribute) (propety_name=condition value=$.alamrs.resource)]1[complete data flow]1[1]: https://i.stack.imgur.com/f0pCF.png


回答1:


I'd suggest using PartitionRecord with a JsonPathReader to send all records in the flowfile with /*[./alarms/resource=abc] to one relationship and the others to a different relationship.



来源:https://stackoverflow.com/questions/61919533/how-to-apply-condition-on-json-response-in-nifi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!