如何在NiFi中使用计数器的值 [英] How to use value of a counter in NiFi
问题描述
在NiFi 1.3.0中,我创建了一个流程来拆分JSON文件并更新名称为filenamecounter
的计数器,以便可以将每个拆分保存为不同的文件名.我在查看"NiFi计数器"窗格时看到计数器值得到更新.但是我该如何获取该值?
In NiFi 1.3.0, I have created a flow to split a JSON file and update the counter with name filenamecounter
so that I can save each split into different file names. I see that the counter value gets updated when I view the NiFi counters pane. But how can I access this value?
我尝试使用计数器名称和counters属性设置属性.类似于${filenamecounter}
和${filenamecounter.counter}
,但没有成功.
I tried setting an attribute with the counter name, and counters property. Like ${filenamecounter}
and ${filenamecounter.counter}
but unsuccessful.
推荐答案
当前计数器主要是一种监视功能,您不能真正从表达式语言访问它们.它们通常用于回答我从来源xyz收到了多少条消息?"之类的问题.
Currently counters are mostly a monitoring feature, you can't really access them from expression language. They're used to answer questions like "how many messages have I received from source xyz?".
对于您而言,所有拆分"处理器都应编写一组标准的片段属性:
In your case, all of the "split" processors should be writing a standard set of fragment attributes:
@WritesAttribute(attribute = "fragment.identifier",
description = "All split FlowFiles produced from the same parent FlowFile will have the same randomly generated UUID added for this attribute"),
@WritesAttribute(attribute = "fragment.index",
description = "A one-up number that indicates the ordering of the split FlowFiles that were created from a single parent FlowFile"),
@WritesAttribute(attribute = "fragment.count",
description = "The number of split FlowFiles generated from the parent FlowFile"),
因此,您应该可以在文件名中使用$ {fragment.index}.
So you should be able to use ${fragment.index} in your filename.
这篇关于如何在NiFi中使用计数器的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!