LogoLogo
Python SDKSlack
  • Documentation
  • Cookbooks
  • Self-Hosting
  • Release Notes
  • Reference
  • API Reference
    • Overview
    • Python SDK
    • OpenTelemetry SDK
    • OpenInference SDK
    • Phoenix OSS
    • GraphQL API
      • Getting Started with GraphQL
      • How To Use GraphQL
        • Forming Calls
        • Using global node IDs
        • Querying Nested Data
        • Notebook Examples
        • Mutations
      • Admin API
      • Annotations API
      • Custom Metrics API
      • Dashboards API
      • File Importer API
      • Online Tasks API
      • Metrics API
      • Models API
      • Monitors API
      • Table Importer API
      • Resource Limitations
  • Export Data API
  • Prompt Hub API
  • Authentication & security
    • Arize Private Connect
    • API Keys
    • SSO & RBAC
      • Setting Up SSO with Okta
    • Compliance
      • Arize Audit Log
    • Whitelisting
Powered by GitBook

Support

  • Chat Us On Slack
  • support@arize.com

Get Started

  • Signup For Free
  • Book A Demo

Copyright © 2025 Arize AI, Inc

On this page
  • Creating a custom metric
  • Updating a custom metric
  • Querying a custom metric
  • Creating a monitor for a custom metric
  • Examples

Was this helpful?

  1. API Reference
  2. GraphQL API

Custom Metrics API

Use custom metrics to define a metric specific to your business use case or to your model. By using a programmatic API, you can automate the process of creating a custom metric, updating that metric, and creating monitors on that metric.

Learn more about custom metrics here.

For a brief overview of GraphQL itself, please consult our introduction.

Creating a custom metric

Creating a custom metric directly:

mutation {
  createCustomMetric(
    input: { 
      name: "prediction count", 
      description: "Returns the count of predictions over time", 
      modelId: "model_id", 
      metric: "SELECT COUNT(*) FROM model" 
  }) {
    customMetric {
      id
    }
  }
}

A more repeatable way to do this is to use query parameters:

# Query:
mutation myCustomMetricMutation($input: CreateCustomMetricMutationInput!) {
  createCustomMetric(input: $input) {
    customMetric {
      id
    }
  }
}

# Params:
{
    "input": { 
        "name": "prediction count", 
        "description": "Returns the count of predictions over time", 
        "modelId": "model_id", 
        "metric": "SELECT COUNT(*) FROM model"
    }
}

Note that error messages work the same in GraphQL as in the UI. For example, if my metric was this: SELECT COUNT(income) FROM model, I would get this error message in both the UI and the API:

{
  "errors": [
    {
      "message": "The custom metric failed to save: column \"income\" does not exist on line 1, column 13",
      ...

However, due to the ability to use auto complete and the model schema panel in the UI, we do encourage using the UI to create an initial custom metric before attempting to create one directly using the GraphQL API.

Updating a custom metric

mutation {
  updateCustomMetric(input: {
      customMetricId:"custom_metric_id",
      modelId:"model_id",
      name:"new custom metric name",
      description:"new description",
      customMetric:"SELECT avg(annual_income) FROM model"
  }) {    
    customMetric {
      id
    }
  }
}

Querying a custom metric

You can query for custom metrics associated with a model like this:

{
  node(id: "model_id") {
    ... on Model {
      customMetrics(first: 10) {
        edges {
          node {
            name
            metric
            description
          }
        }
      }
    }
  }
}

If you know the id of your custom metric - you can also query for it directly:

{
  node(id:"custom_metric_id"){
    ... on CustomMetric {
      id
      name
      description
      metric
    }
  }
}

Creating a monitor for a custom metric

To create a custom metric monitor - first get the custom metric id. This can come from the result of the createCustomMetricMutation above, or it can come from the URL of the custom metric:

app.arize.com/organizations/:org_id/spaces/:space_id/models/:model_id/custom_metrics/:custom_metric_id/

Then, use the createPerformanceMonitorMutation to create the monitor:

mutation {
  createPerformanceMonitor(input:{
     modelId: "model_id",
     customMetricId: "custom_metric_id",
     operator: greaterThan,
     name: "custom metric monitor"
  }){
    monitor{
      id
      uri
    }
  }
}

Examples

API Use Cases
Example Colabs

Create Custom Metrics With GraphQL

Update Custom Metrics With GraphQL

Last updated 1 day ago

Was this helpful?

In order to update a custom metric, use the updateCustomMetricMutation. Follow an example .

Users can monitor a custom metric using the performance monitor type. Follow an example .

To learn more about performance monitors - refer to our .

here
here
monitors API documentation here
Colab
Colab