[英]Filter the NIFI logs for monitor the nifi-application
对于 NIFI 默认情况下,监控是不存在的。 我正在尝试从 nifi-app.log 文件中过滤错误和处理器信息。 从 Unix 命令中,我可以看到 NIFI 中的错误日志格式如下。
2022-08-04 23:39:13,790 ERROR [Timer-Driven Process Thread-3] org.apache.nifi.processors.kudu.PutKudu PutKudu[id=b0fb3488-6c64-1d43-8c99-eada1eb75718] Failed to write due to Row error for primary key="ce70cb52-1c1e-4dd4-a8e1-3fb658dfef45\x00\x00c23e26d7-144f-4f5b-b47e-f9fe0050af30\x00\x00\x80\x00\x01\x82l\x9A\xA3\x90", tablet=null, server=null, status=Not found: ([0x0000000280000181B70EA800, 0x000000038000000000000001))
在日志上方,我从命令中过滤: cat nifi-app.log | grep ERROR
上面日志中的cat nifi-app.log | grep ERROR
:时间 - 2022-08-04 23:39:13
日志级别:错误
处理器:PutKudu
Processor_id:[id=b0fb3488-6c64-1d43-8c99-eada1eb75718]
异常:由于主键的行错误而无法写入 =“ce70cb52-1c1e-4dd4-a8e1-3fb658dfef45\x00\x00c23e26d7-144f-4f5b-b47e-f9fe0050af30\x00\x00\x80\x00\x01\x82l\x9A\ xA3\x90"
我将输入文件传递给 python 脚本并尝试以上述格式过滤信息,但似乎没有数据,我在脚本中使用以下命令。
time = re.search(r'\d{2}:\d{2}:\d{2}', content).group()
log_level = content.split("~")[1]
processor = content.split("~")[2].split("[id=")[0].split(" ")[len(content.split("~")[2].split("[id=")[0].split(" ")) -1]
processor_id = content.split("~")[2].split("[id=")[1].split("]")[0].replace("]","")
if len(content.split("~")[2].split("]")) > 0:
message = content.split("~")[2].split("]")[1].replace(",", ":")
我想要以下格式的新文件中的输出: print(log_level + "," + processor_id + "," + processor + "," + message + "," + date + "," + time)
<appender name="CUSTOM_APP_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${org.apache.nifi.bootstrap.config.log.dir}/custom-app.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${org.apache.nifi.bootstrap.config.log.dir}/custom-app_%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern> <maxFileSize>100MB</maxFileSize> <.-- keep 3 custom log files worth of history --> <maxHistory>3</maxHistory> </rollingPolicy> <immediateFlush>true</immediateFlush> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <pattern>%date~%level~%logger{40}~%msg%n</pattern> </encoder> </appender> <root level="INFO"> <appender-ref ref="CUSTOM_APP_FILE" /> </root>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.