Custom metrics exporter for Flux in Kubernetes
Project description
Flux Metrics API
This is an experiment to create a metrics API for Kubernetes that can be run directly from the Flux leader broker pod. We made this after creating prometheus-flux and wanting a more minimalist design. I'm not even sure it will work, but it's worth a try!
Usage
Install
You can install from pypi or from source:
$ python -m venv env
$ source env/bin/activate
$ pip install flux-metrics-api
# or
$ git clone https://github.com/converged-computing/flux-metrics-api
$ cd flux-metrics-api
$ pip install .
# you can also do "pip install -e ."
This will install the executable to your path, which might be your local user bin:
$ which flux-metric-api
/home/vscode/.local/bin/flux-metrics-api
Note that the provided .devcontainer includes an environment for VSCode where you have Flux and can install this and use ready to go!
Start
You'll want to be running in a Flux instance, as we need to connect to the broker handle.
$ flux start --test-size=4
And then start the server. This will use a default port and host (0.0.0.0:8080) that you can customize if desired.
$ flux-metrics-api start
# customize the port or host
$ flux-metrics-api start --port 9000 --host 127.0.0.1
See --help
to see other options available.
Endpoints
Metric
GET /apis/custom.metrics.k8s.io/v1beta2/namespaces//metrics/<metric_name>
Here is an example to get the "node_up_count" metric:
curl -s http://localhost:8080/apis/custom.metrics.k8s.io/v1beta2/namespaces/flux-operator/metrics/node_up_count | jq
{
"items": [
{
"metric": {
"name": "node_up_count"
},
"value": 4,
"time": "",
"windowSeconds": 0,
"describedObject": null
}
],
"apiVersion": "custom.metrics.k8s.io/v1beta2",
"kind": "MetricValueList"
}
The following metrics are supported:
- node_up_count: number of nodes up in the MiniCluster
- node_free_count: number of nodes free in the MiniCluster
- node_cores_free_count: number of node cores free in the MiniCluster
- node_cores_up_count: number of node cores up in the MiniCluster
Docker
We have a docker container, which you can customize for your use case, but it's more intended to be a demo. You can either build it yourself, or use our build.
$ docker build -t flux_metrics_api .
$ docker run -it -p 8080:8080 flux_metrics_api
or
$ docker run -it -p 8080:8080 ghcr.io/converged-computing/flux-metrics-api
You can then open up the browser at http://localhost:8080/metrics/ to see the metrics!
😁️ Contributors 😁️
We use the all-contributors tool to generate a contributors graphic below.
Vanessasaurus 💻 |
License
HPCIC DevTools is distributed under the terms of the MIT license. All new contributions must be made under this license.
See LICENSE, COPYRIGHT, and NOTICE for details.
SPDX-License-Identifier: (MIT)
LLNL-CODE- 842614
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file flux-metrics-api-0.0.0.tar.gz
.
File metadata
- Download URL: flux-metrics-api-0.0.0.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0258d91c80ff555b0e6e3c7a0cdad1da1575f423d6cd399b13ff83bbae0537c4 |
|
MD5 | 26573a5fdf1d2a69b50af1e24cdf4e4f |
|
BLAKE2b-256 | 221706f110854bd42126ed4e090a29710ddb67d5651dd93fe81d3a796b325b64 |