Support Questions

Find answers, ask questions, and share your expertise

Nifi Issue - writing a JSON file to PutDynamoDb

Explorer

Hi,

I am new to using nifi. I am trying to use GetFile processor that points to a JSON file to land in the dynamodb table using a PutDynamoDb processor.

Here is the sample structure of the input json file:

{

"messageid": "1",

"field 1": "value 1",

"field 2": "value 2",

"field 3": "value 3",

"field 4": "value 4"

}

However, I am getting an error related to hash key values in the putdynamodb processor. Attached are the screenshots of the error message (1.jpeg) and the configuration settings (2.jpg) for the putdynamodb processor.

I am not sure if I am doing something wrong in the property settings.

Also, I am not sure what values the JSON Document Attribute property expects? I read the documentation but it is unclear.

Any help will be appreciated on the issues

1.jpg

2.jpg

Thanks, Jason

4 REPLIES 4

Super Guru
@Jason Sphar

as you have configured PutDynamoDB processor as

Hash Key Value

${messageid}

Extract the messageid value from the json record by using EvaluateJsonPath processor and keep as attribute to the flowfile.

92622-screen-shot-2018-10-02-at-62838-pm.png

Then use the matched relationship from EvaluateJsonPath processor to PutDynamoDB processor.

-

If the Answer helped to resolve your issue, Click on Accept button below to accept the answer, That would be great help to Community users to find solution quickly for these kind of issues.

Explorer
@Shu

Thank you for the response. It is working fine without any errors. However, when I go to the dynamodb table, the entire JSON object from the FlowFile lands under the property set in JSON Document Attribute (in this case, activity).

JSON Input:

{

"messageid": "1",

"application": "value 1",

"datetime": "value 2",

"dev": "value 3",

"activity": "value 4"

}

For example, I have the below in a field called activity in dynamodb table. Attached is a screenshot of the table in dynamodb (3.jpg)

Output in DynamoDB table under a field called 'activity':

{

"application" : {

"S" : "value 1"

},

"datetime" : {

"S" : "value 2"

},

"dev" : {

"S" : "value 3"

},

"activity" : {

"S" : "value 4"

},

"messageid" : {

"S" : "1"

}

}

I want the JSON contents of the FlowFile to land in DynamoDB as a record with a messageid and 4 fields with their respective values. I don't know if this is a bug or if I am using it incorrectly. Is there any workaround? Thanks!

3.jpg

Explorer

@Shu

Thank you for the response. It is working fine without any errors. However, when I go to the dynamodb table, the entire JSON object from the FlowFile lands under the property set in JSON Document Attribute (in this case, activity) for the PutDynamoDB processor. Attached is a screenshot of the table in dynamodb (3.jpg) 3.jpg

Sample JSON Input:

{

"messageid": "1",

"application": "value 1",

"datetime": "value 2",

"dev": "value 3",

"activity": "value 4"

}

Sample Output in DynamoDB table under a single field called 'activity':

{

"application" : {

"S" : "value 1"

},

"datetime" : {

"S" : "value 2"

},

"dev" : {

"S" : "value 3"

},

"activity" : {

"S" : "value 4"

},

"messageid" : {

"S" : "1"

}

}

I want the JSON contents of the FlowFile to land in DynamoDB as a record with a messageid and 4 fields with their respective values.

I don't know if this is a bug or if I am using it incorrectly. Is there any workaround?

Thanks in advance!

Explorer

@Shu

Thank you for the response. It is working fine without any errors. However, when I go to the dynamodb table, the entire JSON object from the FlowFile lands under the property set in JSON Document Attribute (in this case, activity) for the PutDynamoDB processor. Attached is a screenshot of the table in dynamodb (3.jpg) 3.jpg

Sample JSON Input:

{

"messageid": "1",

"application": "value 1",

"datetime": "value 2",

"dev": "value 3",

"activity": "value 4"

}

Sample Output in DynamoDB table under a single field called 'activity':

{

"application" : {

"S" : "value 1"

},

"datetime" : {

"S" : "value 2"

},

"dev" : {

"S" : "value 3"

},

"activity" : {

"S" : "value 4"

},

"messageid" : {

"S" : "1"

}

}

I want the JSON contents of the FlowFile to land in DynamoDB as a record with a messageid and 4 fields with their respective values.

I don't know if this is a bug or if I am using it incorrectly. Is there any workaround?

Thanks in advance!