/
getAlertPolicy.go
162 lines (135 loc) · 13.2 KB
/
getAlertPolicy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// Code generated by the Pulumi SDK Generator DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package v3
import (
"context"
"reflect"
"github.com/pulumi/pulumi-google-native/sdk/go/google/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Gets a single alerting policy.
func LookupAlertPolicy(ctx *pulumi.Context, args *LookupAlertPolicyArgs, opts ...pulumi.InvokeOption) (*LookupAlertPolicyResult, error) {
opts = internal.PkgInvokeDefaultOpts(opts)
var rv LookupAlertPolicyResult
err := ctx.Invoke("google-native:monitoring/v3:getAlertPolicy", args, &rv, opts...)
if err != nil {
return nil, err
}
return &rv, nil
}
type LookupAlertPolicyArgs struct {
AlertPolicyId string `pulumi:"alertPolicyId"`
Project *string `pulumi:"project"`
}
type LookupAlertPolicyResult struct {
// Control over how this alert policy's notification channels are notified.
AlertStrategy AlertStrategyResponse `pulumi:"alertStrategy"`
// How to combine the results of multiple conditions to determine if an incident should be opened. If condition_time_series_query_language is present, this must be COMBINE_UNSPECIFIED.
Combiner string `pulumi:"combiner"`
// A list of conditions for the policy. The conditions are combined by AND or OR according to the combiner field. If the combined conditions evaluate to true, then an incident is created. A policy can have from one to six conditions. If condition_time_series_query_language is present, it must be the only condition. If condition_monitoring_query_language is present, it must be the only condition.
Conditions []ConditionResponse `pulumi:"conditions"`
// A read-only record of the creation of the alerting policy. If provided in a call to create or update, this field will be ignored.
CreationRecord MutationRecordResponse `pulumi:"creationRecord"`
// A short name or phrase used to identify the policy in dashboards, notifications, and incidents. To avoid confusion, don't use the same display name for multiple policies in the same project. The name is limited to 512 Unicode characters.The convention for the display_name of a PrometheusQueryLanguageCondition is "{rule group name}/{alert name}", where the {rule group name} and {alert name} should be taken from the corresponding Prometheus configuration file. This convention is not enforced. In any case the display_name is not a unique key of the AlertPolicy.
DisplayName string `pulumi:"displayName"`
// Documentation that is included with notifications and incidents related to this policy. Best practice is for the documentation to include information to help responders understand, mitigate, escalate, and correct the underlying problems detected by the alerting policy. Notification channels that have limited capacity might not show this documentation.
Documentation DocumentationResponse `pulumi:"documentation"`
// Whether or not the policy is enabled. On write, the default interpretation if unset is that the policy is enabled. On read, clients should not make any assumption about the state if it has not been populated. The field should always be populated on List and Get operations, unless a field projection has been specified that strips it out.
Enabled bool `pulumi:"enabled"`
// A read-only record of the most recent change to the alerting policy. If provided in a call to create or update, this field will be ignored.
MutationRecord MutationRecordResponse `pulumi:"mutationRecord"`
// Required if the policy exists. The resource name for this policy. The format is: projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID] [ALERT_POLICY_ID] is assigned by Cloud Monitoring when the policy is created. When calling the alertPolicies.create method, do not include the name field in the alerting policy passed as part of the request.
Name string `pulumi:"name"`
// Identifies the notification channels to which notifications should be sent when incidents are opened or closed or when new violations occur on an already opened incident. Each element of this array corresponds to the name field in each of the NotificationChannel objects that are returned from the ListNotificationChannels method. The format of the entries in this field is: projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID]
NotificationChannels []string `pulumi:"notificationChannels"`
// Optional. The severity of an alert policy indicates how important alerts generated by that policy are. The severity level, if specified, will be displayed on the Incident detail page and in notifications.
Severity string `pulumi:"severity"`
// User-supplied key/value data to be used for organizing and identifying the AlertPolicy objects.The field can contain up to 64 entries. Each key and value is limited to 63 Unicode characters or 128 bytes, whichever is smaller. Labels and values can contain only lowercase letters, numerals, underscores, and dashes. Keys must begin with a letter.Note that Prometheus {alert name} is a valid Prometheus label names (https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels), whereas Prometheus {rule group} is an unrestricted UTF-8 string. This means that they cannot be stored as-is in user labels, because they may contain characters that are not allowed in user-label values.
UserLabels map[string]string `pulumi:"userLabels"`
// Read-only description of how the alert policy is invalid. This field is only set when the alert policy is invalid. An invalid alert policy will not generate incidents.
Validity StatusResponse `pulumi:"validity"`
}
func LookupAlertPolicyOutput(ctx *pulumi.Context, args LookupAlertPolicyOutputArgs, opts ...pulumi.InvokeOption) LookupAlertPolicyResultOutput {
return pulumi.ToOutputWithContext(context.Background(), args).
ApplyT(func(v interface{}) (LookupAlertPolicyResult, error) {
args := v.(LookupAlertPolicyArgs)
r, err := LookupAlertPolicy(ctx, &args, opts...)
var s LookupAlertPolicyResult
if r != nil {
s = *r
}
return s, err
}).(LookupAlertPolicyResultOutput)
}
type LookupAlertPolicyOutputArgs struct {
AlertPolicyId pulumi.StringInput `pulumi:"alertPolicyId"`
Project pulumi.StringPtrInput `pulumi:"project"`
}
func (LookupAlertPolicyOutputArgs) ElementType() reflect.Type {
return reflect.TypeOf((*LookupAlertPolicyArgs)(nil)).Elem()
}
type LookupAlertPolicyResultOutput struct{ *pulumi.OutputState }
func (LookupAlertPolicyResultOutput) ElementType() reflect.Type {
return reflect.TypeOf((*LookupAlertPolicyResult)(nil)).Elem()
}
func (o LookupAlertPolicyResultOutput) ToLookupAlertPolicyResultOutput() LookupAlertPolicyResultOutput {
return o
}
func (o LookupAlertPolicyResultOutput) ToLookupAlertPolicyResultOutputWithContext(ctx context.Context) LookupAlertPolicyResultOutput {
return o
}
// Control over how this alert policy's notification channels are notified.
func (o LookupAlertPolicyResultOutput) AlertStrategy() AlertStrategyResponseOutput {
return o.ApplyT(func(v LookupAlertPolicyResult) AlertStrategyResponse { return v.AlertStrategy }).(AlertStrategyResponseOutput)
}
// How to combine the results of multiple conditions to determine if an incident should be opened. If condition_time_series_query_language is present, this must be COMBINE_UNSPECIFIED.
func (o LookupAlertPolicyResultOutput) Combiner() pulumi.StringOutput {
return o.ApplyT(func(v LookupAlertPolicyResult) string { return v.Combiner }).(pulumi.StringOutput)
}
// A list of conditions for the policy. The conditions are combined by AND or OR according to the combiner field. If the combined conditions evaluate to true, then an incident is created. A policy can have from one to six conditions. If condition_time_series_query_language is present, it must be the only condition. If condition_monitoring_query_language is present, it must be the only condition.
func (o LookupAlertPolicyResultOutput) Conditions() ConditionResponseArrayOutput {
return o.ApplyT(func(v LookupAlertPolicyResult) []ConditionResponse { return v.Conditions }).(ConditionResponseArrayOutput)
}
// A read-only record of the creation of the alerting policy. If provided in a call to create or update, this field will be ignored.
func (o LookupAlertPolicyResultOutput) CreationRecord() MutationRecordResponseOutput {
return o.ApplyT(func(v LookupAlertPolicyResult) MutationRecordResponse { return v.CreationRecord }).(MutationRecordResponseOutput)
}
// A short name or phrase used to identify the policy in dashboards, notifications, and incidents. To avoid confusion, don't use the same display name for multiple policies in the same project. The name is limited to 512 Unicode characters.The convention for the display_name of a PrometheusQueryLanguageCondition is "{rule group name}/{alert name}", where the {rule group name} and {alert name} should be taken from the corresponding Prometheus configuration file. This convention is not enforced. In any case the display_name is not a unique key of the AlertPolicy.
func (o LookupAlertPolicyResultOutput) DisplayName() pulumi.StringOutput {
return o.ApplyT(func(v LookupAlertPolicyResult) string { return v.DisplayName }).(pulumi.StringOutput)
}
// Documentation that is included with notifications and incidents related to this policy. Best practice is for the documentation to include information to help responders understand, mitigate, escalate, and correct the underlying problems detected by the alerting policy. Notification channels that have limited capacity might not show this documentation.
func (o LookupAlertPolicyResultOutput) Documentation() DocumentationResponseOutput {
return o.ApplyT(func(v LookupAlertPolicyResult) DocumentationResponse { return v.Documentation }).(DocumentationResponseOutput)
}
// Whether or not the policy is enabled. On write, the default interpretation if unset is that the policy is enabled. On read, clients should not make any assumption about the state if it has not been populated. The field should always be populated on List and Get operations, unless a field projection has been specified that strips it out.
func (o LookupAlertPolicyResultOutput) Enabled() pulumi.BoolOutput {
return o.ApplyT(func(v LookupAlertPolicyResult) bool { return v.Enabled }).(pulumi.BoolOutput)
}
// A read-only record of the most recent change to the alerting policy. If provided in a call to create or update, this field will be ignored.
func (o LookupAlertPolicyResultOutput) MutationRecord() MutationRecordResponseOutput {
return o.ApplyT(func(v LookupAlertPolicyResult) MutationRecordResponse { return v.MutationRecord }).(MutationRecordResponseOutput)
}
// Required if the policy exists. The resource name for this policy. The format is: projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID] [ALERT_POLICY_ID] is assigned by Cloud Monitoring when the policy is created. When calling the alertPolicies.create method, do not include the name field in the alerting policy passed as part of the request.
func (o LookupAlertPolicyResultOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v LookupAlertPolicyResult) string { return v.Name }).(pulumi.StringOutput)
}
// Identifies the notification channels to which notifications should be sent when incidents are opened or closed or when new violations occur on an already opened incident. Each element of this array corresponds to the name field in each of the NotificationChannel objects that are returned from the ListNotificationChannels method. The format of the entries in this field is: projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID]
func (o LookupAlertPolicyResultOutput) NotificationChannels() pulumi.StringArrayOutput {
return o.ApplyT(func(v LookupAlertPolicyResult) []string { return v.NotificationChannels }).(pulumi.StringArrayOutput)
}
// Optional. The severity of an alert policy indicates how important alerts generated by that policy are. The severity level, if specified, will be displayed on the Incident detail page and in notifications.
func (o LookupAlertPolicyResultOutput) Severity() pulumi.StringOutput {
return o.ApplyT(func(v LookupAlertPolicyResult) string { return v.Severity }).(pulumi.StringOutput)
}
// User-supplied key/value data to be used for organizing and identifying the AlertPolicy objects.The field can contain up to 64 entries. Each key and value is limited to 63 Unicode characters or 128 bytes, whichever is smaller. Labels and values can contain only lowercase letters, numerals, underscores, and dashes. Keys must begin with a letter.Note that Prometheus {alert name} is a valid Prometheus label names (https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels), whereas Prometheus {rule group} is an unrestricted UTF-8 string. This means that they cannot be stored as-is in user labels, because they may contain characters that are not allowed in user-label values.
func (o LookupAlertPolicyResultOutput) UserLabels() pulumi.StringMapOutput {
return o.ApplyT(func(v LookupAlertPolicyResult) map[string]string { return v.UserLabels }).(pulumi.StringMapOutput)
}
// Read-only description of how the alert policy is invalid. This field is only set when the alert policy is invalid. An invalid alert policy will not generate incidents.
func (o LookupAlertPolicyResultOutput) Validity() StatusResponseOutput {
return o.ApplyT(func(v LookupAlertPolicyResult) StatusResponse { return v.Validity }).(StatusResponseOutput)
}
func init() {
pulumi.RegisterOutputType(LookupAlertPolicyResultOutput{})
}