## Resource: OnlineEvaluator

An OnlineEvaluator contains the configuration for an Online Evaluation.
Fields `name` `string` Identifier. The resource name of the OnlineEvaluator. Format: projects/{project}/locations/{location}/onlineEvaluators/{id}.
`agentResource` `string` Required. Immutable. The name of the agent that the OnlineEvaluator evaluates periodically. This value is used to filter the traces with a matching cloud.resource_id and link the evaluation results with relevant dashboards/UIs.

This field is immutable. Once set, it cannot be changed.
`metricSources[]` ``object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#MetricSource`)`` Required. A list of metric sources to be used for evaluating samples. At least one MetricSource must be provided. Right now, only predefined metrics and registered metrics are supported.

Every registered metric must have `displayName` (or `title`) and `scoreRange` defined. Otherwise, the evaluations will fail.

The maximum number of `metricSources` is 25.
`config` ``object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#Config`)`` Required. Configuration for the OnlineEvaluator.
`state` ``enum (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#State`)`` Output only. The state of the OnlineEvaluator.
`stateDetails[]` ``object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#StateDetails`)`` Output only. Contains additional information about the state of the OnlineEvaluator. This is used to provide more details in the event of a failure.
`createTime` ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Output only. timestamp when the OnlineEvaluator was created.

Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`.
`updateTime` ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Output only. timestamp when the OnlineEvaluator was last updated.

Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`.
`displayName` `string` Optional. Human-readable name for the OnlineEvaluator.

The name doesn't have to be unique.

The name can consist of any UTF-8 characters. The maximum length is `63` characters. If the display name exceeds max characters, an `INVALID_ARGUMENT` error is returned.
`data_source` `Union type` Required. The data source used to query samples for evaluations. More data sources will be supported in the future.

The data source type is immutable once set. Within `cloud_observability`, `log_view` and `trace_view` can be updated; the `eval_scope` and `convention` are immutable. Within `bigquery_agent_analytics`, `result_table` can be updated; `source_table`, `scope` and `multi_turn_config` are immutable. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response:
`cloudObservability` ``object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#CloudObservability`)`` data source for the OnlineEvaluator, based on Google Cloud Observability stack (Cloud Trace \& Cloud Logging).
End of mutually exclusive fields.

| JSON representation |
|---|
| ``` { "name": string, "agentResource": string, "metricSources": [ { object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#MetricSource`) } ], "config": { object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#Config`) }, "state": enum (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#State`), "stateDetails": [ { object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#StateDetails`) } ], "createTime": string, "updateTime": string, "displayName": string, // data_source "cloudObservability": { object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#CloudObservability`) } // Union type } ``` |

## CloudObservability

data source for the OnlineEvaluator, based on Google Cloud Observability stack (Cloud Trace \& Cloud Logging).
Fields `logView` `string` Optional. Optional log view that will be used to query logs. If empty, the project's default view (`projects/{projectId}`) will be used.
`traceView` `string` Optional. Optional trace view that will be used to query traces. If empty, the `_AllSpans` view from `_Trace` US bucket will be used, i.e. `projects/{projectId}/locations/us/buckets/_Trace/datasets/Spans/views/_AllSpans`.
`eval_scope` `Union type` Required. Defines the scope of data to be evaluated.

This field is immutable. Once set, it cannot be changed. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response:
`traceScope` ``object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#TraceScope`)`` scope online evaluation to single traces.
End of mutually exclusive fields. `convention` `Union type` Required. Defines which convention the data source follows.

This field is immutable. Once set, it cannot be changed. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response:
`openTelemetry` ``object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#OpenTelemetry`)`` data source follows OpenTelemetry convention.
End of mutually exclusive fields.

| JSON representation |
|---|
| ``` { "logView": string, "traceView": string, // eval_scope "traceScope": { object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#TraceScope`) } // Union type // convention "openTelemetry": { object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#OpenTelemetry`) } // Union type } ``` |

## TraceScope

If chosen, the online evaluator will evaluate single traces matching specified `filter`.
Fields `filter[]` ``object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#Predicate`)`` Optional. A list of predicates to filter traces. Multiple predicates are combined using AND.

The maximum number of predicates is 10.

| JSON representation |
|---|
| ``` { "filter": [ { object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#Predicate`) } ] } ``` |

## Predicate

Defines a single filter predicate.
Fields `predicate` `Union type` The type of predicate. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: `duration` ``object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#NumericPredicate`)`` Filter on the duration of a trace (in seconds).
`totalTokenUsage` ``object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#NumericPredicate`)`` Filter on the total token usage within a trace.
End of mutually exclusive fields.

