使用自定义IScheduler时如何从远程Storm工作者向Graphite服务器发出指标?

问题描述 投票:0回答:1

我正在从Apache Storm到Graphite很好地收集指标。然后我开发了一个实现IScheduler接口的自定义调度程序,现在我无法收集任何指标。

这是我的scheduler

public class SiteAwareScheduler implements IScheduler {
    @Override
    public void prepare(Map conf) {
    }
    @Override
    public void schedule(Topologies topologies, Cluster cluster) {
        ....
    }
}

在storm.yaml文件中:

supervisor.scheduler.meta:
  site: "cluster"
storm.scheduler: "org.sense.storm.scheduler.SiteAwareScheduler"

我正在使用this library收集指标并将其发送到Graphite服务器。

public class MyTopology {
    config.put(YammerFacadeMetric.FACADE_METRIC_TIME_BUCKET_IN_SEC, 30);
    config.put(SimpleGraphiteStormMetricProcessor.GRAPHITE_HOST, "127.0.0.1");
    config.put(SimpleGraphiteStormMetricProcessor.GRAPHITE_PORT, 2003);
    config.put(SimpleGraphiteStormMetricProcessor.REPORT_PERIOD_IN_SEC, 10);
    config.put(Config.TOPOLOGY_NAME, "MqttSensorSumTopology");
    config.registerMetricsConsumer(MetricReporter.class, new MetricReporterConfig(".*", SimpleGraphiteStormMetricProcessor.class.getCanonicalName()), 1);
    ...
    TopologyBuilder topologyBuilder = new TopologyBuilder();
    ...
    topologyBuilder.setBolt(MqttSensors.BOLT_SENSOR_TICKET_SUM.getValue(), new SumSensorValuesWindowBolt(SensorType.COUNTER_TICKETS).withTumblingWindow(Duration.seconds(5)), 1)
.shuffleGrouping(MqttSensors.SPOUT_STATION_01_TICKETS.getValue())
.addConfiguration(TagSite.SITE.getValue(), TagSite.CLUSTER.getValue());
}

public class SumSensorValuesWindowBolt extends BaseWindowedBolt {
    public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) {
        StormYammerMetricsAdapter.configure(stormConf, context, new MetricsRegistry());
        this.collector = collector;
    }
    public void execute(TupleWindow inputWindow) {
        ...
    }
}

IScheduler的“prepare”方法没有TopologyContext,因此我不知道在哪里用新的计划实例化我的指标。

任何提示?谢谢费利佩

apache-storm scheduling graphite graphite-carbon
1个回答
0
投票

我在这个link上安装了Graphite。然后我在两台机器上的link中配置文件storm.yaml。主人和工人。

storm.metrics.reporters:
  # Graphite Reporter
  - class: "org.apache.storm.metrics2.reporters.GraphiteStormReporter"
    daemons:
        - "supervisor"
        - "nimbus"
        - "worker"
    report.period: 60
    report.period.units: "SECONDS"
    graphite.host: "localhost"
    graphite.port: 2003

然后,度量标准将以我的拓扑MqttSensorSumTopology-1-1553506290的名称显示在Graphite服务器上。 enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.