Taffrail is a python package that automatically discovers metrics providers in a Kubernetes cluster and exposes them via a simple interface. You can easily add custom metrics providers as well as override existing metrics endpoints.
Install taffrail using pip:
$ pip install taffrail
Create the client:
from kubernetes import client, config
from taffrail.taffrail_client import MetricsClient
config.load_kube_config()
metrics_client = MetricsClient(client)
response = metrics_client.get_metrics()
response = metrics_client.get_sources()
response = metrics_client.get_metrics_with_source('prometheus')
By default, taffrail will look for kube-state metrics endpoint at: /api/v1/namespaces/kube-system/services/kube-state-metrics:http-metrics/proxy/metrics. To override with a custom endpoint simply set the KUBE-STATE-METRICS-PATH env var.
Example:
$ export KUBE-STATE-METRICS-PATH="/api/v1/namespaces/default/services/kube-state-metrics:8080/proxy/metrics"
Currently, taffrail supports the following metrics providers:
- prometheus
- kube-state-metrics
- heapster
- metrics-server
See Taffrail Server