本文介绍了有没有办法在C#程序中从kafka服务器远程获取指标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前在C#中的项目需要从kafka服务器获取不足的复制分区数.我可以在jconsole的mbeans部分下查看此内容,但是我需要在c#程序中获取该值.我尝试将NetMX与这段代码结合使用以建立初始连接.

My current project in c# requires getting the number of under replicated partitions from a kafka server. I can view this in jconsole under the mbeans section, but I need to get the value in a c# program. I tried using NetMX with this code to make the initial connection.

AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
INetMXConnector connector = NetMXConnectorFactory.Connect(new Uri("http://<myserver>:<jmxport>"), null);
IMBeanServerConnection remoteServer = connector.MBeanServerConnection;

第二行引发找不到部分"错误,我想知道是否有人可以提供帮助?

A "Section not found" error is thrown at the second line and I was wondering if anyone could help with this please?

推荐答案

1)使用jolokia jar通过添加以下内容将JMX转换为HTTP:

1) Use jolokia jar to convert JMX to HTTP by adding:

2)现在您将获得一个http端点,您可以尝试获取示例请求以检查其是否有效 http://localhost:8778/jolokia/read//java. lang:type = Memory/HeapMemoryUsage

2) You will get a http endpoint now you can try a sample get request to check whether it workshttp://localhost:8778/jolokia/read//java.lang:type=Memory/HeapMemoryUsage

3)使用标准的REST API库在端点之上使用.

3) Use standard rest api libraries to consume above endpoint.

这篇关于有没有办法在C#程序中从kafka服务器远程获取指标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 18:28