User Guide
Metrics
Metrics are a great way to understand the performance and internal characteristics of your services and infrastructure.
Metoro Produced Metrics
Metoro has two sources of metrics which it makes available to you:
- eBPF metrics - These are collected by the in-cluster agents and provide detailed information about the performance of your services and infrastructure. This includes things like
- Network metrics at the container level
- Disk metrics at the container level
- CPU metrics at the container level
- Memory metrics at the container level
- Node level metrics
- And many many more...
- Prometheus metrics - Metoro scrapes Prometheus metrics from your services. This is useful if you already have Prometheus metrics in your services and want to use Metoro to visualize and query them in Metoro with the rest of your observability data.
You can check out all of the available metrics in the metric explorer
Custom metrics
Metoro supports sending custom metrics via the metoro exporter running in each cluster over the OTel http spec.
If you send your metrics to http://metoro-exporter.metoro.svc.cluster.local/api/v1/custom/otel/metrics
the exporter will forward them to Metoro and you'll be able to chart and visualize them like any other Metoro produced metric.
Example custom metric production
The python script below will publish two metrics to Metoro:
- custom_metrics.desired_replicas - The desired number of replicas for a deployment
- custom_metrics.available_replicas - The number of available replicas for a deployment
Both metrics are have a deployment attribute which is set to the name of the deployment
import sys
from kubernetes import client, config
from opentelemetry import metrics
from opentelemetry.exporter.otlp.proto.http.metric_exporter import OTLPMetricExporter
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.metrics.export import (
PeriodicExportingMetricReader,
)
# Main
if __name__ == "__main__":
metric_reader = PeriodicExportingMetricReader(
OTLPMetricExporter(endpoint="http://metoro-exporter.metoro.svc.cluster.local/api/v1/custom/otel/metrics")
)
provider = MeterProvider(metric_readers=[metric_reader])
# Sets the global default meter provider
metrics.set_meter_provider(provider)
# Creates a meter from the global meter provider
meter = metrics.get_meter(__name__)
config.load_kube_config()
namespace = sys.argv[1]
app = client.AppsV1Api()
deployment_data = app.list_namespaced_deployment(namespace)
desired_replicas = meter.create_gauge("custom_metrics.desired_replicas")
available_replicas = meter.create_gauge("custom_metrics.available_replicas")
for item in deployment_data.items:
desired_replicas.set(item.status.replicas, {"deployment": item.metadata.name})
available_replicas.set(item.status.available_replicas, {"deployment": item.metadata.name})
# Make sure that all the metrics are exported before the application exits
provider.force_flush()