I believe that I have the needed dependencies:
Код: Выделить всё
4.0.0
org.springframework.boot
spring-boot-starter-parent
3.5.0
com.example
question
0.0.1-SNAPSHOT
rest-service-complete
Demo project for Spring Boot
24
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-actuator
io.micrometer
micrometer-registry-prometheus
io.prometheus
simpleclient_pushgateway
org.springframework.boot
spring-boot-maven-plugin
< /code>
Вот фиктивные классы, генерирующие пользовательские метрики, поверх метрики пружины по умолчанию: < /p>
@RestController
public class GreetingController {
private static final String template = "Hello, %s!";
private final AtomicLong counter = new AtomicLong();
private final MeterRegistry registry;
// Use constructor injection to get the MeterRegistry
public GreetingController(MeterRegistry registry) {
this.registry = registry;
}
@GetMapping("/greeting")
public Greeting greeting(@RequestParam(value = "name", defaultValue = "World") String name) {
registry.counter("greetings.total", "name", name).increment();
return new Greeting(counter.incrementAndGet(), String.format(template, name));
}
}
Код: Выделить всё
management.prometheus.metrics.export.pushgateway.address=https://prometheus-prod-13-prod-us-east-0.grafana.net/api/prom/push
management.prometheus.metrics.export.pushgateway.username=1234567
management.prometheus.metrics.export.pushgateway.password=glc_abc
Тот же проект, изменение PromeTeus на oTl Однако, используя Prometheus, ничто не отправлено в Прометею.>
Подробнее здесь: https://stackoverflow.com/questions/796 ... sing-pushg