Search code examples
jsonapache-nifi

Apache NiFi 9.0.0-m4 - trying to set a flow attribute from JSON content


I'm trying to get monitoringType out of this content and to set it in the flow attributes for use later in routing to a particular elastic index

    [ {
 ...
  "Average_Wait_on_Journal" : 0.007984,
  "monitoringType" : "PlexUtilisation",
  "@timestamp" : "2024-07-29T18:03:53.000Z",
  ...
} ]

My processor looks like this

evaluatejsonpath

The intended attribute does appear in the output, but has a value of "empty string set". Can anyone advise?

output in queue


Solution

  • I had not noted that when I retrieved "$" into an attribute called "All" (as per another question) that the JSON was in an array. Therefore when I tried to use jsonPath to get ${All .... "...on MQ"} from NiFi, the attribute $All it did not work. Creating "All" as $.[0] made everything work correctly. I hope that this helps someone.

    You could also call SplitJson beforehand