Member since
05-17-2017
23
Posts
1
Kudos Received
0
Solutions
11-08-2017
09:38 AM
I have a Nifi standalone Node secure with LDAP provider. And I have 2 users: admin with all privilege and another user A with view/modify component. When login by admin account, I create a Process Group name Admin_Flow Although I grant Access Policies for process group Admin_Flow just for admin (view/modify,..) When login by user A account, Although I can not see name of Process Group and it has dashed border but I still double click to that Process Group to go inside it. When going inside Admin_Flow, I still can modify processors here. What policy I granted for user A that user A can go inside process group although user A has no view/modify policy?
... View more
Labels:
- Labels:
-
Apache NiFi
10-30-2017
03:41 AM
Thank you for useful article @Bryan Bende, After reading your post, I confuse some points that HOW and WHERE to configure properties: Max Batch Size, Max Size of Message Queue, Max Size of Socket Buffer. My flowfile: Data Producer --> JettyWebsocketServer --> ListenWebsocket --> Flowfile So I don't know how and where to configure above properties. Where is Message Queue between Channel Reader and Listen Processor? I just only configure JettyWebsocketServer(Input Buffer Size, Max Text Messsage Size) and ListenWebsocket has no properties relating to Queue Size. Thanks,
... View more
10-24-2017
06:39 AM
Thanks @Abdelkrim Hadjidj, It works well. It is interesting when just use $.* to capture content. I understood more about JsonPath Expression. Thank you again, :d
... View more
10-20-2017
04:34 AM
@Abdelkrim Hadjidj Today I have a solution for just my case: Because the key of our data is unique string on json data. So here my step to capture both key and value of json data: Step 1: Using ExtractText to obtain key (project_1, project_2,...) Step 2: Using ReplaceText to replace key on json data by a static key (project_1, project_2,... string will be replaced by content string. Step 3: Using EvaluateJsonPath to obtain data of content above and transform it to flowfile-content for next processor. Step 4: Using PutMongoDB to insert data into corresponding database using Expression Regex {projectname} with data above. As alternatively way, we also can use ExecuteScript to convert key and value of json data to attribute then insert into MongoDB. But as I running, the throughput when use the first way is higher then using ExecuteScript. Here my code when using ExecuteScript: #!/usr/bin/python3
import json
import java.io
from org.apache.commons.io import IOUtils
from java.nio.charset import StandardCharsets
from org.apache.nifi.processor.io import StreamCallback
class StreamCallback(StreamCallback):
def __init__(self):
pass
def process(self, inputStream, outputStream):
text = IOUtils.toString(inputStream, StandardCharsets.UTF_8)
data = json.loads(text)
for key in data:
first = key
break
content = data[first]
contentString = json.dumps(content)
viewFlowFile = session.create()
viewFlowFile = session.putAllAttributes(viewFlowFile,
{'project': str(first), 'content': contentString})
session.transfer(viewFlowFile, REL_SUCCESS)
flowFile = session.get()
if flowFile != None:
flowFile = session.write(flowFile, StreamCallback())
session.transfer(flowFile, REL_FAILURE)
session.commit()
... View more
10-19-2017
03:21 AM
@Abdelkrim Hadjidj, As your suggestion, I already got project_1, project_2... under the name: projectname. And it is an attribute of incoming flowfile for EvaluateJsonPath. But when I try to get value of above key, I add property content with value: $.${projectname} Output flowfile of EvaluateJsonPath has content attribute is empty string. I think EvaluateJsonPath uses JsonPath expression and It doesn't know variable "projectname" attribute of incoming flowfile.
... View more
10-18-2017
10:56 AM
Thanks @Abdelkrim Hadjidj, Although using regex with dynamic key seem difficult for me. I will try this. However as you see, the data to insert into MongoDB is value of key, it is not whole incoming data. (not include "project_1"...) So we need to capture this data too. And it will be very difficult to obtain value of key if also using regex. I need to capture both key and value separately. 😞
... View more
10-18-2017
09:50 AM
Hi @Abdelkrim Hadjidj After routing, the rest of flow is json string like: {
"host": "V001",
"data": [{
"sensor_code": "temp",
"value": {
"max": 26.2,
"avg": 26.1,
"min": 26.1
}
},
{
"sensor_code": "humid",
"value": {
"max": 48.8,
"avg": 48.7,
"min": 48.6
}
}]
}<br> It is value of key "project_1", "project_2",.... For my case, I will use key as database name on MongoDB. Example: Value of data from project_1 will be insert into database project_1. Value of data from project_2 will be insert into database project_2. Because PutMongo processor of Nifi version 1.4.0 currently supports expression language. So if I can capture key of data I can insert into corresponding database using ${key} Please help me if you have any suggestion. Thanks, Kiem
... View more
10-18-2017
03:48 AM
Thanks @Shu Please let me clarify my problem. Because I don't know key before. So I need to create a FlowFile which can run with dynamic key without stopping Job when having a data with new key. If we know certainly list of key, I think we can use EvaluateJsonPath to pull key into Attribute and use RouteOnAttribute as alternative way. Again, my problem is I don't know when new key incoming to stop Job and add more key into RouteOnContent as your way.
... View more
10-17-2017
10:10 AM
I have json data listen from JettyWebsocketServer like: {
"project_1": {
"host": "V001",
"data": [{
"sensor_code": "temp",
"value": {
"max": 26.2,
"avg": 26.1,
"min": 26.1
}
},
{
"sensor_code": "humid",
"value": {
"max": 48.8,
"avg": 48.7,
"min": 48.6
}
}]
}
}
Because my data from multiple project, so I have dynamic key as: project_1, project_2. And I have to route those data into corresponding destination. I found EvaluateJsonPath to parse Json data but it need static key. There is any way to capture both key and value of it to route data by key?
... View more
Labels:
- Labels:
-
Apache NiFi
10-13-2017
09:01 AM
Thanks for your detail @Abdelkrim Hadjidj After researching, I also have a summary as yours. We have 2 normal way to load balance Firstly, using a HA proxy between Nifi cluster and client In other hand, we can use one node for reception then forward data to S2S and RPG to distribute.
... View more