apache-nifi - 如何将自定义属性添加到 AttributesToJSON?
问题描述
我有一个场景,其中文件列表来自前一个处理器,对于每个文件,我必须创建具有流文件属性的 json 文件。在 AttributesToJSON 处理器配置中,有一个提取管道属性的选项,可以创建 json 文件/对象,如果我们将 Include Core Attributes 设置为 true,它将读取一些文件属性并形成 json 文件。
the out for the above case in my scenario is …
{"fragment.size":"125"
file.group:"root",
file.lastModifiedTime:"2020-12-22T15:09:13+0000",
fragment.identifier:"ee5770ea-8406-400a-a2fd-2362bd706fe0",
fragment.index:"1",
file.creationTime:"2020-12-22T15:09:13+0000",
file.lastAccessTime:"2020-12-22T17:34:22+0000",
segment.original.filename:"Sample-Spreadsheet-10000-rows.csv",
file.owner:"root",
fragment.count:"2",
file.permissions:"rw-r--r--",
text.line.count:"1"}
}
But the files has other properties, like absolute.path, filename, uuid are missing in the above json file.
My requirement is, get the absolute.path, filename and uuid and concatenate absolute.path+/+filename, assign this to custom attribute say filepath:absolute.path+/+filename and also add uuid to json object.
所以我的 json 文件应该像
{ uuid:"file uuid value", filepath:"absolute.path+/+filename" } 获取上述 json 文件的任何输入。
解决方案
UpdateAttribute
在传递给之前使用处理器删除不必要的属性,AttributestoJSON
或者您也可以在attributesToJSON
处理器中指定您需要的确切属性。
推荐阅读
- centos7 - 你如何在 centos 6/7 服务器上运行 puppeteer chromium/chrome `headless:false`
- c# - 使用 EF Core 和 OData,应用程序如何按相关实体中的属性进行排序?
- python - Python Web Scraping - 导航到下一页链接并获取数据
- redux - 如何获得 graphql refetchQueries 的结果?
- vue.js - 在这种情况下,有没有办法让转义字符在 Vue.js 中工作?
- python - 如何在python中查找数据框中文本的大小
- android - 如何使用 AsyncTask 中的用户 ID 获取当前登录的用户
- java - 从 xml 文件 www.bnr.ro java 中获取值
- python - Django注释没有为多对多字段提供值
- php - 如何超链接有帖子的日历日