Custom Metrics API
Learn how to query, create, and update custom metrics programmatically
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:
A more repeatable way to do this is to use query parameters:
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:
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
In order to update a custom metric, use the updateCustomMetricMutation
. Follow an example here.
Querying a custom metric
You can query for custom metrics associated with a model like this:
If you know the id of your custom metric - you can also query for it directly:
Creating a monitor for a custom metric
Users can monitor a custom metric using the performance monitor type. Follow an example here.
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:
Examples
API Use Cases | Example Colabs |
---|---|
Create Custom Metrics With GraphQL | |
Update Custom Metrics With GraphQL |
To learn more about performance monitors - refer to our monitors API documentation here.
Last updated