| JSON representation |
|---|
| ``` { // predicate "duration": { object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#NumericPredicate`) }, "totalTokenUsage": { object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#NumericPredicate`) } // Union type } ``` |

## NumericPredicate

Defines a predicate for filtering based on a numeric value.
Fields `comparisonOperator` ``enum (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#ComparisonOperator`)`` Required. The comparison operator to apply.
`value` `number` Required. The value to compare against.

| JSON representation |
|---|
| ``` { "comparisonOperator": enum (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#ComparisonOperator`), "value": number } ``` |

## ComparisonOperator

Comparison operators for numeric predicates.

| Enums ||
|---|---|
| `COMPARISON_OPERATOR_UNSPECIFIED` | Unspecified comparison operator. This value should not be used. |
| `LESS` | Less than. |
| `LESS_OR_EQUAL` | Less than or equal to. |
| `EQUAL` | Equal to. |
| `NOT_EQUAL` | Not equal to. |
| `GREATER_OR_EQUAL` | Greater than or equal to. |
| `GREATER` | Greater than. |

## OpenTelemetry

Configuration for data source following OpenTelemetry.
Fields `semconvVersion` `string` Required. Defines which version OTel Semantic Convention the data follows. Can be "1.39.0" or newer.

| JSON representation |
|---|
| ``` { "semconvVersion": string } ``` |

## MetricSource

The metric source used for evaluation.
Fields `metric_source` `Union type` The source of the metric. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: `metric` ``object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/Metric`)`` Inline metric config.
`metricResourceName` `string` Optional. Resource name for registered metric.
End of mutually exclusive fields.

| JSON representation |
|---|
| ``` { // metric_source "metric": { object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/Metric`) }, "metricResourceName": string // Union type } ``` |

## Config

Configuration for sampling behavior of the OnlineEvaluator. The OnlineEvaluator runs at a fixed interval of 10 minutes.
Fields `maxEvaluatedSamplesPerRun` `string (https://developers.google.com/discovery/v1/type-format format)` Optional. The maximum number of evaluations to perform per run. If set to 0, the number is unbounded.
`sampling_method` `Union type` Required. The sampling method used to select traces for evaluation. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: `randomSampling` ``object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#RandomSampling`)`` Random sampling method.
End of mutually exclusive fields.

| JSON representation |
|---|
| ``` { "maxEvaluatedSamplesPerRun": string, // sampling_method "randomSampling": { object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators#RandomSampling`) } // Union type } ``` |

## RandomSampling

Configuration for random sampling.
Fields `percentage` `integer` Required. The percentage of traces to sample for evaluation. Must be an integer between `1` and `100`.

| JSON representation |
|---|
| ``` { "percentage": integer } ``` |

## State

The state of the OnlineEvaluator.

| Enums ||
|---|---|
| `STATE_UNSPECIFIED` | Default value. |
| `ACTIVE` | Indicates that the OnlineEvaluator is active. |
| `SUSPENDED` | Indicates that the OnlineEvaluator is suspended. In this state, the OnlineEvaluator will not evaluate any samples. |
| `FAILED` | Indicates that the OnlineEvaluator is in a failed state. This can happen if, for example, the `logView` or `traceView` set on the `CloudObservability` does not exist. |
| `WARNING` | Indicates that the OnlineEvaluator is in a warning state. This can happen if, for example, some of the metrics in the `metricSources` are invalid. Evaluation will still run with the remaining valid metrics. |

## StateDetails

Contains additional information about the state of the OnlineEvaluator.
Fields `message` `string` Output only. Human-readable message describing the state of the OnlineEvaluator.

| JSON representation |
|---|
| ``` { "message": string } ``` |

| ## Methods ||
|---|---|
| ### `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators/activate` | Activates an OnlineEvaluator. |
| ### `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators/create` | Creates an OnlineEvaluator in the given project and location. |
| ### `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators/delete` | Deletes an OnlineEvaluator. |
| ### `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators/get` | Gets details of an OnlineEvaluator. |
| ### `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators/list` | Lists the OnlineEvaluators for the given project and location. |
| ### `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators/patch` | Updates the fields of an OnlineEvaluator. |
| ### `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1beta1/projects.locations.onlineEvaluators/suspend` | Suspends an OnlineEvaluator. |