Healthchecks.io API Wrapper for Java

API Wrapper for healthchecks.io

License

License

Categories

Categories

Java Languages
GroupId

GroupId

com.niklasarndt
ArtifactId

ArtifactId

healthchecksio-java
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

Healthchecks.io API Wrapper for Java
API Wrapper for healthchecks.io
Project URL

Project URL

https://github.com/niklas2810/healthchecksio-java
Source Code Management

Source Code Management

https://github.com/niklas2810/healthchecksio-java/tree/main

Download healthchecksio-java

How to add to project

<!-- https://jarcasting.com/artifacts/com.niklasarndt/healthchecksio-java/ -->
<dependency>
    <groupId>com.niklasarndt</groupId>
    <artifactId>healthchecksio-java</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.niklasarndt/healthchecksio-java/
implementation 'com.niklasarndt:healthchecksio-java:1.0.1'
// https://jarcasting.com/artifacts/com.niklasarndt/healthchecksio-java/
implementation ("com.niklasarndt:healthchecksio-java:1.0.1")
'com.niklasarndt:healthchecksio-java:jar:1.0.1'
<dependency org="com.niklasarndt" name="healthchecksio-java" rev="1.0.1">
  <artifact name="healthchecksio-java" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.niklasarndt', module='healthchecksio-java', version='1.0.1')
)
libraryDependencies += "com.niklasarndt" % "healthchecksio-java" % "1.0.1"
[com.niklasarndt/healthchecksio-java "1.0.1"]

Dependencies

provided (1)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.18.16

test (2)

Group / Artifact Type Version
org.slf4j : slf4j-simple jar 1.7.30
org.junit.jupiter : junit-jupiter jar 5.7.0

Project Modules

There are no modules declared in this project.

healthchecksio-java

Maven Central GitHub Build Javadoc Link

healthchecksio-java is a Java Library for the REST API of healthchecks.io (it supports private instances as well). For now, only client features (Pinging API) are supported. However, the Management API is on my ToDo-List!

You can find more information on how to set up and use this library down below.


Table of Contents:

Installation

healthchecksio-java is available on Maven Central. You can find alternative importing methods (as well as direct download options) there.

The Javadocs of this project are available here.

Maven:

<dependency>
  <groupId>com.niklasarndt</groupId>
  <artifactId>healthchecksio-java</artifactId>
  <version>1.0.1</version>
</dependency>

Gradle:

implementation 'com.niklasarndt:healthchecksio-java:1.0.1'

Quick Start

Creating a Healthchecks client is quite straightforward.

//Creates a new healthchecks.io pinging client for the specified UUID
HealthchecksClient client = Healthchecks.forUuid("<uuid>"); 

Use these commands to send events to healthchecks.io:

client.start(); //The job has just begun
client.success(); //The job was completed successfully
client.fail(); //The job failed unexpectedly
client.exitCode(5); //The job exited with a specific exit code. Non-Zero exit codes will trigger alerts.

Every method also supports an attached message:

client.fail("Could not execute the job: " + reason); //Sends this string to healthchecks.io, which will be visible on the dashboard

The same applies to the Manager:

HealthchecksManager manager = Healthchecks.manager("<api-key>");

Read more about the Management API in the wiki for further instructions, here's a quick example:

Check[] filteredChecks = manager.getExistingChecks("cron debian").get(); //Retrieve all checks with tags "cron" and "debian"

To find out more about using the API, visit the wiki!

This library has a slf4-api(https://mvnrepository.com/artifact/org.slf4j/slf4j-api) implementation which produces debug logging output. To prevent this from happening, add this line to your logback.xml:

<logger name="com.niklasarndt.healthchecksio" level="WARN"/>

From now on, only warnings will be added to your logs.

Advanced Usage

You can also use this library with your self-hosted instance. To do this, simply use a different constructor function!

HealthchecksClient client = Healthchecks.forUuid("https://healthchecks.example.com", "<uuid>"); 

The same scheme applies to the manager (wiki).

Contributing

If you have any questions regarding the project or spotted a bug, feel free to open an issue!

Pull requests are always very much appreciated, but I hope you'll forgive me if I'm slow to respond sometimes.

Dependencies

Unit Testing:

License

© Niklas Arndt 2020, MIT License

I do not own or claim any copyright of healthchecks.io. healthchecks.io is being created by Pēteris Caune and other contributors under the BSD 3-Clause Revised License.

Versions

Version
1.0.1
1.0.0