Skip to content

Commit

Permalink
fix: add inline actions and conditions to monitor v2 data source to s…
Browse files Browse the repository at this point in the history
…upport exporting (#180)
  • Loading branch information
obs-gh-abhinavpappu authored Dec 17, 2024
1 parent 37ca21f commit 1af8693
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 9 deletions.
107 changes: 105 additions & 2 deletions docs/data-sources/monitor_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ template and destinations to configure the receiver.

### Optional

- `data_stabilization_delay` (String) expresses the minimum time that should elapse before data is considered "good enough" to evaluate. Choosing a delay really depends on the expectations of latency of data and whether data is expected to arrive later than other data and thus would change previously evaluated results.
- `id` (String) Resource ID for this object.
- `max_alerts_per_hour` (Number) overrides the default value of max alerts generated in a single hour before the monitor is deactivated for safety
- `name` (String) Monitor name.
- `workspace` (String) OID of the workspace this object is contained in.

### Read-Only

- `actions` (Block List) The list of shared actions to which this monitor is connected. (see [below for nested schema](#nestedblock--actions))
- `data_stabilization_delay` (String) expresses the minimum time that should elapse before data is considered "good enough" to evaluate. Choosing a delay really depends on the expectations of latency of data and whether data is expected to arrive later than other data and thus would change previously evaluated results.
- `description` (String) A brief description of the monitor.
- `groupings` (Block List) Describes the groups that logically separate events/rows/etc from each other. If monitor dataset is resource type and monitor strategy is promote, this field should be either empty or only contain the primary keys of the dataset. (see [below for nested schema](#nestedblock--groupings))
- `icon_url` (String) URL of the monitor icon.
- `inputs` (Map of String) The inputs map binds dataset OIDs to labels which can be referenced within
stage pipelines.
- `lookback_time` (String) optionally describes a duration that must be satisifed by this monitor. It applies to all rules, but is only applicable to rule kinds that utilize it.
- `max_alerts_per_hour` (Number) overrides the default value of max alerts generated in a single hour before the monitor is deactivated for safety
- `oid` (String)
- `rule_kind` (String) Describes the type of each of the rules in the definition (they must all be the same type).
- `rules` (Block List) All rules for this monitor must be of the same MonitorRuleKind as specified in ruleKind. Rules should be constructed logically such that a state transition null->Warning implies transition from null->Informational. (see [below for nested schema](#nestedblock--rules))
Expand All @@ -51,11 +51,114 @@ its predecessor. (see [below for nested schema](#nestedblock--stage))

Read-Only:

- `action` (Block List) This value should be used for creating inline private actions. (see [below for nested schema](#nestedblock--actions--action))
- `conditions` (List of Object) Optional conditions that can be AND'd with levels to match the action. (see [below for nested schema](#nestedatt--actions--conditions))
- `levels` (List of String) The alarm level(s) at which this monitor should trigger this shared action.
- `oid` (String) The OID of this shared action. This should be used for existing shared actions.
- `send_end_notifications` (Boolean)
- `send_reminders_interval` (String)

<a id="nestedblock--actions--action"></a>
### Nested Schema for `actions.action`

Read-Only:

- `description` (String)
- `email` (List of Object) (see [below for nested schema](#nestedatt--actions--action--email))
- `type` (String)
- `webhook` (List of Object) (see [below for nested schema](#nestedatt--actions--action--webhook))

<a id="nestedatt--actions--action--email"></a>
### Nested Schema for `actions.action.email`

Read-Only:

- `addresses` (List of String)
- `body` (String)
- `fragments` (String)
- `subject` (String)
- `users` (List of String)


<a id="nestedatt--actions--action--webhook"></a>
### Nested Schema for `actions.action.webhook`

Read-Only:

- `body` (String)
- `fragments` (String)
- `headers` (List of Object) (see [below for nested schema](#nestedobjatt--actions--action--webhook--headers))
- `method` (String)
- `url` (String)

<a id="nestedobjatt--actions--action--webhook--headers"></a>
### Nested Schema for `actions.action.webhook.headers`

Read-Only:

- `header` (String)
- `value` (String)




<a id="nestedatt--actions--conditions"></a>
### Nested Schema for `actions.conditions`

Read-Only:

- `compare_terms` (List of Object) (see [below for nested schema](#nestedobjatt--actions--conditions--compare_terms))

<a id="nestedobjatt--actions--conditions--compare_terms"></a>
### Nested Schema for `actions.conditions.compare_terms`

Read-Only:

- `column` (List of Object) (see [below for nested schema](#nestedobjatt--actions--conditions--compare_terms--column))
- `comparison` (List of Object) (see [below for nested schema](#nestedobjatt--actions--conditions--compare_terms--comparison))

<a id="nestedobjatt--actions--conditions--compare_terms--column"></a>
### Nested Schema for `actions.conditions.compare_terms.comparison`

Read-Only:

- `column_path` (List of Object) (see [below for nested schema](#nestedobjatt--actions--conditions--compare_terms--comparison--column_path))
- `link_column` (List of Object) (see [below for nested schema](#nestedobjatt--actions--conditions--compare_terms--comparison--link_column))

<a id="nestedobjatt--actions--conditions--compare_terms--comparison--column_path"></a>
### Nested Schema for `actions.conditions.compare_terms.comparison.column_path`

Read-Only:

- `name` (String)
- `path` (String)


<a id="nestedobjatt--actions--conditions--compare_terms--comparison--link_column"></a>
### Nested Schema for `actions.conditions.compare_terms.comparison.link_column`

Read-Only:

- `name` (String)



<a id="nestedobjatt--actions--conditions--compare_terms--comparison"></a>
### Nested Schema for `actions.conditions.compare_terms.comparison`

Read-Only:

- `compare_fn` (String)
- `value_bool` (List of Boolean)
- `value_duration` (List of Boolean)
- `value_float64` (List of Number)
- `value_int64` (List of Number)
- `value_string` (List of String)
- `value_timestamp` (List of String)





<a id="nestedblock--groupings"></a>
### Nested Schema for `groupings`
Expand Down
61 changes: 59 additions & 2 deletions observe/data_source_monitor_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,11 @@ func dataSourceMonitorV2() *schema.Resource {
"data_stabilization_delay": { // Int64
Type: schema.TypeString,
Computed: true,
Optional: true,
Description: descriptions.Get("monitorv2", "schema", "data_stabilization_delay"),
},
"max_alerts_per_hour": { //Int64
Type: schema.TypeInt,
Computed: true,
Optional: true,
Description: descriptions.Get("monitorv2", "schema", "max_alerts_per_hour"),
},
"groupings": { // [MonitorV2ColumnInput!]
Expand Down Expand Up @@ -246,12 +244,71 @@ func dataSourceMonitorV2() *schema.Resource {
Computed: true,
Description: descriptions.Get("monitorv2", "schema", "actions", "oid"),
},
"action": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Description: descriptions.Get("monitorv2", "schema", "actions", "action"),
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
// fields of MonitorV2ActionInput
"type": { // MonitorV2ActionType!
Type: schema.TypeString,
Computed: true,
},
"email": { // MonitorV2EmailDestinationInput
Type: schema.TypeList,
Computed: true,
Elem: monitorV2EmailActionDatasource(),
},
"webhook": { // MonitorV2WebhookDestinationInput
Type: schema.TypeList,
Computed: true,
Elem: monitorV2WebhookActionDatasource(),
},
"description": { // String
Type: schema.TypeString,
Computed: true,
},
},
},
},
"levels": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: descriptions.Get("monitorv2", "schema", "actions", "levels"),
},
"conditions": { // MonitorV2ComparisonExpression
Type: schema.TypeList,
Computed: true,
Description: descriptions.Get("monitorv2", "schema", "actions", "conditions", "description"),
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"compare_terms": { // [MonitorV2ComparisonTerm!]
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"comparison": { // [MonitorV2Comparison!]!
Type: schema.TypeList,
Computed: true,
Elem: monitorV2ComparisonDatasource(),
Description: descriptions.Get("monitorv2", "schema", "actions", "conditions", "compare_terms", "comparison"),
},
"column": { // [MonitorV2Column!]!
Type: schema.TypeList,
Computed: true,
Elem: monitorV2ColumnDatasource(),
Description: descriptions.Get("monitorv2", "schema", "actions", "conditions", "compare_terms", "column"),
},
},
},
},
// note: operator is an implied AND for now until the UI supports OR
},
},
},
"send_end_notifications": { // Boolean
Type: schema.TypeBool,
Computed: true,
Expand Down
10 changes: 5 additions & 5 deletions observe/resource_monitor_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ func resourceMonitorV2() *schema.Resource {
ValidateDiagFunc: validateOID(oid.TypeWorkspace),
Description: descriptions.Get("monitorv2", "schema", "workspace_id"),
},
"name": { // String!
Type: schema.TypeString,
Required: true,
Description: descriptions.Get("monitorv2", "schema", "name"),
},
// fields of MonitorV2Input excluding the components of MonitorV2DefinitionInput
"rule_kind": { // MonitorV2RuleKind!
Type: schema.TypeString,
Required: true,
ValidateDiagFunc: validateEnums(gql.AllMonitorV2RuleKinds),
Description: descriptions.Get("monitorv2", "schema", "rule_kind"),
},
"name": { // String!
Type: schema.TypeString,
Required: true,
Description: descriptions.Get("monitorv2", "schema", "name"),
},
"icon_url": { // String
Type: schema.TypeString,
Optional: true,
Expand Down

0 comments on commit 1af8693

Please sign in to comment.