Fluentd 0.12中if条件配置求助:按TRAFFIC_TO新增字段
Fixing NEW_TRAFFIC Field Assignment in Fluentd 0.12 Record Transformer
I see the issue with your current record_transformer configuration — Fluentd 0.12 uses a specific syntax for conditional value assignment in the <record> block, and your approach of trying to do an inline assignment won't work. Let's fix this.
First, let's recap your requirement: map values of TRAFFIC_TO to NEW_TRAFFIC as follows:
blue-connectorprocess→webconnectorhttpRetrievedata→uiconnectorPromptConnector→checkconnector
Correct Configuration Using Conditional Expressions
Fluentd 0.12 expects you to return the desired value directly from the conditional expression, not perform an assignment inside it. Here's the working version using if/elsif:
<filter sla.**> @type record_transformer <record> NEW_TRAFFIC ${if record["TRAFFIC_TO"] == "blue-connectorprocess" then "webconnector" elsif record["TRAFFIC_TO"] == "httpRetrievedata" then "uiconnector" elsif record["TRAFFIC_TO"] == "PromptConnector" then "checkconnector" else nil end} </record> </filter>
Alternative: More Readable case Statement
If you prefer cleaner syntax for multiple conditions, use a case statement instead:
<filter sla.**> @type record_transformer <record> NEW_TRAFFIC ${case record["TRAFFIC_TO"] when "blue-connectorprocess" then "webconnector" when "httpRetrievedata" then "uiconnector" when "PromptConnector" then "checkconnector" else nil end} </record> </filter>
Key Notes to Ensure It Works:
- Strict String Matching: Make sure the values in
TRAFFIC_TOexactly match the strings in your conditions (including capitalization, likePromptConnector— if your log has a different case, adjust accordingly). - Validate Field Existence: Double-check that your prior regex parsing step correctly extracts the
TRAFFIC_TOfield into the record. If this field is missing, the conditional will default tonil(you can replacenilwith an empty string""if you prefer).
内容的提问来源于stack exchange,提问作者Puja
相关产品推荐
相关产品推荐

