Local Metrics
Learn how to test and validate metrics collection in Seldon Core locally, including Prometheus setup and Grafana dashboards.
Run these examples from the samples folder at the root of the repo.
This notebook tests the exposed Prometheus metrics of model and pipeline servers.
Requires: prometheus_client and requests libraries.
See docs for full set of metrics available.
mlserver_metrics_host="0.0.0.0:9006"
triton_metrics_host="0.0.0.0:9007"
pipeline_metrics_host="0.0.0.0:9009"from prometheus_client.parser import text_string_to_metric_families
import requests
def scrape_metrics(host):
data = requests.get(f"http://{host}/metrics").text
return {
family.name: family for family in text_string_to_metric_families(data)
}
def print_sample(family, label, value):
for sample in family.samples:
if sample.labels[label] == value:
print(sample)
def get_model_infer_count(host, model_name):
metrics = scrape_metrics(host)
family = metrics["seldon_model_infer"]
print_sample(family, "model", model_name)
def get_pipeline_infer_count(host, pipeline_name):
metrics = scrape_metrics(host)
family = metrics["seldon_pipeline_infer"]
print_sample(family, "pipeline", pipeline_name)MLServer Model
Triton Model
Load the model.
Pipeline
Last updated
Was this helpful?

