Jmxtrans将Kafka指标发布到Cloudwatch

时间:2018-10-19 00:28:40

标签: amazon-web-services apache-kafka jmxtrans

我正在通过JMX端口使用Jmxtrans检索Kafka指标,并尝试将其发布到CloudWatch中。以下是我的Jmxtrans配置:

{
   "servers":[
      {
         "alias":"kafka_broker",
         "host":"localhost",
         "port":"9999",
         "queries":[
            {
               "obj":"kafka.controller:type=ControllerStats,name=LeaderElectionRateAndTimeMs",
               "attr":[
                  "99thPercentile",
                  "MeanRate"
               ],
               "resultAlias":"LeaderElectionRateTimeMs",
               "outputWriters":[
                  {
                     "@class":"com.googlecode.jmxtrans.model.output.CloudWatchWriter",
                     "settings":{
                        "namespace":"samplekafkanamespace",
                        "dimensions":[
                           {
                              "name":"InstanceId",
                              "value":"$InstanceId"
                           }
                        ]
                     }
                  }
               ]
            }
         ]
      }
   ]
}

还有我的/ etc / default / jmxtrans文件:

http_proxy=http://proxy.com:3128
https_proxy=https://proxy.com:3128
HTTPS_PROXY=https://proxy.com:3128
HTTP_PROXY=http://proxy.com:3128
NO_PROXY=169.254.169.254
no_proxy=169.254.169.254

但是Cloudwatch请求超时。我缺少设置吗?

2018-10-19 11:25:35 [jmxtrans-result-1] level com.googlecode.jmxtrans.jmx.ResultProcessor [ResultProcessor.java:65] - Could not write results [Result(attributeName=99thPercentile, className=com.yammer.metrics.reporting.JmxReporter$Timer, objDomain=kafka.controller, typeName=type=ControllerStats,name=LeaderElectionRateAndTimeMs, valuePath=[], value=0.0, epoch=1539908694623, keyAlias=LeaderElectionRateTimeMs), Result(attributeName=MeanRate, className=com.yammer.metrics.reporting.JmxReporter$Timer, objDomain=kafka.controller, typeName=type=ControllerStats,name=LeaderElectionRateAndTimeMs, valuePath=[], value=0.0, epoch=1539908694623, keyAlias=LeaderElectionRateTimeMs)] of query Query(objectName=kafka.controller:type=ControllerStats,name=LeaderElectionRateAndTimeMs, keys=[], attr=[99thPercentile, MeanRate], typeNames=[], resultAlias=LeaderElectionRateTimeMs, useObjDomainAsKey=false, allowDottedKeys=false, useAllTypeNames=false, outputWriterInstances=[com.googlecode.jmxtrans.model.output.support.ResultTransformerOutputWriter@10934918]) to output writer com.googlecode.jmxtrans.model.output.support.ResultTransformerOutputWriter@10934918
com.amazonaws.SdkClientException: Unable to execute HTTP request: Connect to monitoring.ap-southeast-2.amazonaws.com:443 [monitoring.ap-southeast-2.amazonaws.com/103.8.175.93] failed: connect timed out
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleRetryableException(AmazonHttpClient.java:1114)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1064)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:743)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:717)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:699)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:667)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:649)
        at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:513)
        at com.amazonaws.services.cloudwatch.AmazonCloudWatchClient.doInvoke(AmazonCloudWatchClient.java:1320)
        at com.amazonaws.services.cloudwatch.AmazonCloudWatchClient.invoke(AmazonCloudWatchClient.java:1296)
        at com.amazonaws.services.cloudwatch.AmazonCloudWatchClient.executePutMetricData(AmazonCloudWatchClient.java:1204)
        at com.amazonaws.services.cloudwatch.AmazonCloudWatchClient.putMetricData(AmazonCloudWatchClient.java:1181)
        at com.googlecode.jmxtrans.model.output.CloudWatchWriter$Writer.doWrite(CloudWatchWriter.java:147)
        at com.googlecode.jmxtrans.model.output.support.ResultTransformerOutputWriter.doWrite(ResultTransformerOutputWriter.java:53)
        at com.googlecode.jmxtrans.jmx.ResultProcessor$1.run(ResultProcessor.java:63)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)

有人熟悉此工具吗?

1 个答案:

答案 0 :(得分:0)

我设法通过在包装器配置中提供代理设置来利用Jmxstans。 我将参数添加为afterPass。 wrapper.conf位于Java Additional Parameter中:

/etc/jmxtrans/wrapper.conf