This is a Prometheus client in C which exports the hailstone sequence.
Go to file
Matthew Binning 800bdeaefe feat: Integrate a Prometheus C client
In the build code, the C library to interoperate with the Prometheus
metrics system is added. Now a heartbeat is published over that
connection.
2024-09-23 06:30:35 -07:00
cli.c feat: Integrate a Prometheus C client 2024-09-23 06:30:35 -07:00
cli.h feat: Integrate a Prometheus C client 2024-09-23 06:30:35 -07:00
Containerfile feat: Integrate a Prometheus C client 2024-09-23 06:30:35 -07:00
hailstone.c feat: Integrate a Prometheus C client 2024-09-23 06:30:35 -07:00
hailstone.h feat: Integrate a Prometheus C client 2024-09-23 06:30:35 -07:00
heartbeat.c feat: Integrate a Prometheus C client 2024-09-23 06:30:35 -07:00
heartbeat.h feat: Integrate a Prometheus C client 2024-09-23 06:30:35 -07:00
main.c feat: Integrate a Prometheus C client 2024-09-23 06:30:35 -07:00
Makefile feat: Integrate a Prometheus C client 2024-09-23 06:30:35 -07:00
metadata.h init: Create a working CLI application 2024-09-23 06:29:55 -07:00
README.md feat: Integrate a Prometheus C client 2024-09-23 06:30:35 -07:00

Hailstone

Project Hailstone is a system to test benchmark different middleware. At its core, there is a hailstone sequence generator. Those numbers are pushed through a NATS connection. Both the sender and the receiver log their times of sending and receiving. It exports these times as well as a basic heartbeat to Prometheus via the C API.

The hailstone sequence is tweakable with arguments The client can be controlled via signals once launched.

Build

docker build -f Containerfile -t hailstone .

Run

To view the CLI output, use the -i flag as below. To free up the terminal (e.g. only the metrics at the endpoint are of interest), dettach with the -d flag.

docker run --rm --name hailstone -tip 8000:8000 hailstone

Stop

If running interactively, send a SIGINT with Ctrl+c. If running dettached, simply stop with: docker stop hailstone

Test

curl http://localhost:8080/metrics also available from web browsers near you. On an additional command or a refresh, the heartbeat metric should increase.

Install

On the install target, the container may be run, or the client may be copied out of the container and run directly on the target host.

To run directly on a target host, the dynamically linked dependencies for a Prometheus client will need to be available on the target host. For a dpkg- based host (e.g. Debian, Ubuntu, etc.) follow the commands in the Containerfile. For installing libraries in a non-Debian (but typical Linux FHS), i.e. RHEL, use the below steps in place of the base stage of the Containerfile.

FROM ${BASE_IMAGE}:${BASE_VERSION} as base
ADD "https://github.com/digitalocean/prometheus-client-c/releases/download/v0.1.3/libprom-dev-0.1.3-Linux.tar.gz" ./
RUN tar -xzf libprom*.tar.gz && \
    rm libprom*.tar.gz && \
    mv libprom*/lib/* /usr/lib/ && \
    mv libprom*/include/* /usr/include