2021-05-04 12:23:34 +00:00
|
|
|
package org.sysmon.collector;
|
|
|
|
|
|
|
|
import org.apache.camel.builder.RouteBuilder;
|
|
|
|
import org.apache.camel.model.rest.RestBindingMode;
|
2021-05-06 08:57:35 +00:00
|
|
|
import org.sysmon.shared.MetricResult;
|
2021-05-04 12:23:34 +00:00
|
|
|
|
|
|
|
public class CollectorRouteBuilder extends RouteBuilder {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void configure() throws Exception {
|
2021-05-04 15:54:47 +00:00
|
|
|
|
2021-05-04 12:23:34 +00:00
|
|
|
restConfiguration().component("jetty")
|
|
|
|
.bindingMode(RestBindingMode.auto)
|
|
|
|
.host("127.0.0.1")
|
|
|
|
.port(9925);
|
|
|
|
|
|
|
|
rest()
|
|
|
|
.get("/")
|
|
|
|
.produces("text/html")
|
|
|
|
.route()
|
|
|
|
.to("log:stdout")
|
|
|
|
.endRest();
|
|
|
|
|
|
|
|
rest()
|
|
|
|
.post("/metrics")
|
|
|
|
.consumes("application/json")
|
|
|
|
.produces("text/html")
|
2021-05-06 08:57:35 +00:00
|
|
|
.type(MetricResult.class)
|
2021-05-04 12:23:34 +00:00
|
|
|
.route()
|
2021-05-04 15:54:47 +00:00
|
|
|
.to("seda:inbound")
|
2021-05-04 12:23:34 +00:00
|
|
|
.endRest();
|
2021-05-04 15:54:47 +00:00
|
|
|
|
2021-05-06 11:26:53 +00:00
|
|
|
//from("seda:inbound").log("Got metric from: ${header.component}").to("mock:sink");
|
2021-05-06 08:57:35 +00:00
|
|
|
|
2021-05-04 15:54:47 +00:00
|
|
|
from("seda:inbound")
|
2021-05-06 11:26:53 +00:00
|
|
|
.log("Got metric from: ${header.component}")
|
|
|
|
.doTry()
|
|
|
|
.process(new MetricResultToPointProcessor())
|
|
|
|
.log("${body}")
|
|
|
|
.to("influxdb://myInfluxConnection?databaseName=sysmon&retentionPolicy=autogen")
|
|
|
|
.doCatch(Exception.class)
|
|
|
|
.log("Error storing metric to InfluxDB: ${exception}")
|
|
|
|
.end();
|
|
|
|
|
2021-05-04 15:54:47 +00:00
|
|
|
|
2021-05-04 12:23:34 +00:00
|
|
|
}
|
|
|
|
|
2021-05-04 15:54:47 +00:00
|
|
|
|
|
|
|
|
2021-05-04 12:23:34 +00:00
|
|
|
}
|