如何在NIFI中对JSON响应应用条件 [英] how to apply condition on json response in NIFI
问题描述
{
"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": ,
}
[这里我使用了http调用的处理器,该处理器从Web应用程序获取警报....此处理器的响应为json格式...实际上,我希望此警报基于资源= abc ..i得到过滤器表示具有资源= abc且存储在文本文件中的警报] [routedonatrribute configration--property_name = condtion value = $ {alamrs.resource:equals('abc')}] 1 [完整的数据流]
[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
推荐答案
我建议使用 /*[./alarms/resource=abc]
一种关系而其他关系则不同.
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.
这篇关于如何在NIFI中对JSON响应应用条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!