Reputation: 347
I have a Spring Boot application running on Cloud Foundry that exposes metrics and health info via the /metrics & /health endpoints respectively. I'd like to post these metrics as a continuous stream to an influxDB user provided service for visualization on a grafana dashboard. I am looking for any resources that explain how the dataflow would work and would appreciate any suggestions.
Thanks.
Upvotes: 10
Views: 10462
Reputation: 4818
InfluxDB (unlike Prometheus) is a push based system. It cannot poll a HTTP endpoint to collect metrics. Your application needs to contiguously/periodically push data into InfuxDB instance.
To push application into InfluxB, others have suggested libraries like influxdb-java, metrics-influxdb, etc.
There is one more (and much better IMO) solution.
You can have a look at a new library, developed by Spring team, called micrometer.
Micrometer is a metrics collection library with support for a huge number of TSDBs (Influx being one of them). It was first introduced in Spring 2, and has been since back-ported to Spring 1.3+.
Micrometer publishes all of default actuator metrics out of the box. It is super-easy to get started with. You can read about all the capabilities here.
Upvotes: 1
Reputation: 64039
As far as I know there is no ready made solution. However what you can do is implement a custom Exporter for InfluxDB.
The details of how to do this in Spring Boot can be found here. In essence what you need to implement is an exporter that converts the Spring Boot metrics data to InfluxDB's line protocol
Another possible solution would be to get the Spring Boot metrics into Dropwizard metrics and then use this external library for reporting the Dropwizard metrics into InfluxDB (or use the master branch of dropwizard metrics which already an InfluxDB backend).
Finally, if you want to forgo InfluxDB and instead save the data into Graphite's storage (Whisper database), you should check out this or this. Once the data is in Graphite, Grafana can easily visualize it as is shown here
Upvotes: 7
Reputation: 961
Telegraf meets your requirements. It pulls data from jolokia and save to InfluxDB.
All you need to do is enable actuator and jolokia for SpringbootApplication, it is easy to add dependency to your maven:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-core</artifactId>
</dependency>
After this you need configure telegraf to connect your web server and influxDB, here is an example config:
[tags]
dc = "local-1"
[agent]
interval = "10s"
[[inputs.jolokia]]
context = "/jolokia"
[[inputs.jolokia.servers]]
name = "catalog"
host = "{web server ip address}"
port = "{web server port}"
[[inputs.jolokia.metrics]]
name = "metrics"
mbean = "org.springframework.boot:name=metricsEndpoint,type=Endpoint"
attribute = "Data"
[outputs]
[outputs.influxdb]
url = "{http://influxdb:port}"
database = "telegraf"
precision = "s"
Make sure network of upper configuration is available, then you will get data in you influxDB.
Configure grafana to display the data stored in influxDB:
You will see the data on the panel.
Upvotes: 2
Reputation: 2237
There are two implementations possible with influxdb :-
a) For influxdb version <= 0.8.8 you can use metrics-influxdb jar to put your app time series data on running influxdb server.
b) For influxdb version > 0.8.8 you can use influxdb-java jar to put your app time series data on running influxdb server.
Now about how to install & manage influxdb with grafana you can follow following useful links :-
http://www.philipotoole.com/influxdb-and-grafana-howto/
http://blog.sflow.com/2014/12/influxdb-and-grafana.html
https://devops.profitbricks.com/tutorials/creating-a-grafana-and-influxdb-docker-container/
https://influxdb.com/docs/v0.6/ui/grafana.html
Upvotes: 1
Reputation: 1846
It might be possible to write a telegraf plugin to emit the metrics to InfluxDB. Otherwise, the influxdb-java library might simplify emitting the metrics directly from Spring Boot.
Upvotes: 3