Skip to content

Commit 3c32d37

Browse files
Add example to AlertQuery data field descriptions
Previously, the `data` field description was just "Array of query data objects" with no guidance on the required structure. Since `models.AlertQuery.Model` is `interface{}`, the jsonschema reflector emits bare `true` for it, giving LLMs no type information about the model field. Add a concrete example showing the expected AlertQuery structure (refId, datasourceUid, relativeTimeRange, model with expr) to all three Data field descriptions. This helps LLMs construct valid create/update payloads without needing to guess the nested object structure.
1 parent 9bca52e commit 3c32d37

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

tools/alerting_manage_rules_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ type CreateAlertRuleParams struct {
6363
RuleGroup string `json:"ruleGroup" jsonschema:"required,description=The rule group name"`
6464
FolderUID string `json:"folderUID" jsonschema:"required,description=The folder UID where the rule will be created"`
6565
Condition string `json:"condition" jsonschema:"required,description=The query condition identifier (e.g. 'A'\\, 'B')"`
66-
Data []*models.AlertQuery `json:"data" jsonschema:"required,description=Array of query data objects"`
66+
Data []*models.AlertQuery `json:"data" jsonschema:"required,description=Array of alert query objects. Example: [{refId: 'A'\\, datasourceUid: 'prometheus'\\, relativeTimeRange: {from: 600\\, to: 0}\\, model: {expr: 'vector(1)'\\, refId: 'A'}}]. Use datasourceUid '__expr__' for server-side expressions."`
6767
NoDataState string `json:"noDataState" jsonschema:"required,description=State when no data (NoData\\, Alerting\\, OK)"`
6868
ExecErrState string `json:"execErrState" jsonschema:"required,description=State on execution error (NoData\\, Alerting\\, OK)"`
6969
For string `json:"for" jsonschema:"required,description=Duration before alert fires (e.g. '5m')"`
@@ -111,7 +111,7 @@ type UpdateAlertRuleParams struct {
111111
RuleGroup string `json:"ruleGroup" jsonschema:"required,description=The rule group name"`
112112
FolderUID string `json:"folderUID" jsonschema:"required,description=The folder UID where the rule will be created"`
113113
Condition string `json:"condition" jsonschema:"required,description=The query condition identifier (e.g. 'A'\\, 'B')"`
114-
Data []*models.AlertQuery `json:"data" jsonschema:"required,description=Array of query data objects"`
114+
Data []*models.AlertQuery `json:"data" jsonschema:"required,description=Array of alert query objects. Example: [{refId: 'A'\\, datasourceUid: 'prometheus'\\, relativeTimeRange: {from: 600\\, to: 0}\\, model: {expr: 'vector(1)'\\, refId: 'A'}}]. Use datasourceUid '__expr__' for server-side expressions."`
115115
NoDataState string `json:"noDataState" jsonschema:"required,description=State when no data (NoData\\, Alerting\\, OK)"`
116116
ExecErrState string `json:"execErrState" jsonschema:"required,description=State on execution error (NoData\\, Alerting\\, OK)"`
117117
For string `json:"for" jsonschema:"required,description=Duration before alert fires (e.g. '5m')"`
@@ -216,7 +216,7 @@ type ManageRulesReadWriteParams struct {
216216
RuleGroup string `json:"rule_group,omitempty" jsonschema:"description=The rule group name (required for 'create'\\, 'update')"`
217217
FolderUID string `json:"folder_uid,omitempty" jsonschema:"description=The folder UID. For 'list': filter by exact folder UID (mutually exclusive with search_folder). For 'create'/'update': the folder to store the rule in (required)."`
218218
Condition string `json:"condition,omitempty" jsonschema:"description=The query condition identifier\\, e.g. 'A'\\, 'B' (required for 'create'\\, 'update')"`
219-
Data []*models.AlertQuery `json:"data,omitempty" jsonschema:"description=Array of query data objects (required for 'create'\\, 'update')"`
219+
Data []*models.AlertQuery `json:"data,omitempty" jsonschema:"description=Array of alert query objects (required for 'create' and 'update'). Example: [{refId: 'A'\\, datasourceUid: 'prometheus'\\, relativeTimeRange: {from: 600\\, to: 0}\\, model: {expr: 'vector(1)'\\, refId: 'A'}}]. Use datasourceUid '__expr__' for server-side expressions. The 'condition' field must reference one of the refIds."`
220220
NoDataState string `json:"no_data_state,omitempty" jsonschema:"description=State when no data: NoData\\, Alerting\\, OK (required for 'create'\\, 'update')"`
221221
ExecErrState string `json:"exec_err_state,omitempty" jsonschema:"description=State on execution error: NoData\\, Alerting\\, OK (required for 'create'\\, 'update')"`
222222
For string `json:"for,omitempty" jsonschema:"description=Duration before alert fires\\, e.g. '5m' (required for 'create'\\, 'update')"`

0 commit comments

Comments
 (0)