Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

How to get specific fields from Json in Nifi JoltTransformJson?

avatar

I have nifi cluster summarry json data like this;

[{
	"nodeId": "29bed24c-6d73-4652-930b-0065cad4ef66",
	"address": "b1518aec7e38",
	"apiPort": 8080,
	"status": "CONNECTED",
	"heartbeat": "01/16/2019 16:24:32 UTC",
	"roles": ["Primary Node", "Cluster Coordinator"],
	"activeThreadCount": 0,
	"queued": "0 / 0 bytes",
	"events": [{
		"timestamp": "01/16/2019 15:21:50 UTC",
		"category": "INFO",
		"message": "Received first heartbeat from connecting node. Node connected."
	}, {
		"timestamp": "01/16/2019 15:21:48 UTC",
		"category": "INFO",
		"message": "Connection requested from existing node. Setting status to connecting."
	}],
	"nodeStartTime": "01/16/2019 15:20:44 UTC"
   },
   {
	"nodeId": "22aofpp4-87rf-asf4-930b-0065cad4ef66",
	"address": "b67uf98tkl5",
	"apiPort": 8080,
	"status": "CONNECTED",
	"heartbeat": "01/16/2019 16:24:32 UTC",
	"roles": [],
	"activeThreadCount": 0,
	"queued": "0 / 0 bytes",
	"events": [{
		"timestamp": "01/16/2019 15:21:50 UTC",
		"category": "INFO",
		"message": "Received first heartbeat from connecting node. Node connected."
	}, {
		"timestamp": "01/16/2019 15:21:48 UTC",
		"category": "INFO",
		"message": "Connection requested from existing node. Setting status to connecting."
	}],
	"nodeStartTime": "01/16/2019 15:20:44 UTC"
}]

I want only nodeId and status fields from this json. Output what i want;

{
   "nodeIds": ["node1Id", "node2Id"],
   "status": ["node1Status", "node2Status"]
}

For example output what i want;

{
   "nodeIds": ["29bed24c-6d73-4652-930b-0065cad4ef66", "22aofpp4-87rf-asf4-930b-0065cad4ef66"],
   "status": ["CONNECTED", "CONNECTED"]
}

But I couldn't do Jolt Specification for this. How can i do this?

1 ACCEPTED SOLUTION

avatar

I solved the problem. I used this solution;

[
  {
    "operation": "shift",
    "spec": {
    	"*": {
        	"nodeId": "node_ids",
          	"status": "node_status"
        }
    }
  }
]

View solution in original post

1 REPLY 1

avatar

I solved the problem. I used this solution;

[
  {
    "operation": "shift",
    "spec": {
    	"*": {
        	"nodeId": "node_ids",
          	"status": "node_status"
        }
    }
  }
]