LogoLogo
WebsiteSlack
0.35
0.35
  • Get started
  • Clusters
    • Management
      • Auth
      • Create
      • Update
      • Delete
      • Environments
    • Instances
      • Multi-instance
      • Spot instances
    • Observability
      • Logging
      • Metrics
      • Alerting
    • Networking
      • Load balancers
      • VPC peering
      • HTTPS
      • Custom domain
    • Advanced
      • Setting up kubectl
      • Private Docker registry
      • Self hosted images
  • Workloads
    • Realtime APIs
      • Example
      • Handler
      • Configuration
      • Parallelism
      • Autoscaling
      • Models
      • Multi-model
        • Example
        • Configuration
        • Caching
      • Server-side batching
      • Metrics
      • Statuses
      • Traffic Splitter
        • Example
        • Configuration
      • Troubleshooting
    • Async APIs
      • Example
      • Handler
      • Configuration
      • TensorFlow Models
      • Metrics
      • Statuses
      • Webhooks
    • Batch APIs
      • Example
      • Handler
      • Configuration
      • Jobs
      • TensorFlow Models
      • Metrics
      • Statuses
    • Task APIs
      • Example
      • Definition
      • Configuration
      • Jobs
      • Metrics
      • Statuses
    • Dependencies
      • Example
      • Python packages
      • System packages
      • Custom images
    • Debugging
  • Clients
    • Install
    • Uninstall
    • CLI commands
    • Python client
Powered by GitBook
On this page
  1. Workloads
  2. Task APIs

Metrics

It is possible to export custom user metrics by adding the metrics_client argument to the task definition constructor. Below there is an example of how to use the metrics client.

Currently, it is only possible to instantiate the metrics client from a class task definition.

class Task:
    def __init__(self, metrics_client):
        self.metrics = metrics_client

    def __call__(self, config):
        # --- my task code here ---
        ...

        # increment a counter with name "my_metric" and tags model:v1
        self.metrics.increment(metric="my_counter", value=1, tags={"model": "v1"})

        # set the value for a gauge with name "my_gauge" and tags model:v1
        self.metrics.gauge(metric="my_gauge", value=42, tags={"model": "v1"})

        # set the value for an histogram with name "my_histogram" and tags model:v1
        self.metrics.histogram(metric="my_histogram", value=100, tags={"model": "v1"})

Note: The metrics client uses the UDP protocol to push metrics, so if it fails during a metrics push, no exception is thrown.

PreviousJobsNextStatuses

Last updated 3 years ago