如何配置NiFi InvokeHTTP向ClickHouse发送POST插入请求
Got it, let's walk through exactly how to map your working curl command to NiFi's InvokeHTTP processor. Your curl command is essentially sending an INSERT statement as raw binary data via POST to your ClickHouse endpoint—here's how to replicate that in NiFi:
Already Set Correctly
You've got these right, just double-check the URL includes the trailing ? (your curl command uses http://xxx.xxx.xxx.xxx:8123/?):
- HTTP Method: POST
- Remote URL:
http://xxx.xxx.xxx.xxx:8123/?
Key Missing Configurations
1. Content Type
Since you're sending plain SQL text to ClickHouse, set the Content-Type property under "HTTP Headers" to:text/plain
This matches the raw text payload your curl command sends.
2. Request Body
You mentioned your INSERT statement is stored in a NiFi attribute (let's assume the attribute name is sql.insert.statement for this example). In the Request Body field, reference that attribute directly:${sql.insert.statement}
If you're hardcoding the value instead of using an attribute, paste the full INSERT statement here:INSERT INTO default.PERFTEST_BUFFER VALUES (1, '2020-04-09 19:06:02', 48.8644, 'A')
3. Request Body Handling
To match curl's --data-binary @- behavior (sending raw, unencoded data), set Request Body Handling to:Set Request Body from Attribute/Value
This ensures NiFi sends the exact content of your attribute/value without modifying it.
4. Optional: Additional Headers
Your original curl command doesn't use any extra headers, so you can leave Additional HTTP Headers blank unless your ClickHouse instance requires authentication or other custom headers (like Authorization if you have access controls enabled).
Quick Validation Tip
After configuring, run the processor and check the NiFi logs or use a tool like Wireshark to verify the outgoing request matches your curl command. The request body should be your full INSERT statement, and the Content-Type header should be text/plain.
内容的提问来源于stack exchange,提问作者Stephane

