Skip to content

Commit 7b2c6fe

Browse files
authored
feat(vertexai): add google_vertex_ai_online_evaluator resource (#17944)
1 parent 3488c4b commit 7b2c6fe

4 files changed

Lines changed: 496 additions & 0 deletions

File tree

Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
# Copyright 2026 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
---
14+
name: OnlineEvaluator
15+
description: Description
16+
base_url: projects/{{project}}/locations/{{region}}/onlineEvaluators
17+
min_version: beta
18+
self_link: 'projects/{{project}}/locations/{{region}}/onlineEvaluators/{{name}}'
19+
create_url: projects/{{project}}/locations/{{region}}/onlineEvaluators
20+
update_mask: true
21+
update_verb: PATCH
22+
timeouts:
23+
insert_minutes: 20
24+
update_minutes: 20
25+
delete_minutes: 60
26+
async:
27+
type: 'OpAsync'
28+
operation:
29+
base_url: '{{op_id}}'
30+
actions:
31+
- create
32+
- update
33+
- delete
34+
result:
35+
resource_inside_response: true
36+
autogen_status: T25saW5lRXZhbHVhdG9y
37+
parameters:
38+
- name: region
39+
type: String
40+
required: true
41+
description: Resource ID segment making up resource `name`. It identifies the resource
42+
within its parent collection as described in https://google.aip.dev/122.
43+
immutable: true
44+
url_param_only: true
45+
properties:
46+
- name: agentResource
47+
type: String
48+
required: true
49+
description: 'The name of the agent that the OnlineEvaluator evaluates periodically.
50+
This value is used to filter the traces with a matching cloud.resource_id
51+
and link the evaluation results with relevant dashboards/UIs.
52+
This field is immutable. Once set, it cannot be changed.'
53+
immutable: true
54+
- name: cloudObservability
55+
type: NestedObject
56+
description: 'Data source for the OnlineEvaluator, based on Google Cloud Observability
57+
stack (Cloud Trace & Cloud Logging).'
58+
properties:
59+
- name: logView
60+
type: String
61+
description: 'Optional log view that will be used to query logs.
62+
If empty, the `_Default` view will be used.'
63+
immutable: true
64+
- name: openTelemetry
65+
type: NestedObject
66+
description: Configuration for data source following OpenTelemetry.
67+
immutable: true
68+
ignore_read: true
69+
properties:
70+
- name: semconvVersion
71+
type: String
72+
required: true
73+
description: 'Defines which version OTel Semantic Convention the data follows.
74+
Can be "1.39.0" or newer.'
75+
immutable: true
76+
- name: traceScope
77+
type: NestedObject
78+
description: 'If chosen, the online evaluator will evaluate single traces matching
79+
specified `filter`.'
80+
immutable: true
81+
properties:
82+
- name: filter
83+
type: Array
84+
description: 'A list of predicates to filter traces. Multiple predicates are
85+
combined using AND.
86+
The maximum number of predicates is 10.'
87+
immutable: true
88+
item_type:
89+
type: NestedObject
90+
properties:
91+
- name: duration
92+
type: NestedObject
93+
description: Defines a predicate for filtering based on a numeric value.
94+
immutable: true
95+
properties:
96+
- name: comparisonOperator
97+
type: String
98+
required: true
99+
description: 'The comparison operator to apply.
100+
Possible values:
101+
LESS
102+
LESS_OR_EQUAL
103+
EQUAL
104+
NOT_EQUAL
105+
GREATER_OR_EQUAL
106+
GREATER'
107+
immutable: true
108+
- name: value
109+
type: Double
110+
required: true
111+
description: The value to compare against.
112+
immutable: true
113+
- name: totalTokenUsage
114+
type: NestedObject
115+
description: Defines a predicate for filtering based on a numeric value.
116+
immutable: true
117+
properties:
118+
- name: comparisonOperator
119+
type: String
120+
required: true
121+
description: 'The comparison operator to apply.
122+
Possible values:
123+
LESS
124+
LESS_OR_EQUAL
125+
EQUAL
126+
NOT_EQUAL
127+
GREATER_OR_EQUAL
128+
GREATER'
129+
immutable: true
130+
- name: value
131+
type: Double
132+
required: true
133+
description: The value to compare against.
134+
immutable: true
135+
- name: traceView
136+
type: String
137+
description: 'Optional trace view that will be used to query traces.
138+
If empty, the `_Default` view will be used.
139+
NOTE: This field is not supported yet and will be ignored if set.'
140+
immutable: true
141+
required: true
142+
immutable: true
143+
- name: config
144+
type: NestedObject
145+
required: true
146+
description: 'Configuration for sampling behavior of the OnlineEvaluator.
147+
The OnlineEvaluator runs at a fixed interval of 10 minutes.'
148+
properties:
149+
- name: maxEvaluatedSamplesPerRun
150+
type: String
151+
description: 'The maximum number of evaluations to perform per run.
152+
If set to 0, the number is unbounded.'
153+
- name: randomSampling
154+
type: NestedObject
155+
description: Configuration for random sampling.
156+
properties:
157+
- name: percentage
158+
type: Integer
159+
required: true
160+
description: 'The percentage of traces to sample for evaluation.
161+
Must be an integer between `1` and `100`.'
162+
- name: createTime
163+
type: String
164+
description: Timestamp when the OnlineEvaluator was created.
165+
output: true
166+
- name: displayName
167+
type: String
168+
description: 'Human-readable name for the `OnlineEvaluator`.
169+
The name doesn''t have to be unique.
170+
The name can consist of any UTF-8 characters. The maximum length is `63`
171+
characters. If the display name exceeds max characters, an
172+
`INVALID_ARGUMENT` error is returned.'
173+
- name: metricSources
174+
type: Array
175+
required: true
176+
immutable: true
177+
description: 'A list of metric sources to be used for evaluating samples.
178+
At least one MetricSource must be provided.
179+
Right now, only predefined metrics and registered metrics are supported.
180+
Every registered metric must have `display_name` (or `title`) and
181+
`score_range` defined. Otherwise, the evaluations will fail.
182+
The maximum number of `metric_sources` is 25.'
183+
item_type:
184+
type: NestedObject
185+
properties:
186+
# TODO: Support structured metric config instead of JSON string.
187+
- name: metric
188+
type: String
189+
description: |
190+
Inline metric config. Provide this field as a JSON-formatted string.
191+
Suggested predefined metricSpecName values:
192+
- `final_response_quality_v1`
193+
- `tool_use_quality_v1`
194+
- `hallucination_v1`
195+
- `safety_v1`
196+
- `multi_turn_task_success_v1`
197+
- `multi_turn_tool_use_quality_v1`
198+
- `multi_turn_trajectory_quality_v1`
199+
immutable: true
200+
custom_expand: 'templates/terraform/custom_expand/json_value.tmpl'
201+
custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
202+
- name: metricResourceName
203+
type: String
204+
description: Resource name for registered metric.
205+
immutable: true
206+
- name: name
207+
type: String
208+
description: 'Identifier. The resource name of the OnlineEvaluator.
209+
Format: projects/{project}/locations/{region}/onlineEvaluators/{id}.'
210+
output: true
211+
custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.tmpl'
212+
- name: state
213+
type: String
214+
description: 'The state of the OnlineEvaluator.
215+
Possible values:
216+
ACTIVE
217+
SUSPENDED
218+
FAILED
219+
WARNING'
220+
output: true
221+
- name: stateDetails
222+
type: Array
223+
description: 'Contains additional information about the state of the OnlineEvaluator.
224+
This is used to provide more details in the event of a failure.'
225+
output: true
226+
item_type:
227+
type: NestedObject
228+
output: true
229+
properties:
230+
- name: message
231+
type: String
232+
description: Human-readable message describing the state of the OnlineEvaluator.
233+
output: true
234+
- name: updateTime
235+
type: String
236+
description: Timestamp when the OnlineEvaluator was last updated.
237+
output: true
238+
239+
examples:
240+
- name: 'vertex_ai_online_evaluator_basic'
241+
primary_resource_id: 'evaluator'
242+
vars:
243+
evaluator_name: 'my-evaluator'
244+
engine_name: 'my-engine'
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
resource "google_vertex_ai_reasoning_engine" "engine" {
2+
provider = google-beta
3+
display_name = "{{index $.Vars "engine_name"}}"
4+
description = "A basic reasoning engine"
5+
labels = {
6+
"key" = "value"
7+
}
8+
region = "us-central1"
9+
}
10+
11+
resource "google_vertex_ai_online_evaluator" "evaluator" {
12+
provider = google-beta
13+
region = "us-central1"
14+
display_name = "{{index $.Vars "evaluator_name"}}"
15+
16+
agent_resource = google_vertex_ai_reasoning_engine.engine.id
17+
18+
config {
19+
max_evaluated_samples_per_run = "100"
20+
random_sampling {
21+
percentage = 10
22+
}
23+
}
24+
25+
metric_sources {
26+
metric = jsonencode({
27+
"predefinedMetricSpec" = {
28+
"metricSpecName" = "safety_v1"
29+
}
30+
})
31+
}
32+
33+
metric_sources {
34+
metric = jsonencode({
35+
"predefinedMetricSpec" = {
36+
"metricSpecName" = "hallucination_v1"
37+
}
38+
})
39+
}
40+
41+
metric_sources {
42+
metric = jsonencode({
43+
"predefinedMetricSpec" = {
44+
"metricSpecName" = "final_response_quality_v1"
45+
}
46+
})
47+
}
48+
49+
metric_sources {
50+
metric = jsonencode({
51+
"predefinedMetricSpec" = {
52+
"metricSpecName" = "tool_use_quality_v1"
53+
}
54+
})
55+
}
56+
57+
cloud_observability {
58+
open_telemetry {
59+
semconv_version = "1.39.0"
60+
}
61+
62+
trace_scope {
63+
filter {
64+
duration {
65+
comparison_operator = "GREATER"
66+
value = 0
67+
}
68+
}
69+
}
70+
}
71+
}

0 commit comments

Comments
 (0)