Skip to content

primelib/prometheus4j

Repository files navigation

Prometheus4J

Maven Central javadoc

A java client for the Prometheus REST API.

Installation

implementation("io.github.primelib:prometheus4j:<latestVersion>")

Click to view instructions for other build tools.

Usage

Consumer Specification Approach

PrometheusHTTPConsumerApi client = PrometheusHTTPFactory.create(spec -> {
    spec.api(PrometheusHTTPConsumerApi.class);
    spec.baseUrl("http://localhost:9090/api/v1");
    // optional auth
    spec.basicAuth(authSpec -> {
        authSpec.username("<username>");
        authSpec.password("<password>");
    });
});

RuleReadResponse alertingRules = client.readRules(spec ->{
    spec.type("alert")
});

Parameter Approach

PrometheusHTTPApi client = PrometheusHTTPFactory.create(spec -> {
    spec.api(PrometheusHTTPApi.class);
    spec.baseUrl("http://localhost:9090/api/v1");
    // optional auth
    spec.basicAuth(authSpec -> {
        authSpec.username("<username>");
        authSpec.password("<password>");
    });
});

RuleReadResponse alertingRules = client.readRules("alert");

NOTE: The Parameter Approach can break if the API changes. The Consumer Specification Approach is more resilient to API changes.

Links

License

Released under the MIT License.

About

Java Client for the Prometheus REST APIs.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages