spring-boot-starter-prometheus

Metrics endpoint prometheus.io format for Spring Boot

License

License

Categories

Categories

Spring Boot Container Microservices Prometheus Application Testing & Monitoring Monitoring
GroupId

GroupId

ru.vyukov
ArtifactId

ArtifactId

spring-boot-starter-prometheus
Last Version

Last Version

0.1
Release Date

Release Date

Type

Type

jar
Description

Description

spring-boot-starter-prometheus
Metrics endpoint prometheus.io format for Spring Boot
Project URL

Project URL

https://github.com/akaGelo/spring-boot-starter-prometheus
Project Organization

Project Organization

Pivotal Software, Inc.
Source Code Management

Source Code Management

https://github.com/akaGelo/spring-boot-starter-prometheus

Download spring-boot-starter-prometheus

How to add to project

<!-- https://jarcasting.com/artifacts/ru.vyukov/spring-boot-starter-prometheus/ -->
<dependency>
    <groupId>ru.vyukov</groupId>
    <artifactId>spring-boot-starter-prometheus</artifactId>
    <version>0.1</version>
</dependency>
// https://jarcasting.com/artifacts/ru.vyukov/spring-boot-starter-prometheus/
implementation 'ru.vyukov:spring-boot-starter-prometheus:0.1'
// https://jarcasting.com/artifacts/ru.vyukov/spring-boot-starter-prometheus/
implementation ("ru.vyukov:spring-boot-starter-prometheus:0.1")
'ru.vyukov:spring-boot-starter-prometheus:jar:0.1'
<dependency org="ru.vyukov" name="spring-boot-starter-prometheus" rev="0.1">
  <artifact name="spring-boot-starter-prometheus" type="jar" />
</dependency>
@Grapes(
@Grab(group='ru.vyukov', module='spring-boot-starter-prometheus', version='0.1')
)
libraryDependencies += "ru.vyukov" % "spring-boot-starter-prometheus" % "0.1"
[ru.vyukov/spring-boot-starter-prometheus "0.1"]

Dependencies

compile (5)

Group / Artifact Type Version
io.prometheus : simpleclient_common jar 0.0.17
org.springframework.boot : spring-boot-starter jar 1.4.1.RELEASE
org.springframework.boot : spring-boot-starter-web jar 1.4.1.RELEASE
org.springframework.boot : spring-boot-starter-actuator jar 1.4.1.RELEASE
org.springframework.boot : spring-boot-configuration-processor Optional jar 1.4.1.RELEASE

test (5)

Group / Artifact Type Version
junit : junit jar 4.12
org.assertj : assertj-core jar 2.5.0
org.mockito : mockito-core jar 1.10.19
org.hamcrest : hamcrest-library jar 1.3
org.springframework : spring-test jar

Project Modules

There are no modules declared in this project.

spring-boot-starter-prometheus

Maven Central

#Quick start

  1. dependency
<dependency>
	<groupId>ru.vyukov</groupId>
	<artifactId>spring-boot-starter-prometheus</artifactId>
	<version>0.1</version>
</dependency>
  1. Add annotation to enable @EnablePrometheus
@EnablePrometheus
@SpringBootApplication
public class SpringBootApplication {
....
}

Russian

Это реализация metrics endpoint для Spring Boot Actuator в текстовом формате применяемом в Prometheus.

Экспортирует все зарегистрированные метрики.

Возвращает HTTP Status 200 если health check в статусе UP и 500 если в статусе down или unknown. Это используется Prometheus для определения состояния.

Принятые правила именовая метрик отличаются в Spring и Prometheus, поэтому я слегда модифицировал их в этом endpoint.

Пример: К "heap" дописаны единицы изменения, в результате метрика heap называется heap_bytes. Использовать рекомендации prometheus собирая метрики в _total смысла не вижу, документация spring станет неудобна.

Чтобы отключить или изменить это поведение нужно определить свой экземпляр PrometeusMetricNameConverter. Реализацию текущего поведения можно найти в DefaultPrometeusMetricNameConverter

English

This is the implementation of metrics endpoint for Spring Boot Actuator in the text format applied in Prometheus.

It exploits all the registered metrics.

It returns HTTP Status 200 if health check is in the status UP and 500 if it is in the status down or unknown. It is used in Prometheus to identify the status.

The accepted rules of naming the metrics are different in Spring and Prometheus, that’s why I’ve slightly modified them in this endpoint. For example, there are some added units to "heap", as a result, the metric heap is called heap_bytes.

In order to turn off or change this behaviour it is necessary to define your instance of PrometeusMetricNameConverter. It’s possible to find the implementation of the current behaviour in DefaultPrometeusMetricNameConverter.

Versions

Version
0.1