简体   繁体   中英

Showing HTTP Request API latency using the Spring Boot Micrometer metrics

We use Prometheus to scrape Spring Boot 2.0.0 metrics and then persist them in InfluxDB. We then use Grafana to visualize them from InfluxDB.

Our micrometer dependencies are

  • micrometer-core
  • micrometer-registry-prometheus

I want to be able to show a latency metric for our REST APIs.

From our Prometheus scraper I can see these metrics are generated for HTTP requests.

  • http_server_requests_seconds_count
  • http_server_requests_seconds_sum
  • http_server_requests_seconds_max

I understand from the micrometer documentation, https://micrometer.io/docs/concepts#_client_side , that latency can be done by combining 2 of the above generated metrics: totalTime / count.

However our data source is InfluxDB which does not support combining measurements, https://docs.influxdata.com/influxdb/v1.7/troubleshooting/frequently-asked-questions/#how-do-i-query-data-across-measurements , so I am unable to implement that function in InfluxDB.

Do I need to provide my own implementation of this latency metric in the Spring Boot component or is their an easier way that I can achieve this?

You essentially can join your measurements in Kapacitor, another component of Influxdata TICK stack.

It's going to be pretty simple with JoinNode , possibly followed by Eval to calculate what you want right in place. There's tons of examples around it in documentation.

Although the problem is different there: you'd unnecessarily overingeneered your solution, and moreover - you're trying to combine two products that has the same purpose, but uses different approach to it. How smart is that?

You're already scraping things with Prometheus? Fine! Stay with it, do the math there, it's simple. And Grafana works with Prometheus too, right out of the box!

You wanna have your data in Influx (I can understand that, it's certainly more advanced)? Fine! Micrometer can send it right to Influx out of the box - and in at least two ways!

I, personally, don't see any reason to do what you suppose to do, can you share one?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM