问题描述
我试图在此处遵循示例
https://www.endgame.com/blog/blog/storm-metrics-how <
这是我的风暴.yaml
storm.zookeeper.servers: - localhost supervisor.slots.ports: - 6700 - 6701 - 6702 - 6703 - 6704 nimbus.host: localhost ui.port: 8080 ui.host: localhost storm.log.dir: /path/to/storm/logdir topology.max.spout.pending: 5000
我尝试以本地和群集模式运行拓扑. Metrics.log文件是在位置/path/to/storm/logdir上创建的,但是文件为空!我是否缺少一些配置?
推荐答案
问题是在风暴中的 log4j2 设置 中的设置中有点涉及.
问题
首先让我列出Storm的Jira中的一些错误.阅读问题和修复可以通过指标记录到手头上的问题上有很多光线:
- STORM-584 STORM-584整个集群共享指标log
- STORM-1673 LoggingMetricsConsumer的软件包> LoggingMetricsConsumer的软件包> LoggingMetricsConsumer错过的指标记录设置 /li>
- STORM-1767 STORM-1767使用完全合格的类名称命名logger会产生问题 > > > li>
总结以上情况:
- cluster.xml中的定义 logger是不正确的,因为使用worker.xml定义了工人记录器(正在记录的指标).因此,工人可能无法访问指标记录器的定义.它还创建了文件所有权问题 - 第一个日志指标将拥有日志文件,以防止其他工人中的其他登录器附加到指标日志文件.
- 包裹从backtype.storm.metric重命名为org.apache.storm.metric> org.apache.storm.metric intage intame diss worker.xml file.
- 最后,指标记录器被命名为org.apache.storm.metric.LoggingMetricsConsumer,这意味着在尝试在LoggingMetricsConsumer类中尝试创建它时,实际创建的记录器是附加到 root 的记录器logger和使用A1 appender而不是METRICS appender.
修复
我的实际修复程序涉及2件事(请注意,第一步是可选的)
-
log4j2 worker.xml和cluster.xml文件中的设置.
只需确保您的记录设置具有worker.xml中定义的度量记录器,就像它在此第二" fork" LoggingMetricsConsumer LoggingMetricsConsumer class class from github usting如上.
也请注意,还请注意,我的意思是 fork 我的意思是我将其源代码带入您的项目以修改该源代码所需的一切.您也可以定义自己的类实现IMetricsConsumer,只要您将其附加到拓扑上.一旦拥有自己的LoggingMetricsConsumer类,就必须修改其创建其指标记录仪的方式:public static final Logger METRICS_LOG = LoggerFactory.getLogger("METRICS_LOGGER");
最后一个注释如果您使用的是风暴的版本不同于1.0.0或2.0.0
只需确保您查看LoggingMetricsConsumer源代码以及您版本已删除的git分支中的worker.xml和cluster.xml的版本即可.该区域发生了很大变化,每个更改都不偏离兼容(软件包重命名,记录器移动).
问题描述
I am trying to follow the example here
https://www.endgame.com/blog/storm-metrics-how
here is my storm.yaml
storm.zookeeper.servers: - localhost supervisor.slots.ports: - 6700 - 6701 - 6702 - 6703 - 6704 nimbus.host: localhost ui.port: 8080 ui.host: localhost storm.log.dir: /path/to/storm/logdir topology.max.spout.pending: 5000
I tried running the topology in local and cluster mode. the metrics.log file is created at the location /path/to/storm/logdir but the file is empty! am i missing some configuration?
推荐答案
The problem is with the current log4j2 setup of Metrics in Storm and the fix is a little involved.
Issues
Firstly let me list some bugs from Storm's Jira. Reading the issues and fixes sheds a good amount of light onto the issue at hand with metrics logging:
- STORM-584 whole cluster is sharing the metrics log
- STORM-1673 package rename of LoggingMetricsConsumermissed metrics logger setup
- STORM-1767 naming logger using fully qualified class name creates problems
To summarise the situation above:
- Defining metrics logger in cluster.xml is not right as worker loggers (where metrics are being logged from) are defined using worker.xml. So it's possible that a worker will not have access to the metrics logger definition. It also creates problems of file ownership - the first worker to log metrics would own the log file preventing other loggers in other workers from appending to metrics log file.
- After the rename of the package from backtype.storm.metric to org.apache.storm.metric the package rename missed worker.xml file.
- Finally the metrics logger is named org.apache.storm.metric.LoggingMetricsConsumer which means that when trying to create it using LoggerFactory.getLogger(LoggingMetricsConsumer.class) inside the LoggingMetricsConsumer class, the logger that is actually created is a logger attached to ROOT logger and using A1 appender instead of METRICS appender.
The fix
The actual fix for me involved 2 things (please note that first step is optional)
Optionally sorting out log4j2 setup in worker.xml and cluster.xml files.
Simply make sure your logging setup has the metrics logger defined in worker.xml like it is in this github commit for Storm project fixing the STORM-1673 issue (which has made it to 1.0.0 and 2.0.0). Conversely please also make sure that the metrics logger is no longer defined in the cluster.xml file anymore.Renaming the metrics logger and forking LoggingMetricsConsumer class to point it at a newly renamed logger (unatached to root logger):
Firstly make sure your metrics logger in worker.xml file is no longer named org.apache.storm.metric.LoggingMetricsConsumer but say METRICS_LOGGER as per this snippet:<Logger name="METRICS_LOGGER" level="info" additivity="false"> <appender-ref ref="METRICS"/> </Logger>
Secondly "fork" LoggingMetricsConsumer class from the same github commit as above.
Please also note that by fork I mean whatever it takes to bring its source code into your project in order to modify it. You can also define your own class implementing IMetricsConsumer as long as you then attach it to your topology. Once you have your own LoggingMetricsConsumer class you have to modify the way it creates its metrics logger to:public static final Logger METRICS_LOG = LoggerFactory.getLogger("METRICS_LOGGER");
Last note if you are using version of Storm different than 1.0.0 or 2.0.0
Just make sure you look at the LoggingMetricsConsumer source code and the versions of worker.xml and cluster.xml from the git branch your version has been cut from. This area has changed a lot and each change is not backwards compatible (package rename, logger move).