如何在 NiFi 中使用计数器的值 [英] How to use value of a counter in NiFi

查看:35
本文介绍了如何在 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?

我尝试使用计数器名称和计数器属性设置属性.像 ${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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