From 19e74f9ce76502b06f382013d58815f0c561dafd Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Wed, 9 Jun 2021 21:13:26 -0500 Subject: [PATCH 01/34] WIP - SNS receiver Signed-off-by: Tyler Reid --- cmd/alertmanager/main.go | 4 + config/config.go | 9 +++ config/notifiers.go | 51 ++++++++++++ config/testdata/conf.sns-test.yml | 15 ++++ go.mod | 1 + go.sum | 4 + notify/notify.go | 1 + notify/sns/sns.go | 124 ++++++++++++++++++++++++++++++ notify/sns/sns_test.go | 65 ++++++++++++++++ template/default.tmpl | 11 +++ 10 files changed, 285 insertions(+) create mode 100644 config/testdata/conf.sns-test.yml create mode 100644 notify/sns/sns.go create mode 100644 notify/sns/sns_test.go diff --git a/cmd/alertmanager/main.go b/cmd/alertmanager/main.go index c963b2b9d2..e365f09b61 100644 --- a/cmd/alertmanager/main.go +++ b/cmd/alertmanager/main.go @@ -31,6 +31,7 @@ import ( "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" "github.com/pkg/errors" + "github.com/prometheus/alertmanager/notify/sns" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/common/model" @@ -165,6 +166,9 @@ func buildReceiverIntegrations(nc *config.Receiver, tmpl *template.Template, log for i, c := range nc.PushoverConfigs { add("pushover", i, c, func(l log.Logger) (notify.Notifier, error) { return pushover.New(c, tmpl, l) }) } + for i, c := range nc.SNSConfigs { + add("sns", i, c, func(l log.Logger) (notify.Notifier, error) { return sns.New(c, tmpl, l) }) + } if errs.Len() > 0 { return nil, &errs } diff --git a/config/config.go b/config/config.go index e911e1b63c..1691622a28 100644 --- a/config/config.go +++ b/config/config.go @@ -242,6 +242,9 @@ func resolveFilepaths(baseDir string, cfg *Config) { for _, cfg := range receiver.WechatConfigs { cfg.HTTPConfig.SetDirectory(baseDir) } + for _, cfg := range receiver.SNSConfigs { + cfg.HTTPConfig.SetDirectory(baseDir) + } } } @@ -447,6 +450,11 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { voc.APIKey = c.Global.VictorOpsAPIKey } } + for _, sns := range rcv.SNSConfigs { + if sns.HTTPConfig == nil { + sns.HTTPConfig = c.Global.HTTPConfig + } + } names[rcv.Name] = struct{}{} } @@ -784,6 +792,7 @@ type Receiver struct { WechatConfigs []*WechatConfig `yaml:"wechat_configs,omitempty" json:"wechat_configs,omitempty"` PushoverConfigs []*PushoverConfig `yaml:"pushover_configs,omitempty" json:"pushover_configs,omitempty"` VictorOpsConfigs []*VictorOpsConfig `yaml:"victorops_configs,omitempty" json:"victorops_configs,omitempty"` + SNSConfigs []*SNSConfig `yaml:"sns_configs,omitempty" json:"sns_configs,omitempty"` } // UnmarshalYAML implements the yaml.Unmarshaler interface for Receiver. diff --git a/config/notifiers.go b/config/notifiers.go index 5db3d66ff6..ed25aa5e57 100644 --- a/config/notifiers.go +++ b/config/notifiers.go @@ -127,6 +127,15 @@ var ( Expire: duration(1 * time.Hour), HTML: false, } + + // DefaultSNSConfig defines default values for SNS configurations. + DefaultSNSConfig = SNSConfig{ + NotifierConfig: NotifierConfig{ + VSendResolved: true, + }, + APIVersion: "sns.default.api_version", + Message: `{{ template "sns.default.message" . }}`, + } ) // NotifierConfig contains base options common across all notifier configurations. @@ -579,3 +588,45 @@ func (c *PushoverConfig) UnmarshalYAML(unmarshal func(interface{}) error) error } return nil } + +// TODO: Move to common? + +// SigV4Config is the configuration for signing remote write requests with +// AWS's SigV4 verification process. Empty values will be retrieved using the +// AWS default credentials chain. +type SigV4Config struct { + Region string `yaml:"region,omitempty"` + AccessKey string `yaml:"access_key,omitempty"` + SecretKey Secret `yaml:"secret_key,omitempty"` + Profile string `yaml:"profile,omitempty"` + RoleARN string `yaml:"role_arn,omitempty"` +} + +type SNSConfig struct { + NotifierConfig `yaml:",inline" json:",inline"` + + HTTPConfig *commoncfg.HTTPClientConfig `yaml:"http_config,omitempty" json:"http_config,omitempty"` + + APIUrl string `yaml:"api_url" json:"api_url"` + APIVersion string `yaml:"api_version,omitempty" json:"api_version,omitempty"` + Sigv4 SigV4Config `yaml:"sigv4" json:"sigv4"` + TopicARN string `yaml:"topic_arn,omitempty" json:"topic_arn,omitempty"` + PhoneNumber string `yaml:"phone_number,omitempty" json:"phone_number,omitempty"` + Subject string `yaml:"subject,omitempty" json:"subject,omitempty"` + TargetARN string `yaml:"target_arn,omitempty" json:"target_arn,omitempty"` + Message string `yaml:"message,omitempty" json:"message,omitempty"` + Attributes map[string]string `yaml:"attributes,omitempty" json:"attributes,omitempty"` +} + +// UnmarshalYAML implements the yaml.Unmarshaler interface. +func (c *SNSConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { + *c = DefaultSNSConfig + type plain SNSConfig + if err := unmarshal((*plain)(c)); err != nil { + return err + } + if c.TargetARN == "" && c.TopicARN == "" && c.PhoneNumber == "" { + return fmt.Errorf("must provide either a Target ARN, Topic ARN, or Phone Number for SNS config") + } + return nil +} diff --git a/config/testdata/conf.sns-test.yml b/config/testdata/conf.sns-test.yml new file mode 100644 index 0000000000..ab83ed9e06 --- /dev/null +++ b/config/testdata/conf.sns-test.yml @@ -0,0 +1,15 @@ +route: + receiver: 'sns-api-notifications' + group_by: [alertname] + +receivers: +- name: 'sns-api-notifications' + sns_configs: + - api_url: https://sns.us-east-2.amazonaws.com + topic_arn: arn:aws:sns:us-east-2:123456789012:My-Topic + sigv4: + region: us-east-2 + access_key: access_key + secret_key: secret_ket + attributes: + severity: Sev2 diff --git a/go.mod b/go.mod index 49068ac6a9..77fcbbbd34 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,7 @@ module github.com/prometheus/alertmanager require ( github.com/alecthomas/units v0.0.0-20210208195552-ff826a37aa15 + github.com/aws/aws-sdk-go v1.38.35 github.com/cenkalti/backoff/v4 v4.1.0 github.com/cespare/xxhash v1.1.0 github.com/go-kit/kit v0.10.0 diff --git a/go.sum b/go.sum index 448a8e18df..c1dd7fbd30 100644 --- a/go.sum +++ b/go.sum @@ -39,6 +39,8 @@ github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:W github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48= +github.com/aws/aws-sdk-go v1.38.35 h1:7AlAO0FC+8nFjxiGKEmq0QLpiA8/XFr6eIxgRTwkdTg= +github.com/aws/aws-sdk-go v1.38.35/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= @@ -301,7 +303,9 @@ github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= diff --git a/notify/notify.go b/notify/notify.go index e1cd5f8075..46acea78e0 100644 --- a/notify/notify.go +++ b/notify/notify.go @@ -277,6 +277,7 @@ func NewMetrics(r prometheus.Registerer) *Metrics { "opsgenie", "webhook", "victorops", + "sns", } { m.numNotifications.WithLabelValues(integration) m.numTotalFailedNotifications.WithLabelValues(integration) diff --git a/notify/sns/sns.go b/notify/sns/sns.go new file mode 100644 index 0000000000..b816d76559 --- /dev/null +++ b/notify/sns/sns.go @@ -0,0 +1,124 @@ +// Copyright 2021 Prometheus Team +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package sns + +import ( + "context" + "net/http" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/credentials" + "github.com/aws/aws-sdk-go/aws/session" + "github.com/aws/aws-sdk-go/service/sns" + "github.com/go-kit/kit/log" + "github.com/prometheus/alertmanager/config" + "github.com/prometheus/alertmanager/notify" + "github.com/prometheus/alertmanager/template" + "github.com/prometheus/alertmanager/types" + commoncfg "github.com/prometheus/common/config" +) + +// Notifier implements a Notifier for SNS notifications. +type Notifier struct { + conf *config.SNSConfig + tmpl *template.Template + logger log.Logger + client *http.Client + retrier *notify.Retrier +} + +func (n Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, error) { + // TODO: get Credentials from env variables + creds := credentials.NewStaticCredentials(n.conf.Sigv4.AccessKey, string(n.conf.Sigv4.SecretKey), "") + + sess, err := session.NewSessionWithOptions(session.Options{ + Config: aws.Config{ + Region: aws.String(n.conf.Sigv4.Region), + Credentials: creds, + Endpoint: aws.String(n.conf.APIUrl), + }, + Profile: n.conf.Sigv4.Profile, + }) + + data := notify.GetTemplateData(ctx, n.tmpl, alert, n.logger) + tmpl := notify.TmplText(n.tmpl, data, &err) + message := tmpl(n.conf.Message) + + client := sns.New(sess) + publishInput := &sns.PublishInput{} + + if n.conf.TopicARN != "" { + publishInput.SetTopicArn(n.conf.TopicARN) + // TODO: Truncate for SNS at 256KB + publishInput.SetMessage(message) + } + if n.conf.PhoneNumber != "" { + publishInput.SetPhoneNumber(n.conf.PhoneNumber) + // Truncate for SMS + trunc, isTruncated := notify.Truncate(message, 140) + if isTruncated { + publishInput.SetMessage(trunc) + } else { + publishInput.SetMessage(message) + } + } + if n.conf.TopicARN != "" { + publishInput.SetTopicArn(n.conf.TopicARN) + // TODO: Truncate for SNS at 256KB + publishInput.SetMessage(message) + } + + if len(n.conf.Attributes) > 0 { + attributes := map[string]*sns.MessageAttributeValue{} + for k, v := range n.conf.Attributes { + attributes[k] = &sns.MessageAttributeValue{DataType: aws.String("String"), StringValue: aws.String(v)} + } + publishInput.SetMessageAttributes(attributes) + } + + if n.conf.Subject != "" { + publishInput.SetSubject(n.conf.Subject) + } + + publishOutput, err := client.Publish(publishInput) + if err != nil { + // AWS Response is bad, probably a config issue + return false, err + } + + err = n.logger.Log(publishOutput.String()) + if err != nil { + return false, err + } + + // Response is good and does not need to be retried + return false, nil +} + +// New returns a new SNS notification handler. +func New(c *config.SNSConfig, t *template.Template, l log.Logger, httpOpts ...commoncfg.HTTPClientOption) (*Notifier, error) { + + client, err := commoncfg.NewClientFromConfig(*c.HTTPConfig, "sns", append(httpOpts, commoncfg.WithHTTP2Disabled())...) + if err != nil { + return nil, err + } + + return &Notifier{ + conf: c, + tmpl: t, + logger: l, + client: client, + retrier: ¬ify.Retrier{}, + }, nil +} diff --git a/notify/sns/sns_test.go b/notify/sns/sns_test.go new file mode 100644 index 0000000000..7476e61a6d --- /dev/null +++ b/notify/sns/sns_test.go @@ -0,0 +1,65 @@ +// Copyright 2021 Prometheus Team +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package sns + +import ( + "testing" + "time" + + "github.com/go-kit/kit/log" + "github.com/prometheus/alertmanager/config" + "github.com/prometheus/alertmanager/notify/test" + "github.com/prometheus/alertmanager/types" + commoncfg "github.com/prometheus/common/config" + "github.com/prometheus/common/model" + "github.com/stretchr/testify/require" +) + +func TestNotifier_Notify(t *testing.T) { + ctx, _, fn := test.GetContextWithCancelingURL() + defer fn() + attrTest := map[string]string{} + attrTest["key"] = "testVal" + // These are fake values + notifier, err := New( + &config.SNSConfig{ + HTTPConfig: &commoncfg.HTTPClientConfig{}, + Message: `{{ template "sns.default.message" . }}`, + TopicARN: "arn:aws:sns:us-east-2:123456789012:My-Topic", + Sigv4: config.SigV4Config{ + Region: "us-east-2", + AccessKey: "access_key", + SecretKey: "secret_key", + }, + Attributes: attrTest, + }, + test.CreateTmpl(t), + log.NewNopLogger(), + ) + require.NoError(t, err) + + ok, err := notifier.Notify(ctx, []*types.Alert{ + &types.Alert{ + Alert: model.Alert{ + Labels: model.LabelSet{ + "lbl1": "val1", + }, + StartsAt: time.Now(), + EndsAt: time.Now().Add(time.Hour), + }, + }, + }...) + require.NoError(t, err) + require.False(t, ok) +} diff --git a/template/default.tmpl b/template/default.tmpl index 64e95b49ab..f74c590efb 100644 --- a/template/default.tmpl +++ b/template/default.tmpl @@ -217,3 +217,14 @@ Alerts Resolved: {{ end }} {{ end }} {{ define "pushover.default.url" }}{{ template "__alertmanagerURL" . }}{{ end }} + +{{ define "sns.default.message" }}{{ .CommonAnnotations.SortedPairs.Values | join " " }} +{{ if gt (len .Alerts.Firing) 0 }} +Alerts Firing: +{{ template "__text_alert_list" .Alerts.Firing }} +{{ end }} +{{ if gt (len .Alerts.Resolved) 0 }} +Alerts Resolved: +{{ template "__text_alert_list" .Alerts.Resolved }} +{{ end }} +{{ end }} From 5dcf4f5f912c57ed7ed920bc173c2a9fd8d55d0a Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Fri, 11 Jun 2021 10:30:44 -0500 Subject: [PATCH 02/34] ARN Auth start Signed-off-by: Tyler Reid --- notify/sns/sns.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/notify/sns/sns.go b/notify/sns/sns.go index b816d76559..ff13df5618 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -19,6 +19,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" + "github.com/aws/aws-sdk-go/aws/credentials/stscreds" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/sns" "github.com/go-kit/kit/log" @@ -39,11 +40,15 @@ type Notifier struct { } func (n Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, error) { - // TODO: get Credentials from env variables + // TODO: get Credentials from env variables if none passed in + api auth creds := credentials.NewStaticCredentials(n.conf.Sigv4.AccessKey, string(n.conf.Sigv4.SecretKey), "") + if n.conf.Sigv4.AccessKey == "" { + creds = nil + } sess, err := session.NewSessionWithOptions(session.Options{ Config: aws.Config{ + CredentialsChainVerboseErrors: aws.Bool(true), Region: aws.String(n.conf.Sigv4.Region), Credentials: creds, Endpoint: aws.String(n.conf.APIUrl), @@ -51,11 +56,15 @@ func (n Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, erro Profile: n.conf.Sigv4.Profile, }) + if n.conf.Sigv4.RoleARN != "" { + sess.Config.Credentials = stscreds.NewCredentials(sess, n.conf.Sigv4.RoleARN) + } + data := notify.GetTemplateData(ctx, n.tmpl, alert, n.logger) tmpl := notify.TmplText(n.tmpl, data, &err) message := tmpl(n.conf.Message) - client := sns.New(sess) + client := sns.New(sess, &aws.Config{Credentials: creds}) publishInput := &sns.PublishInput{} if n.conf.TopicARN != "" { From 74d15273c0a1852781098479ba85257e64bb5ed0 Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Fri, 11 Jun 2021 16:21:15 -0500 Subject: [PATCH 03/34] Add support for role arn, truncation, dedupe key and env auth Signed-off-by: Tyler Reid --- config/notifiers.go | 8 ++-- config/testdata/conf.sns-test.yml | 1 + notify/sns/sns.go | 62 +++++++++++++++++++++++++------ 3 files changed, 56 insertions(+), 15 deletions(-) diff --git a/config/notifiers.go b/config/notifiers.go index ed25aa5e57..7ef0cf4f7b 100644 --- a/config/notifiers.go +++ b/config/notifiers.go @@ -133,8 +133,9 @@ var ( NotifierConfig: NotifierConfig{ VSendResolved: true, }, - APIVersion: "sns.default.api_version", - Message: `{{ template "sns.default.message" . }}`, + APIVersion: "sns.default.api_version", + Message: `{{ template "sns.default.message" . }}`, + IsFIFOTopic: false, } ) @@ -612,8 +613,9 @@ type SNSConfig struct { Sigv4 SigV4Config `yaml:"sigv4" json:"sigv4"` TopicARN string `yaml:"topic_arn,omitempty" json:"topic_arn,omitempty"` PhoneNumber string `yaml:"phone_number,omitempty" json:"phone_number,omitempty"` - Subject string `yaml:"subject,omitempty" json:"subject,omitempty"` TargetARN string `yaml:"target_arn,omitempty" json:"target_arn,omitempty"` + IsFIFOTopic bool `yaml:"is_fifo_topic,omitempty" json:"is_fifo_topic,omitempty"` + Subject string `yaml:"subject,omitempty" json:"subject,omitempty"` Message string `yaml:"message,omitempty" json:"message,omitempty"` Attributes map[string]string `yaml:"attributes,omitempty" json:"attributes,omitempty"` } diff --git a/config/testdata/conf.sns-test.yml b/config/testdata/conf.sns-test.yml index ab83ed9e06..5cfe317a90 100644 --- a/config/testdata/conf.sns-test.yml +++ b/config/testdata/conf.sns-test.yml @@ -7,6 +7,7 @@ receivers: sns_configs: - api_url: https://sns.us-east-2.amazonaws.com topic_arn: arn:aws:sns:us-east-2:123456789012:My-Topic + is_fifo_topic: true sigv4: region: us-east-2 access_key: access_key diff --git a/notify/sns/sns.go b/notify/sns/sns.go index ff13df5618..e793893778 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -15,7 +15,9 @@ package sns import ( "context" + "fmt" "net/http" + "unicode/utf8" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" @@ -40,22 +42,24 @@ type Notifier struct { } func (n Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, error) { - // TODO: get Credentials from env variables if none passed in + api auth - creds := credentials.NewStaticCredentials(n.conf.Sigv4.AccessKey, string(n.conf.Sigv4.SecretKey), "") + credentials := credentials.NewStaticCredentials(n.conf.Sigv4.AccessKey, string(n.conf.Sigv4.SecretKey), "") if n.conf.Sigv4.AccessKey == "" { - creds = nil + credentials = nil } sess, err := session.NewSessionWithOptions(session.Options{ Config: aws.Config{ - CredentialsChainVerboseErrors: aws.Bool(true), Region: aws.String(n.conf.Sigv4.Region), - Credentials: creds, + Credentials: credentials, Endpoint: aws.String(n.conf.APIUrl), }, Profile: n.conf.Sigv4.Profile, }) + if _, err := sess.Config.Credentials.Get(); err != nil { + return false, fmt.Errorf("could not get SigV4 credentials: %w", err) + } + if n.conf.Sigv4.RoleARN != "" { sess.Config.Credentials = stscreds.NewCredentials(sess, n.conf.Sigv4.RoleARN) } @@ -64,13 +68,19 @@ func (n Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, erro tmpl := notify.TmplText(n.tmpl, data, &err) message := tmpl(n.conf.Message) - client := sns.New(sess, &aws.Config{Credentials: creds}) + client := sns.New(sess, &aws.Config{Credentials: credentials}) publishInput := &sns.PublishInput{} if n.conf.TopicARN != "" { publishInput.SetTopicArn(n.conf.TopicARN) - // TODO: Truncate for SNS at 256KB - publishInput.SetMessage(message) + messageToSend, isTrunc, err := validateAndTruncateMessage(message) + if err != nil { + return false, err + } + if isTrunc { + n.conf.Attributes["truncated"] = "true" + } + publishInput.SetMessage(messageToSend) } if n.conf.PhoneNumber != "" { publishInput.SetPhoneNumber(n.conf.PhoneNumber) @@ -84,8 +94,14 @@ func (n Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, erro } if n.conf.TopicARN != "" { publishInput.SetTopicArn(n.conf.TopicARN) - // TODO: Truncate for SNS at 256KB - publishInput.SetMessage(message) + messageToSend, isTrunc, err := validateAndTruncateMessage(message) + if err != nil { + return false, err + } + if isTrunc { + n.conf.Attributes["truncated"] = "true" + } + publishInput.SetMessage(messageToSend) } if len(n.conf.Attributes) > 0 { @@ -100,9 +116,18 @@ func (n Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, erro publishInput.SetSubject(n.conf.Subject) } + // Deduplication key is only added if it's a FIFO SNS Topic. + if n.conf.IsFIFOTopic { + key, err := notify.ExtractGroupKey(ctx) + if err != nil { + return false, err + } + publishInput.SetMessageDeduplicationId(key.Hash()) + } + publishOutput, err := client.Publish(publishInput) if err != nil { - // AWS Response is bad, probably a config issue + // AWS Response is bad, probably a config issue. return false, err } @@ -111,10 +136,23 @@ func (n Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, erro return false, err } - // Response is good and does not need to be retried + // Response is good and does not need to be retried. return false, nil } +func validateAndTruncateMessage(message string) (string, bool, error) { + if utf8.ValidString(message) { + // if the message is larger than 256KB we have to truncate. + if len(message) > 256*1000 { + truncated := make([]byte, 256*1000, 256*1000) + copy(truncated, message) + return string(truncated), true, nil + } + return message, false, nil + } + return "", false, fmt.Errorf("non utf8 encoded message string") +} + // New returns a new SNS notification handler. func New(c *config.SNSConfig, t *template.Template, l log.Logger, httpOpts ...commoncfg.HTTPClientOption) (*Notifier, error) { From 009f8b17e91f1c875f9d8557eced4e946c13ff43 Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Mon, 14 Jun 2021 10:21:33 -0500 Subject: [PATCH 04/34] Use 1024 rather than 1000 for KB size, fix target arn, handle large SMS messages correctly Signed-off-by: Tyler Reid --- notify/sns/sns.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/notify/sns/sns.go b/notify/sns/sns.go index e793893778..35c88c32ad 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -84,16 +84,16 @@ func (n Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, erro } if n.conf.PhoneNumber != "" { publishInput.SetPhoneNumber(n.conf.PhoneNumber) - // Truncate for SMS - trunc, isTruncated := notify.Truncate(message, 140) + // If SMS message is over 1600 chars, SNS will reject the message. + _, isTruncated := notify.Truncate(message, 1600) if isTruncated { - publishInput.SetMessage(trunc) + return false, fmt.Errorf("SMS message exeeds length of 1600 charactors") } else { publishInput.SetMessage(message) } } - if n.conf.TopicARN != "" { - publishInput.SetTopicArn(n.conf.TopicARN) + if n.conf.TargetARN != "" { + publishInput.SetTargetArn(n.conf.TargetARN) messageToSend, isTrunc, err := validateAndTruncateMessage(message) if err != nil { return false, err @@ -143,8 +143,8 @@ func (n Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, erro func validateAndTruncateMessage(message string) (string, bool, error) { if utf8.ValidString(message) { // if the message is larger than 256KB we have to truncate. - if len(message) > 256*1000 { - truncated := make([]byte, 256*1000, 256*1000) + if len(message) > 256*1024 { + truncated := make([]byte, 256*1024, 256*1024) copy(truncated, message) return string(truncated), true, nil } From 72d63a5d72e50a72ec125bf5e66220138946d1e0 Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Mon, 14 Jun 2021 18:28:57 -0500 Subject: [PATCH 05/34] Remove isFifo config option; use template strings; use retier; other code review comments Signed-off-by: Tyler Reid --- config/notifiers.go | 4 +- notify/sns/sns.go | 105 ++++++++++++++++++++++++-------------------- 2 files changed, 58 insertions(+), 51 deletions(-) diff --git a/config/notifiers.go b/config/notifiers.go index 7ef0cf4f7b..e18be6f697 100644 --- a/config/notifiers.go +++ b/config/notifiers.go @@ -135,7 +135,6 @@ var ( }, APIVersion: "sns.default.api_version", Message: `{{ template "sns.default.message" . }}`, - IsFIFOTopic: false, } ) @@ -590,11 +589,11 @@ func (c *PushoverConfig) UnmarshalYAML(unmarshal func(interface{}) error) error return nil } -// TODO: Move to common? // SigV4Config is the configuration for signing remote write requests with // AWS's SigV4 verification process. Empty values will be retrieved using the // AWS default credentials chain. +// TODO: Move to common. type SigV4Config struct { Region string `yaml:"region,omitempty"` AccessKey string `yaml:"access_key,omitempty"` @@ -614,7 +613,6 @@ type SNSConfig struct { TopicARN string `yaml:"topic_arn,omitempty" json:"topic_arn,omitempty"` PhoneNumber string `yaml:"phone_number,omitempty" json:"phone_number,omitempty"` TargetARN string `yaml:"target_arn,omitempty" json:"target_arn,omitempty"` - IsFIFOTopic bool `yaml:"is_fifo_topic,omitempty" json:"is_fifo_topic,omitempty"` Subject string `yaml:"subject,omitempty" json:"subject,omitempty"` Message string `yaml:"message,omitempty" json:"message,omitempty"` Attributes map[string]string `yaml:"attributes,omitempty" json:"attributes,omitempty"` diff --git a/notify/sns/sns.go b/notify/sns/sns.go index 35c88c32ad..d379e01f3e 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -17,9 +17,11 @@ import ( "context" "fmt" "net/http" + "strings" "unicode/utf8" "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/credentials/stscreds" "github.com/aws/aws-sdk-go/aws/session" @@ -41,17 +43,38 @@ type Notifier struct { retrier *notify.Retrier } +// New returns a new SNS notification handler. +func New(c *config.SNSConfig, t *template.Template, l log.Logger, httpOpts ...commoncfg.HTTPClientOption) (*Notifier, error) { + client, err := commoncfg.NewClientFromConfig(*c.HTTPConfig, "sns", append(httpOpts, commoncfg.WithHTTP2Disabled())...) + if err != nil { + return nil, err + } + + return &Notifier{ + conf: c, + tmpl: t, + logger: l, + client: client, + retrier: ¬ify.Retrier{}, + }, nil +} + func (n Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, error) { - credentials := credentials.NewStaticCredentials(n.conf.Sigv4.AccessKey, string(n.conf.Sigv4.SecretKey), "") - if n.conf.Sigv4.AccessKey == "" { - credentials = nil + var( + err error + data = notify.GetTemplateData(ctx, n.tmpl, alert, n.logger) + tmpl = notify.TmplText(n.tmpl, data, &err) + creds *credentials.Credentials = nil + ) + if n.conf.Sigv4.AccessKey != "" && n.conf.Sigv4.SecretKey != "" { + creds = credentials.NewStaticCredentials(n.conf.Sigv4.AccessKey, string(n.conf.Sigv4.SecretKey), "") } sess, err := session.NewSessionWithOptions(session.Options{ Config: aws.Config{ Region: aws.String(n.conf.Sigv4.Region), - Credentials: credentials, - Endpoint: aws.String(n.conf.APIUrl), + Credentials: creds, + Endpoint: aws.String(tmpl(n.conf.APIUrl)), }, Profile: n.conf.Sigv4.Profile, }) @@ -64,37 +87,44 @@ func (n Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, erro sess.Config.Credentials = stscreds.NewCredentials(sess, n.conf.Sigv4.RoleARN) } - data := notify.GetTemplateData(ctx, n.tmpl, alert, n.logger) - tmpl := notify.TmplText(n.tmpl, data, &err) - message := tmpl(n.conf.Message) - - client := sns.New(sess, &aws.Config{Credentials: credentials}) + client := sns.New(sess, &aws.Config{Credentials: creds}) publishInput := &sns.PublishInput{} if n.conf.TopicARN != "" { - publishInput.SetTopicArn(n.conf.TopicARN) - messageToSend, isTrunc, err := validateAndTruncateMessage(message) + publishInput.SetTopicArn(tmpl(n.conf.TopicARN)) + messageToSend, isTrunc, err := validateAndTruncateMessage(tmpl(n.conf.Message)) if err != nil { return false, err } if isTrunc { n.conf.Attributes["truncated"] = "true" } + + // Deduplication key and Message Group ID are only added if it's a FIFO SNS Topic. + if isFIFOTopic(n.conf.TopicARN) { + key, err := notify.ExtractGroupKey(ctx) + if err != nil { + return false, err + } + publishInput.SetMessageDeduplicationId(key.Hash()) + publishInput.SetMessageGroupId(key.Hash()) + } + publishInput.SetMessage(messageToSend) } if n.conf.PhoneNumber != "" { - publishInput.SetPhoneNumber(n.conf.PhoneNumber) + publishInput.SetPhoneNumber(tmpl(n.conf.PhoneNumber)) // If SMS message is over 1600 chars, SNS will reject the message. - _, isTruncated := notify.Truncate(message, 1600) + _, isTruncated := notify.Truncate(tmpl(n.conf.Message), 1600) if isTruncated { return false, fmt.Errorf("SMS message exeeds length of 1600 charactors") } else { - publishInput.SetMessage(message) + publishInput.SetMessage(tmpl(n.conf.Message)) } } if n.conf.TargetARN != "" { - publishInput.SetTargetArn(n.conf.TargetARN) - messageToSend, isTrunc, err := validateAndTruncateMessage(message) + publishInput.SetTargetArn(tmpl(n.conf.TargetARN)) + messageToSend, isTrunc, err := validateAndTruncateMessage(tmpl(n.conf.Message)) if err != nil { return false, err } @@ -107,28 +137,18 @@ func (n Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, erro if len(n.conf.Attributes) > 0 { attributes := map[string]*sns.MessageAttributeValue{} for k, v := range n.conf.Attributes { - attributes[k] = &sns.MessageAttributeValue{DataType: aws.String("String"), StringValue: aws.String(v)} + attributes[tmpl(k)] = &sns.MessageAttributeValue{DataType: aws.String("String"), StringValue: aws.String(tmpl(v))} } publishInput.SetMessageAttributes(attributes) } if n.conf.Subject != "" { - publishInput.SetSubject(n.conf.Subject) - } - - // Deduplication key is only added if it's a FIFO SNS Topic. - if n.conf.IsFIFOTopic { - key, err := notify.ExtractGroupKey(ctx) - if err != nil { - return false, err - } - publishInput.SetMessageDeduplicationId(key.Hash()) + publishInput.SetSubject(tmpl(n.conf.Subject)) } publishOutput, err := client.Publish(publishInput) if err != nil { - // AWS Response is bad, probably a config issue. - return false, err + return n.retrier.Check(err.(awserr.RequestFailure).StatusCode(), strings.NewReader(err.(awserr.RequestFailure).Message())) } err = n.logger.Log(publishOutput.String()) @@ -136,10 +156,16 @@ func (n Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, erro return false, err } - // Response is good and does not need to be retried. return false, nil } +func isFIFOTopic(topicARN string) bool { + if topicARN[len(topicARN)-5:] == ".fifo" { + return true + } + return false +} + func validateAndTruncateMessage(message string) (string, bool, error) { if utf8.ValidString(message) { // if the message is larger than 256KB we have to truncate. @@ -152,20 +178,3 @@ func validateAndTruncateMessage(message string) (string, bool, error) { } return "", false, fmt.Errorf("non utf8 encoded message string") } - -// New returns a new SNS notification handler. -func New(c *config.SNSConfig, t *template.Template, l log.Logger, httpOpts ...commoncfg.HTTPClientOption) (*Notifier, error) { - - client, err := commoncfg.NewClientFromConfig(*c.HTTPConfig, "sns", append(httpOpts, commoncfg.WithHTTP2Disabled())...) - if err != nil { - return nil, err - } - - return &Notifier{ - conf: c, - tmpl: t, - logger: l, - client: client, - retrier: ¬ify.Retrier{}, - }, nil -} From 6519c399b1a2b6f59ba3c1af1cc19f89eab36756 Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Mon, 14 Jun 2021 22:14:12 -0500 Subject: [PATCH 06/34] Add some tests for sns receiver Signed-off-by: Tyler Reid --- config/config_test.go | 16 ++++- config/testdata/conf.sns-invalid.yml | 14 ++++ ...nf.sns-test.yml => conf.sns-topic-arn.yml} | 1 - notify/sns/sns_test.go | 65 +++++++------------ 4 files changed, 54 insertions(+), 42 deletions(-) create mode 100644 config/testdata/conf.sns-invalid.yml rename config/testdata/{conf.sns-test.yml => conf.sns-topic-arn.yml} (93%) diff --git a/config/config_test.go b/config/config_test.go index 9bae3b7144..6687c7bd51 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -26,7 +26,7 @@ import ( commoncfg "github.com/prometheus/common/config" "github.com/prometheus/common/model" "github.com/stretchr/testify/require" - yaml "gopkg.in/yaml.v2" + "gopkg.in/yaml.v2" ) func TestLoadEmptyString(t *testing.T) { @@ -904,6 +904,20 @@ func TestSlackGlobalAPIURLFile(t *testing.T) { } } +func TestValidSNSConfig(t *testing.T) { + _, err := LoadFile("testdata/conf.sns-topic-arn.yml") + if err != nil { + t.Fatalf("Error parsing %s: %s", "testdata/conf.sns-topic-arn.yml\"", err) + } +} + +func TestInvalidSNSConfig(t *testing.T) { + _, err := LoadFile("testdata/conf.sns-invalid.yml") + if err == nil { + t.Fatalf("expected error with missing fields on SNS config") + } +} + func TestUnmarshalHostPort(t *testing.T) { for _, tc := range []struct { in string diff --git a/config/testdata/conf.sns-invalid.yml b/config/testdata/conf.sns-invalid.yml new file mode 100644 index 0000000000..148c71e647 --- /dev/null +++ b/config/testdata/conf.sns-invalid.yml @@ -0,0 +1,14 @@ +route: + receiver: 'sns-api-notifications' + group_by: [alertname] + +receivers: + - name: 'sns-api-notifications' + sns_configs: + - api_url: https://sns.us-east-2.amazonaws.com + sigv4: + region: us-east-2 + access_key: access_key + secret_key: secret_ket + attributes: + severity: Sev2 diff --git a/config/testdata/conf.sns-test.yml b/config/testdata/conf.sns-topic-arn.yml similarity index 93% rename from config/testdata/conf.sns-test.yml rename to config/testdata/conf.sns-topic-arn.yml index 5cfe317a90..ab83ed9e06 100644 --- a/config/testdata/conf.sns-test.yml +++ b/config/testdata/conf.sns-topic-arn.yml @@ -7,7 +7,6 @@ receivers: sns_configs: - api_url: https://sns.us-east-2.amazonaws.com topic_arn: arn:aws:sns:us-east-2:123456789012:My-Topic - is_fifo_topic: true sigv4: region: us-east-2 access_key: access_key diff --git a/notify/sns/sns_test.go b/notify/sns/sns_test.go index 7476e61a6d..bfa702fd26 100644 --- a/notify/sns/sns_test.go +++ b/notify/sns/sns_test.go @@ -15,51 +15,36 @@ package sns import ( "testing" - "time" - "github.com/go-kit/kit/log" - "github.com/prometheus/alertmanager/config" - "github.com/prometheus/alertmanager/notify/test" - "github.com/prometheus/alertmanager/types" - commoncfg "github.com/prometheus/common/config" - "github.com/prometheus/common/model" "github.com/stretchr/testify/require" ) -func TestNotifier_Notify(t *testing.T) { - ctx, _, fn := test.GetContextWithCancelingURL() - defer fn() - attrTest := map[string]string{} - attrTest["key"] = "testVal" - // These are fake values - notifier, err := New( - &config.SNSConfig{ - HTTPConfig: &commoncfg.HTTPClientConfig{}, - Message: `{{ template "sns.default.message" . }}`, - TopicARN: "arn:aws:sns:us-east-2:123456789012:My-Topic", - Sigv4: config.SigV4Config{ - Region: "us-east-2", - AccessKey: "access_key", - SecretKey: "secret_key", - }, - Attributes: attrTest, - }, - test.CreateTmpl(t), - log.NewNopLogger(), - ) +func TestIsFIFO(t *testing.T) { + require.True(t, isFIFOTopic("arn:aws:sns:us-east-2:624413706616:snsTestTopic.fifo")) + require.False(t, isFIFOTopic("arn:aws:sns:us-east-2:624413706616:snsTestTopic")) +} + +func TestValidateAndTruncateMessage(t *testing.T) { + sBuff := make([]byte, 257*1024, 257*1024) + for i := range sBuff { + sBuff[i] = byte(33) + } + truncatedMessage, isTruncated, err := validateAndTruncateMessage(string(sBuff)) + require.True(t, isTruncated) require.NoError(t, err) + require.NotEqual(t, sBuff, truncatedMessage) + require.Equal(t, len(truncatedMessage), 256*1024) - ok, err := notifier.Notify(ctx, []*types.Alert{ - &types.Alert{ - Alert: model.Alert{ - Labels: model.LabelSet{ - "lbl1": "val1", - }, - StartsAt: time.Now(), - EndsAt: time.Now().Add(time.Hour), - }, - }, - }...) + sBuff = make([]byte, 100, 100) + for i := range sBuff { + sBuff[i] = byte(33) + } + truncatedMessage, isTruncated, err = validateAndTruncateMessage(string(sBuff)) + require.False(t, isTruncated) require.NoError(t, err) - require.False(t, ok) + require.Equal(t, string(sBuff), truncatedMessage) + + invalidUtf8String := "\xc3\x28" + _, _, err = validateAndTruncateMessage(invalidUtf8String) + require.Error(t, err) } From af8406a92006e6e37bcb45fb678a7df86ca62e18 Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Tue, 15 Jun 2021 09:09:01 -0500 Subject: [PATCH 07/34] Check error type before unpacking awserr.requestFailure Signed-off-by: Tyler Reid --- notify/sns/sns.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/notify/sns/sns.go b/notify/sns/sns.go index d379e01f3e..cf0ffd2fdb 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -60,10 +60,10 @@ func New(c *config.SNSConfig, t *template.Template, l log.Logger, httpOpts ...co } func (n Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, error) { - var( - err error - data = notify.GetTemplateData(ctx, n.tmpl, alert, n.logger) - tmpl = notify.TmplText(n.tmpl, data, &err) + var ( + err error + data = notify.GetTemplateData(ctx, n.tmpl, alert, n.logger) + tmpl = notify.TmplText(n.tmpl, data, &err) creds *credentials.Credentials = nil ) if n.conf.Sigv4.AccessKey != "" && n.conf.Sigv4.SecretKey != "" { @@ -148,7 +148,11 @@ func (n Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, erro publishOutput, err := client.Publish(publishInput) if err != nil { - return n.retrier.Check(err.(awserr.RequestFailure).StatusCode(), strings.NewReader(err.(awserr.RequestFailure).Message())) + if e, ok := err.(awserr.RequestFailure); ok { + return n.retrier.Check(e.StatusCode(), strings.NewReader(e.Message())) + } else { + return true, err + } } err = n.logger.Log(publishOutput.String()) From 68fa1bf19fcf6689fe163371541365fcddef78d7 Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Tue, 15 Jun 2021 09:46:07 -0500 Subject: [PATCH 08/34] Add string length check to fifo check Signed-off-by: Tyler Reid --- notify/sns/sns.go | 2 +- notify/sns/sns_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/notify/sns/sns.go b/notify/sns/sns.go index cf0ffd2fdb..262a8c390f 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -164,7 +164,7 @@ func (n Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, erro } func isFIFOTopic(topicARN string) bool { - if topicARN[len(topicARN)-5:] == ".fifo" { + if len(topicARN) > 5 && topicARN[len(topicARN)-5:] == ".fifo" { return true } return false diff --git a/notify/sns/sns_test.go b/notify/sns/sns_test.go index bfa702fd26..510e4548f9 100644 --- a/notify/sns/sns_test.go +++ b/notify/sns/sns_test.go @@ -22,6 +22,7 @@ import ( func TestIsFIFO(t *testing.T) { require.True(t, isFIFOTopic("arn:aws:sns:us-east-2:624413706616:snsTestTopic.fifo")) require.False(t, isFIFOTopic("arn:aws:sns:us-east-2:624413706616:snsTestTopic")) + require.False(t, isFIFOTopic("bad")) } func TestValidateAndTruncateMessage(t *testing.T) { From b509a5bdbb57fe2c55a1792fdc2391333fbd1b6d Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Tue, 15 Jun 2021 17:24:52 -0500 Subject: [PATCH 09/34] Add subject template for subject field. Better check for supplied creds, use GetTopicAttributes to check fifo Signed-off-by: Tyler Reid --- config/notifiers.go | 9 ++++++--- notify/sns/sns.go | 24 +++++++++++++++++++----- template/default.tmpl | 1 + 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/config/notifiers.go b/config/notifiers.go index e18be6f697..2797843bb6 100644 --- a/config/notifiers.go +++ b/config/notifiers.go @@ -133,8 +133,9 @@ var ( NotifierConfig: NotifierConfig{ VSendResolved: true, }, - APIVersion: "sns.default.api_version", - Message: `{{ template "sns.default.message" . }}`, + APIVersion: "sns.default.api_version", + Subject: `{{ template "sns.default.subject" . }}`, + Message: `{{ template "sns.default.message" . }}`, } ) @@ -589,7 +590,6 @@ func (c *PushoverConfig) UnmarshalYAML(unmarshal func(interface{}) error) error return nil } - // SigV4Config is the configuration for signing remote write requests with // AWS's SigV4 verification process. Empty values will be retrieved using the // AWS default credentials chain. @@ -628,5 +628,8 @@ func (c *SNSConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { if c.TargetARN == "" && c.TopicARN == "" && c.PhoneNumber == "" { return fmt.Errorf("must provide either a Target ARN, Topic ARN, or Phone Number for SNS config") } + if (c.Sigv4.AccessKey == "") != (c.Sigv4.SecretKey == "") { + return fmt.Errorf("must provide a AWS SigV4 Access key and Secret Key if credentials are specified in the SNS config") + } return nil } diff --git a/notify/sns/sns.go b/notify/sns/sns.go index 262a8c390f..580a26341b 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -100,8 +100,16 @@ func (n Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, erro n.conf.Attributes["truncated"] = "true" } + isFifo, err := checkTopicFifoAttribute(client, n.conf.TopicARN) + if err != nil { + if e, ok := err.(awserr.RequestFailure); ok { + return n.retrier.Check(e.StatusCode(), strings.NewReader(e.Message())) + } else { + return true, err + } + } // Deduplication key and Message Group ID are only added if it's a FIFO SNS Topic. - if isFIFOTopic(n.conf.TopicARN) { + if isFifo { key, err := notify.ExtractGroupKey(ctx) if err != nil { return false, err @@ -163,11 +171,17 @@ func (n Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, erro return false, nil } -func isFIFOTopic(topicARN string) bool { - if len(topicARN) > 5 && topicARN[len(topicARN)-5:] == ".fifo" { - return true +func checkTopicFifoAttribute(client *sns.SNS, topicARN string) (bool, error) { + fmt.Println("Checking Attributes") + topicAttributes, err := client.GetTopicAttributes(&sns.GetTopicAttributesInput{TopicArn: aws.String(topicARN)}) + if err != nil { + return false, err + } + ta := topicAttributes.Attributes["FifoTopic"] + if ta != nil && *ta == "true" { + return true, nil } - return false + return false, nil } func validateAndTruncateMessage(message string) (string, bool, error) { diff --git a/template/default.tmpl b/template/default.tmpl index f74c590efb..35e4b4c5ad 100644 --- a/template/default.tmpl +++ b/template/default.tmpl @@ -218,6 +218,7 @@ Alerts Resolved: {{ end }} {{ define "pushover.default.url" }}{{ template "__alertmanagerURL" . }}{{ end }} +{{ define "sns.default.subject" }}{{ template "__subject" . }}{{ end }} {{ define "sns.default.message" }}{{ .CommonAnnotations.SortedPairs.Values | join " " }} {{ if gt (len .Alerts.Firing) 0 }} Alerts Firing: From 8d3b1b5896384cf1c4bbc688c8f0628e9901e5dd Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Tue, 15 Jun 2021 18:03:02 -0500 Subject: [PATCH 10/34] Add config docs Signed-off-by: Tyler Reid --- docs/configuration.md | 57 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/docs/configuration.md b/docs/configuration.md index 15a58b07d9..0953febce7 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -691,6 +691,63 @@ value: [ short: | default = slack_config.short_fields ] ``` +## `` +```yaml +# Whether or not to notify about resolved alerts. +[ send_resolved: | default = false ] + +# The SNS API URL i.e. https://sns.us-east-2.amazonaws.com +[api_url: ] + +# The SNS API version i.e. +[ api_version: | default = sns.default.api_version ] + +# Configures AWS's Signature Verification 4 signing process to sign requests. +sigv4: + [ ] + +# SNS topic ARN, i.e. arn:aws:sns:us-east-2:698519295917:My-Topic +# If you don't specify this value, you must specify a value for the phone_number or target_arn. +[ topic_arn: ] + +# Subject line when the message is delivered to email endpoints. +[ subject: | default = '{{ template "sns.default.subject" .}}' ] + +# Phone number if message is delivered via SMS in E.164 format. +# If you don't specify this value, you must specify a value for the topic_arn or target_arn. +[ phone_number: ] + +# The mobile platform endpoint ARN if message is delivered via mobile notifications. +# If you don't specify this value, you must specify a value for the topic_arn or phone_number. +[ target_arn: ] + +# The message content of the SNS notification. +[ message: | default = '{{ template "sns.default.message" .}}' ] + +# SNS message attributes. +attributes: + [key : value] + +# The HTTP client's configuration. +[ http_config: | default = global.http_config ] +``` +###`` +```yaml +# The AWS region. If blank, the region from the default credentials chain is used. +[ region: ] + +# The AWS API keys. Both access_key and secret_key must be supplied or both must be blank. +# If blank the environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` are used. +[ access_key: ] +[ secret_key: ] + +# Named AWS profile used to authenticate. +[ profile: ] + +# AWS Role ARN, an alternative to using AWS API keys. +[ role_arn: ] +``` + ## `` A matcher is a string with a syntax inspired by PromQL and OpenMetrics. The syntax of a matcher consists of three tokens: From 889fa964398d2cdaf9aef2d5e9db74ff5925f389 Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Tue, 15 Jun 2021 18:18:19 -0500 Subject: [PATCH 11/34] Remove isFifoTopic test Signed-off-by: Tyler Reid --- notify/sns/sns_test.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/notify/sns/sns_test.go b/notify/sns/sns_test.go index 510e4548f9..f9b0cbf7c6 100644 --- a/notify/sns/sns_test.go +++ b/notify/sns/sns_test.go @@ -19,12 +19,6 @@ import ( "github.com/stretchr/testify/require" ) -func TestIsFIFO(t *testing.T) { - require.True(t, isFIFOTopic("arn:aws:sns:us-east-2:624413706616:snsTestTopic.fifo")) - require.False(t, isFIFOTopic("arn:aws:sns:us-east-2:624413706616:snsTestTopic")) - require.False(t, isFIFOTopic("bad")) -} - func TestValidateAndTruncateMessage(t *testing.T) { sBuff := make([]byte, 257*1024, 257*1024) for i := range sBuff { From c48b54bdf8b795c73e793225dc22f3bb8b9446db Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Tue, 15 Jun 2021 19:07:19 -0500 Subject: [PATCH 12/34] Fix gosmpl linter issues Signed-off-by: Tyler Reid --- notify/sns/sns.go | 4 ++-- notify/sns/sns_test.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/notify/sns/sns.go b/notify/sns/sns.go index 580a26341b..7cfba6e5ec 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -187,8 +187,8 @@ func checkTopicFifoAttribute(client *sns.SNS, topicARN string) (bool, error) { func validateAndTruncateMessage(message string) (string, bool, error) { if utf8.ValidString(message) { // if the message is larger than 256KB we have to truncate. - if len(message) > 256*1024 { - truncated := make([]byte, 256*1024, 256*1024) + if len(message) > 256 * 1024 { + truncated := make([]byte, 256 * 1024, 256 * 1024) copy(truncated, message) return string(truncated), true, nil } diff --git a/notify/sns/sns_test.go b/notify/sns/sns_test.go index f9b0cbf7c6..6d85d14352 100644 --- a/notify/sns/sns_test.go +++ b/notify/sns/sns_test.go @@ -20,7 +20,7 @@ import ( ) func TestValidateAndTruncateMessage(t *testing.T) { - sBuff := make([]byte, 257*1024, 257*1024) + sBuff := make([]byte, 257 * 1024) for i := range sBuff { sBuff[i] = byte(33) } @@ -28,9 +28,9 @@ func TestValidateAndTruncateMessage(t *testing.T) { require.True(t, isTruncated) require.NoError(t, err) require.NotEqual(t, sBuff, truncatedMessage) - require.Equal(t, len(truncatedMessage), 256*1024) + require.Equal(t, len(truncatedMessage), 256 * 1024) - sBuff = make([]byte, 100, 100) + sBuff = make([]byte, 100) for i := range sBuff { sBuff[i] = byte(33) } From 3a63cc28350640a8877b0cfda1f744ba2e9111a1 Mon Sep 17 00:00:00 2001 From: Marco Pracucci Date: Wed, 16 Jun 2021 15:55:28 +0200 Subject: [PATCH 13/34] Updated assets Signed-off-by: Marco Pracucci --- asset/assets_vfsdata.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/asset/assets_vfsdata.go b/asset/assets_vfsdata.go index 26011bc2e7..9a6b33e87d 100644 --- a/asset/assets_vfsdata.go +++ b/asset/assets_vfsdata.go @@ -162,9 +162,9 @@ var Assets = func() http.FileSystem { "/templates/default.tmpl": &vfsgen۰CompressedFileInfo{ name: "default.tmpl", modTime: time.Date(1970, 1, 1, 0, 0, 1, 0, time.UTC), - uncompressedSize: 17128, + uncompressedSize: 17526, - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xec\x1b\xfd\x6f\xdb\xb6\xf2\x77\xfd\x15\x37\x0d\x0f\x6b\x00\x7f\xa5\xdd\x8a\xc5\xb1\xf3\xe0\x3a\x4a\x23\x3c\xc7\x0e\x6c\xa5\x5d\x31\x0c\x01\x2d\x9d\x6d\xb6\x12\xa9\x91\x54\x1c\x2f\xf5\xff\xfe\x40\x4a\xfe\x90\x3f\x12\xa7\xe8\x92\xec\x3d\x2f\xd8\x66\x91\xf7\x7d\xc7\xbb\xa3\x48\xdd\xdd\x41\x80\x03\xca\x10\xec\xeb\x6b\x12\xa2\x50\x11\x61\x64\x88\xc2\x86\xe9\xb4\xb1\xf4\x7c\x77\x07\xc8\x02\x98\x4e\xad\xad\x28\x57\xdd\x96\xc6\xba\xbb\x83\x92\x73\xab\x50\x30\x12\x5e\x75\x5b\x30\x9d\x96\x7f\x2c\x1b\x38\xf9\x6f\x81\x3e\xd2\x1b\x14\x75\x0d\xd4\xcd\x1e\xe0\x2b\x24\x22\xfc\x33\x41\x31\x49\xd1\x33\x46\x79\x4e\x32\xe9\x7f\x46\x5f\x69\x0e\xbf\x6b\xec\x9e\x22\x2a\x91\xf0\x15\x14\xbf\x8a\x63\x14\x29\x2a\x1d\x00\xfe\x39\x9f\xb4\x07\x54\x50\x36\xd4\x38\x55\x8d\x63\x14\x92\xa5\x33\x33\x0a\x5f\x21\x44\xb6\xcc\xf1\x0f\xd0\x40\xef\x05\x4f\xe2\x16\xe9\x63\x28\x4b\x3d\x2e\x14\x06\x97\x84\x0a\x59\xfa\x40\xc2\x04\x35\xc3\xcf\x9c\x32\xb0\x41\x53\x85\x94\xe5\x50\xc1\x2b\x4d\xab\xd4\xe4\x51\xc4\x59\x8a\x7c\x90\x8d\x2d\xd1\x3b\x80\xe9\xf4\xd5\xdd\x1d\x8c\xa9\x1a\xe5\x81\x4b\x5d\x8c\xf8\x0d\xe6\xb9\xb7\x49\x84\x32\xb3\xe8\x26\xee\x73\xc1\x0f\xe6\xbf\xb6\xb8\x29\x40\xe9\x0b\x1a\x2b\xca\x99\x7d\x8f\x8d\x15\xde\xaa\xd4\xa5\xd7\x21\x95\x2a\x03\x15\x84\x0d\x11\x4a\x30\x9d\xa6\x72\x55\xad\xc5\xe0\xba\x9d\xb4\x55\x8a\xc6\x90\x5a\x7c\xfd\x54\x87\xb9\x02\x99\x60\x29\xf3\x06\x63\x5c\x11\x2d\x53\x8e\xe4\xd2\xf0\xb7\xd1\xed\xf1\x44\xf8\x58\x4d\x9d\x89\x0c\x05\x51\x5c\xa4\x91\x68\x6d\x30\x54\xce\x06\x32\x24\xfe\x97\x52\x80\x03\x92\x84\xaa\xa4\xa8\x0a\x31\xb3\x82\xc2\x28\x0e\x89\xca\xc7\x62\x69\x9b\xc9\xf3\x74\x12\xa9\x57\x43\xb4\x89\x54\x7e\xcd\xed\x48\x6f\x40\xc2\xb0\x4f\xfc\x2f\x6b\xf4\x36\x8a\xaf\x89\xc2\x57\x78\x08\x30\xa4\xec\xcb\xce\x12\xf8\x99\x04\x34\xb0\x77\x43\x88\x05\xea\xe8\xda\x11\x7a\x49\xa0\x7b\x2d\x66\x52\xce\x8e\x22\x53\x9f\x33\x8c\xf8\x67\x6a\xef\x0e\x9f\x88\x70\x57\x89\x77\x57\x6e\xc0\xb9\x4a\x13\xec\x96\x20\x8c\xb5\x6a\x41\xa2\x26\x73\x94\xf5\xf5\xfb\xb8\x70\x5c\xa7\xe8\x87\x14\x99\xfa\xf6\x80\xdc\x46\x71\x51\x04\xbe\xcd\x67\xeb\x74\x29\x93\x8a\x30\x1f\xe5\x06\xba\x6b\x09\xab\xb4\xdd\xaa\x3c\x96\x43\x64\x14\xe7\x84\x23\x94\x92\x0c\xbf\x6d\x7d\xaf\x11\x5b\xf7\x50\x96\xdf\xb7\xa4\xb3\x8d\x09\xdd\x5a\x29\x27\xb9\x7a\x75\x00\x15\x28\x4e\xa7\x56\x3a\x08\xe9\xa0\x49\x9c\xf7\x5b\x24\x5f\xf4\x0c\x93\xe2\x92\x46\x1b\xf8\x75\x51\xf2\xf0\x06\x83\x15\x8e\xb3\xe1\xdd\x79\xce\x30\xd6\xb8\x16\x77\x31\xa9\x34\x79\xfc\xf1\xd1\x94\xf3\xfa\x18\xfd\x11\x51\x8f\xf5\xb9\xb5\xf7\xdf\x3d\xfe\x5b\xee\x0b\xaf\x44\xb8\x46\x6f\xa3\x7f\xb6\x78\x7d\xc5\x3f\x8a\x5f\xeb\x62\xb9\x35\x93\xae\x83\xc7\x44\xa8\xc9\x23\xe0\x15\x19\xee\x0a\x4d\x86\xc8\xd4\xf5\x6a\x89\xcb\xc7\xd7\x0d\xf5\x15\x17\x3c\x96\x8b\xb0\x55\x44\xe1\x75\x3e\xd0\xf6\xb1\xf4\xb8\x5c\xb0\x6e\x55\x64\x8a\xaa\xc9\x75\x40\x65\x1c\x92\xc9\xf5\x96\x6e\xea\xe1\xc4\xbd\x4e\x39\xe2\x8c\x2a\xae\x0d\x72\xad\x38\x0f\x1f\x59\x12\x97\x69\x63\x44\x68\xb8\x88\x83\xc5\x86\xe5\xd1\x52\xe6\x29\x8d\x54\x64\xc4\xb2\x6a\x3f\x9c\x76\x9a\xde\xa7\x4b\x07\xf4\x10\x5c\x5e\xbd\x6b\xb9\x4d\xb0\x8b\xe5\xf2\xc7\x37\xcd\x72\xf9\xd4\x3b\x85\xdf\xce\xbd\x8b\x16\x1c\x96\x2a\xe0\x09\xc2\x24\xd5\xc1\x46\xc2\x72\xd9\x69\xdb\x60\x8f\x94\x8a\xab\xe5\xf2\x78\x3c\x2e\x8d\xdf\x94\xb8\x18\x96\xbd\x6e\xf9\x56\xd3\x3a\xd4\xc8\xd9\xcf\xa2\x5a\xc2\x2c\x05\x2a\xb0\x4f\xac\xda\x0f\xc5\xa2\xd5\x53\x93\x10\x81\xb0\x00\x0c\x93\x00\x05\xd5\x0e\x1d\x08\x1e\x81\x26\x2d\xab\xe5\xf2\x90\xaa\x51\xd2\x2f\xf9\x3c\x2a\x6b\x1d\x86\x09\x2b\x1b\x72\xc4\x4f\xe9\x15\x8d\x6a\xc5\x99\x39\xa4\x65\x59\xde\x08\xe1\xc2\xf5\xa0\x45\x7d\x64\x12\xe1\xd5\x85\xeb\x1d\x58\x56\x93\xc7\x13\x41\x87\x23\x05\xaf\xfc\x03\x78\x5d\x39\xfc\x19\x2e\x52\x8a\x96\x75\x89\x22\xa2\x52\x52\xce\x80\x4a\x18\xa1\xc0\xfe\x04\x86\x82\x30\x85\x41\x01\x06\x02\x11\xf8\x00\xfc\x11\x11\x43\x2c\x80\xe2\x40\xd8\x04\x62\x14\x92\x33\xe0\x7d\x45\x28\xd3\xf1\x4f\xc0\xe7\xf1\xc4\xe2\x03\x50\x23\x2a\x41\xf2\x81\x1a\x13\x91\x6a\x48\xa4\xe4\x3e\x25\x0a\x03\x08\xb8\x9f\x44\xc8\xd2\x85\x0b\x03\x1a\xa2\x84\x57\x6a\x84\x60\xf7\x32\x0c\xfb\xc0\x30\x09\x90\x84\x16\x65\xa0\xe7\x66\x53\x66\xaf\xc7\x13\x05\x02\xa5\x12\xd4\x58\xa1\x00\x94\xf9\x61\x12\x68\x19\x66\xd3\x21\x8d\x68\xc6\x41\xa3\x1b\xc5\xa5\xa5\x38\x24\x12\x0b\x46\xce\x02\x44\x3c\xa0\x03\xfd\x7f\x34\x6a\xc5\x49\x3f\xa4\x72\x54\x80\x80\x6a\xd2\xfd\x44\x61\x01\xa4\x1e\x34\x76\x2c\x68\x3d\xca\x5c\x80\xc4\x30\xb4\x7c\x1e\x53\x94\x60\x74\x5d\x48\x67\x60\xb4\xe8\xb1\x36\xa8\xca\x4c\x24\xf5\xc8\x78\xc4\xa3\xbc\x26\x54\x5a\x83\x44\x30\x2a\x47\x68\x70\x02\x0e\x92\x1b\x8e\x3a\x9a\xf5\x88\x06\x1f\xf0\x30\xe4\x63\xad\x9a\xcf\x59\x40\xb3\xed\x9d\x71\x32\xe9\xeb\x2d\xae\x3f\xf7\x2b\xe3\x8a\xfa\xa9\xb9\x8d\x03\xe2\x85\x57\xb3\x29\x39\x22\x61\x08\x7d\xcc\x0c\x86\x01\x50\x06\x64\x49\x1d\xa1\xd9\xeb\xfe\x50\x51\x12\x42\xcc\x85\xe1\xb7\xaa\x66\xc9\xb2\xbc\x73\x07\x7a\x9d\x33\xef\x63\xa3\xeb\x80\xdb\x83\xcb\x6e\xe7\x83\x7b\xea\x9c\x82\xdd\xe8\x81\xdb\xb3\x0b\xf0\xd1\xf5\xce\x3b\x57\x1e\x7c\x6c\x74\xbb\x8d\xb6\xf7\x09\x3a\x67\xd0\x68\x7f\x82\xff\xb8\xed\xd3\x02\x38\xbf\x5d\x76\x9d\x5e\x0f\x3a\x5d\xcb\xbd\xb8\x6c\xb9\xce\x69\x01\xdc\x76\xb3\x75\x75\xea\xb6\xdf\xc3\xbb\x2b\x0f\xda\x1d\x0f\x5a\xee\x85\xeb\x39\xa7\xe0\x75\x40\x33\xcc\x48\xb9\x4e\x4f\x13\xbb\x70\xba\xcd\xf3\x46\xdb\x6b\xbc\x73\x5b\xae\xf7\xa9\x60\x9d\xb9\x5e\x5b\xd3\x3c\xeb\x74\xa1\x01\x97\x8d\xae\xe7\x36\xaf\x5a\x8d\x2e\x5c\x5e\x75\x2f\x3b\x3d\x07\x1a\xed\x53\x68\x77\xda\x6e\xfb\xac\xeb\xb6\xdf\x3b\x17\x4e\xdb\x2b\x81\xdb\x86\x76\x07\x9c\x0f\x4e\xdb\x83\xde\x79\xa3\xd5\xd2\xac\xac\xc6\x95\x77\xde\xe9\x6a\xf9\xa0\xd9\xb9\xfc\xd4\x75\xdf\x9f\x7b\x70\xde\x69\x9d\x3a\xdd\x1e\xbc\x73\xa0\xe5\x36\xde\xb5\x9c\x94\x55\xfb\x13\x34\x5b\x0d\xf7\xa2\x00\xa7\x8d\x8b\xc6\x7b\xc7\x60\x75\xbc\x73\xa7\x6b\x69\xb0\x54\x3a\xf8\x78\xee\xe8\x21\xcd\xaf\xd1\x86\x46\xd3\x73\x3b\x6d\xad\x46\xb3\xd3\xf6\xba\x8d\xa6\x57\x00\xaf\xd3\xf5\xe6\xa8\x1f\xdd\x9e\x53\x80\x46\xd7\xed\x69\x83\x9c\x75\x3b\x17\x05\x4b\x9b\xb3\x73\xa6\x41\xdc\xb6\xc6\x6b\x3b\x29\x15\x6d\x6a\xc8\x79\xa4\xd3\x35\xcf\x57\x3d\x67\x4e\x10\x4e\x9d\x46\xcb\x6d\xbf\xef\x69\x64\xad\xe2\x0c\xb8\x64\x15\x8b\x27\x56\xcd\xa4\xc0\xdb\x28\x64\xb2\xbe\x21\xb1\x1d\x1e\x1d\x1d\xa5\xf9\xcc\xde\x0d\x48\xea\xe4\x56\xb7\x07\x9c\xa9\xe2\x80\x44\x34\x9c\x54\xe1\xa7\x73\x0c\x6f\x50\x51\x9f\x40\x1b\x13\xfc\xa9\x00\xf3\x81\x02\x34\x04\x25\x61\x01\x24\x61\xb2\x28\x51\xd0\xc1\x31\xf4\xf9\x6d\x51\xd2\xbf\x74\x2d\x86\x3e\x17\x01\x8a\x62\x9f\xdf\x1e\x83\x21\x2a\xe9\x5f\x58\x85\xc3\x9f\xe3\xdb\x63\x88\x88\x18\x52\x56\x85\xca\xb1\xce\xad\x23\x24\xc1\x73\xf2\x8f\x50\x11\xd0\x15\xb5\x6e\xdf\x50\x1c\xeb\x55\x64\xeb\xd5\xab\x90\xa9\xba\x3d\xa6\x81\x1a\xd5\x03\xbc\xa1\x3e\x16\xcd\xc3\xf3\x19\x0b\xca\x33\x71\xb5\x33\x8b\xf8\x67\x42\x6f\xea\x76\x33\x15\xb5\xe8\x4d\x62\x5c\x12\x5c\xb7\x22\x65\xed\xdc\x63\x53\x09\x24\xaa\xfa\x95\x77\x56\xfc\xf5\x99\xc5\x37\xef\x36\x9e\xcf\xdd\xf7\xf5\x22\xb5\xb2\x11\xee\xc4\xb2\x6a\x65\x1d\x94\xfa\x47\x9f\x07\x13\xa0\x0a\x23\xe9\xf3\x18\xeb\xb6\x6d\x1e\xd4\x44\xff\xce\x56\x94\xf4\x47\x18\x11\xb3\xa2\x1c\x5d\xdd\x2f\x66\xbd\xef\x93\x2a\x59\x1c\x63\xff\x0b\x55\xc5\x74\x22\xe2\x5c\x8d\x0c\x52\x5a\x1b\x28\x91\x18\x2c\x80\x74\x6c\x18\xec\x22\x09\x3e\x27\x52\x55\x81\x71\x86\xc7\x30\x42\x5d\x99\xaa\x70\x58\xa9\xfc\xeb\x18\x42\xca\xb0\x38\x1f\x2a\xbd\xc5\xe8\x18\xcc\x0a\x48\x01\xe0\x07\x1a\xe9\xc5\x42\x98\x3a\x86\x3e\xf1\xbf\x0c\x05\x4f\x58\x50\xf4\x79\xc8\x45\x15\x7e\x1c\xbc\xd5\x7f\xcb\xe6\x87\x98\x04\x81\x91\x4a\x47\x43\x7f\x68\x20\xeb\x76\x06\x69\x6b\x7b\x2b\xd2\x7f\xea\xf0\x58\x52\x69\x47\x3d\x36\xca\x0e\x50\x53\xe2\x19\xf3\x18\x80\x96\xe0\x89\x33\xe9\x0d\x0a\x4d\x24\x2c\x92\x90\x0e\x59\x15\x14\x8f\xf3\x86\xba\x31\x13\x75\x5b\xf1\xd8\x3e\xa9\x95\x55\xb0\x10\x34\xcd\xac\xf6\xdb\x4a\xc5\x7e\x01\x42\x67\x5b\xab\x2a\xf4\x43\xee\x7f\xc9\xc5\x76\x44\x6e\x8b\x59\x90\xbc\xad\x54\xe2\xdb\xdc\xa4\x1f\x22\x11\x9a\xa1\x1a\xe5\xc6\xb7\x2d\x94\xb9\x71\x80\x24\x8a\xaf\x2c\x89\x9c\xb5\x8c\xa1\x00\x6a\x01\xbd\x79\xea\xb0\xca\xeb\xbb\x6a\x9c\xfb\x95\x98\xc9\xad\x9d\x6c\x16\x73\xe6\x67\x6d\x09\x1b\x7c\x0c\xc3\x0c\xba\x6e\x57\xd2\x67\x19\x13\x7f\xf6\xfc\xa4\x8a\x66\x93\x82\x04\x34\x91\x55\x78\x63\xc6\x36\x24\x80\xc1\x20\x97\xc5\x52\xb4\x2a\x1c\xc6\xb7\x20\x79\x48\x03\xf8\x11\x8f\xf4\x5f\x3e\x31\x0c\x06\x4b\xb6\x78\x09\xd9\x61\x21\xc9\xd3\x65\x89\xb7\x5b\x17\x5c\xce\xba\x06\x65\x9c\x95\x9a\x5f\x2a\x95\x63\x30\x25\x2a\x83\xf7\x91\x29\x14\x9b\xfc\x65\xfe\xad\x18\xa7\xac\xfb\xcd\x79\xfb\xcb\xeb\xd7\xcd\xcd\x05\xe8\xb5\x8e\x6b\x1b\xb2\xf5\x96\x32\x58\xf6\x5e\x8a\xbb\x79\x45\xce\xfe\x59\x9c\xa9\xce\x0f\x53\xc1\xbc\x2c\xd9\xf8\x2e\xe9\x00\x0e\x61\x3a\x95\xf3\x17\x1e\x30\xe0\x02\x16\xe7\x7e\x5b\xce\x5d\x61\x3a\x5d\xe1\x0a\xcb\xa7\x80\xf5\xdc\x19\xe0\x1a\x58\xf6\x6a\x25\xe7\xfc\x79\x0e\x9e\x3f\x8b\x7d\x98\xee\x52\xcc\x16\xc1\x73\x98\x06\xcf\x7d\xb1\xf1\xe2\x73\xdf\x56\xb3\xbf\xac\x20\x78\xe9\xa1\x50\x81\xca\x2c\x97\xdc\x17\x0e\x99\x1a\x04\x46\x02\x07\x75\x7b\x97\x13\x83\x27\x8e\x87\x59\xd2\x3c\x3b\x3b\xcb\x92\x6f\x80\x3e\x17\xe6\x9d\xdc\x6c\x7b\x90\xdb\x10\xbc\xd6\xdb\x81\x5c\xde\xee\xf3\x30\xd8\x9c\xb8\xfd\x44\x48\x4d\x3d\xe6\x34\x1d\x98\x37\x14\x94\x19\xa2\x59\x5f\xb1\x92\xe0\x7f\xd1\x82\x19\x7a\xe6\x25\xea\x80\x8b\xa8\x0a\x3e\x89\xa9\x22\x21\xfd\x0b\x37\x26\xfd\x37\x3f\xff\x8a\x01\xd9\x50\xaf\xd7\x20\xb2\x61\x63\xe5\x6a\x5a\xc8\xe7\x83\xf3\xee\x2d\xbe\xcd\xdc\x7b\xf2\x81\xe2\x18\x28\x83\x07\xdf\x8e\xd7\xca\x64\x63\x0c\xaf\x24\xde\xcd\xe9\x77\x9e\xba\xef\x3d\xfc\xd8\x50\x14\xf6\x4b\xf6\xef\x59\xb2\x52\x09\xce\x86\xcf\x67\xda\xdf\xb7\xdf\xdc\xfa\x23\x3b\xf9\xaa\x95\x53\x21\xbf\x43\xd4\x6d\x68\x18\xb2\x99\xd9\xf5\xa4\xd5\x23\xb4\x7d\x1c\xfe\x7f\xc4\x61\xda\x9a\xce\x43\xad\xd6\x17\xcf\xfa\x1e\x71\x93\x8d\x1e\xb8\x97\xb7\xfd\xf2\xdc\x33\x2b\xb3\x7d\xdd\x6d\xaa\x05\x8b\x43\xf4\xb4\x12\x3c\x7b\x64\x2c\x49\xf4\x52\xc2\xe3\x41\x8b\x3e\x78\xd9\xf2\x1f\x1a\x2c\xcb\x1d\xe6\xea\xed\xcf\x67\x6a\x28\x67\xed\xd6\x5a\x4f\x99\xb0\x00\x85\xee\xfe\xf2\xe1\x94\xde\x5f\xd5\x4d\xd4\xcb\xcb\x31\xdf\x56\x4d\x77\x6c\xef\x96\xef\x9a\x6c\x74\xef\xbe\x2b\x7c\x31\xd5\xf8\x05\x56\xbf\xda\xe8\x05\xca\xf4\x8f\x5e\xc1\xf7\x75\xc4\xfb\x85\xf5\xbf\xbf\xdd\x9a\xdf\xd9\x5b\x6c\xb8\x66\x43\xcf\xb0\xe5\x5a\xbe\x41\xb8\x8f\xc6\xfd\xa6\x6b\xbf\xe9\xda\x6f\xba\xf6\x9b\xae\xfd\xa6\x6b\xbf\xe9\xda\xa1\x9e\xd6\xca\xe6\x3c\xee\xe4\x11\x47\xa1\x73\x94\xc5\xc8\x93\xdf\xc4\xc8\x5d\x4d\x5a\xba\x69\xb2\x70\xf4\xd1\xd1\xd1\x7d\x07\xdc\xf9\x93\xdd\xf5\x23\xc9\x97\x72\xd2\xfb\x72\xda\x97\xa7\x6c\x5d\x5e\x6f\x6d\x5d\x36\x1e\xa2\x3d\xe4\xf2\xa5\xde\x66\xe5\x5e\x43\xfe\x16\xd6\x72\xba\xca\x7f\xaa\x6e\x3f\xad\xea\x39\x8d\x76\x4e\x55\xc8\x14\xf4\x27\xbb\x9d\xc3\xad\xe7\x8e\xb5\xfb\x0e\xab\x99\xa1\x56\x0e\xe8\xcd\x49\xfa\x5f\x2b\x9f\x26\xfe\x21\xd7\xeb\x52\x15\x17\xf9\xab\x56\xee\xf3\x60\xa2\x47\x46\x2a\x0a\x4f\x2c\x6b\xf3\xf7\x3b\x71\x22\x47\xfc\x06\xc5\x77\xf8\xfe\x7b\x8d\xd4\xdf\xff\x3d\xd8\xf7\xf9\x1c\x6c\xf7\xaf\xc1\xbe\xdf\xc7\x60\x4b\x3c\x77\xb0\xe4\xe2\x9b\xec\x47\x7c\x13\xfa\xdf\x00\x00\x00\xff\xff\x0c\xfc\x40\x51\xe8\x42\x00\x00"), + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xec\x1b\xfd\x6f\xdb\xb6\xf2\x77\xfd\x15\x37\x0d\x0f\x6b\x00\x7f\xa5\xdd\x8a\xc5\xb1\xf3\xe0\x3a\x4a\x23\x3c\xc7\x0e\x6c\xa5\x5d\x31\x0c\x01\x2d\x9d\x6d\xb6\x12\xa9\x91\x54\x1c\x2f\xf5\xff\xfe\x40\x4a\xfe\x90\x3f\x12\xa7\xe8\x92\xec\x3d\x2f\xd8\x66\x51\xf7\x7d\xc7\xbb\xa3\x48\xde\xdd\x41\x80\x03\xca\x10\xec\xeb\x6b\x12\xa2\x50\x11\x61\x64\x88\xc2\x86\xe9\xb4\xb1\xf4\x7c\x77\x07\xc8\x02\x98\x4e\xad\xad\x28\x57\xdd\x96\xc6\xba\xbb\x83\x92\x73\xab\x50\x30\x12\x5e\x75\x5b\x30\x9d\x96\x7f\x2c\x1b\x38\xf9\x6f\x81\x3e\xd2\x1b\x14\x75\x0d\xd4\xcd\x1e\xe0\x2b\x24\x22\xfc\x33\x41\x31\x49\xd1\x33\x46\x79\x4e\x32\xe9\x7f\x46\x5f\x69\x0e\xbf\x6b\xec\x9e\x22\x2a\x91\xf0\x15\x14\xbf\x8a\x63\x14\x29\x2a\x1d\x00\xfe\x39\x7f\x69\x0f\xa8\xa0\x6c\xa8\x71\xaa\x1a\xc7\x28\x24\x4b\x67\x66\x14\xbe\x42\x88\x6c\x99\xe3\x1f\xa0\x81\xde\x0b\x9e\xc4\x2d\xd2\xc7\x50\x96\x7a\x5c\x28\x0c\x2e\x09\x15\xb2\xf4\x81\x84\x09\x6a\x86\x9f\x39\x65\x60\x83\xa6\x0a\x29\xcb\xa1\x82\x57\x9a\x56\xa9\xc9\xa3\x88\xb3\x14\xf9\x20\x1b\x5b\xa2\x77\x00\xd3\xe9\xab\xbb\x3b\x18\x53\x35\xca\x03\x97\xba\x18\xf1\x1b\xcc\x73\x6f\x93\x08\x65\x66\xd1\x4d\xdc\xe7\x82\x1f\xcc\x7f\x6d\x71\x53\x80\xd2\x17\x34\x56\x94\x33\xfb\x1e\x1b\x2b\xbc\x55\xa9\x4b\xaf\x43\x2a\x55\x06\x2a\x08\x1b\x22\x94\x60\x3a\x4d\xe5\xaa\x5a\x8b\xc1\x75\x3b\x69\xab\x14\x8d\x21\xb5\xf8\xfa\xa9\x0e\x73\x05\x32\xc1\x52\xe6\x0d\xc6\xb8\x22\x5a\xa6\x1c\xc9\xa5\xe1\x6f\xa3\xdb\xe3\x89\xf0\xb1\x9a\x3a\x13\x19\x0a\xa2\xb8\x48\x23\xd1\xda\x60\xa8\x9c\x0d\x64\x48\xfc\x2f\xa5\x00\x07\x24\x09\x55\x49\x51\x15\x62\x66\x05\x85\x51\x1c\x12\x95\x8f\xc5\xd2\x36\x93\xe7\xe9\x24\x52\xcf\x86\x68\x13\xa9\xfc\x9c\xdb\x91\xde\x80\x84\x61\x9f\xf8\x5f\xd6\xe8\x6d\x14\x5f\x13\x85\xaf\xf0\x10\x60\x48\xd9\x97\x9d\x25\xf0\x33\x09\x68\x60\xef\x86\x10\x0b\xd4\xd1\xb5\x23\xf4\x92\x40\xf7\x5a\xcc\xa4\x9c\x1d\x45\xa6\x3e\x67\x18\xf1\xcf\xd4\xde\x1d\x3e\x11\xe1\xae\x12\xef\xae\xdc\x80\x73\x95\x26\xd8\x2d\x41\x18\x6b\xd5\x82\x44\x4d\xe6\x28\xeb\xf3\xf7\x71\xe1\xb8\x4e\xd1\x0f\x29\x32\xf5\xed\x01\xb9\x8d\xe2\xa2\x08\x7c\x9b\xcf\xd6\xe9\x52\x26\x15\x61\x3e\xca\x0d\x74\xd7\x12\x56\x69\xbb\x55\x79\x2c\x87\xc8\x28\xce\x09\x47\x28\x25\x19\x7e\xdb\xfc\x5e\x23\xb6\xee\xa1\x2c\xbf\x6f\x49\x67\x1b\x13\xba\xb5\x52\x4e\x72\xf5\xea\x00\x2a\x50\x9c\x4e\xad\x74\x10\xd2\x41\x93\x38\xef\xb7\x48\xbe\xe8\x19\x26\xc5\x25\x8d\x36\xf0\xeb\xa2\xe4\xe1\x0d\x06\x2b\x1c\x67\xc3\xbb\xf3\x9c\x61\xac\x71\x2d\xee\x62\x52\x69\xf2\xf8\xe3\xa3\x29\xe7\xf5\x31\xfa\x23\xa2\x1e\xeb\x73\x6b\xef\xbf\x7b\xfc\xb7\xdc\x17\x5e\x89\x70\x8d\xde\x46\xff\x6c\xf1\xfa\x8a\x7f\x14\xbf\xd6\xc5\x72\x6b\x26\x5d\x07\x8f\x89\x50\x93\x47\xc0\x2b\x32\xdc\x15\x9a\x0c\x91\xa9\xeb\xd5\x12\x97\x8f\xaf\x1b\xea\x2b\x2e\x78\x2c\x17\x61\xab\x88\xc2\xeb\x7c\xa0\xed\x63\xe9\x71\xb9\x60\xdd\xaa\xc8\x14\x55\x93\xeb\x80\xca\x38\x24\x93\xeb\x2d\xdd\xd4\xc3\x89\x7b\x9d\x72\xc4\x19\x55\x5c\x1b\xe4\x5a\x71\x1e\x3e\xb2\x24\x2e\xd3\xc6\x88\xd0\x70\x11\x07\x8b\x05\xcb\xa3\xa5\xcc\x53\x1a\xa9\xc8\x88\x65\xd5\x7e\x38\xed\x34\xbd\x4f\x97\x0e\xe8\x21\xb8\xbc\x7a\xd7\x72\x9b\x60\x17\xcb\xe5\x8f\x6f\x9a\xe5\xf2\xa9\x77\x0a\xbf\x9d\x7b\x17\x2d\x38\x2c\x55\xc0\x13\x84\x49\xaa\x83\x8d\x84\xe5\xb2\xd3\xb6\xc1\x1e\x29\x15\x57\xcb\xe5\xf1\x78\x5c\x1a\xbf\x29\x71\x31\x2c\x7b\xdd\xf2\xad\xa6\x75\xa8\x91\xb3\x9f\x45\xb5\x84\x59\x0a\x54\x60\x9f\x58\xb5\x1f\x8a\x45\xab\xa7\x26\x21\x02\x61\x01\x18\x26\x01\x0a\xaa\x1d\x3a\x10\x3c\x02\x4d\x5a\x56\xcb\xe5\x21\x55\xa3\xa4\x5f\xf2\x79\x54\xd6\x3a\x0c\x13\x56\x36\xe4\x88\x9f\xd2\x2b\x1a\xd5\x8a\x33\x73\x48\xcb\xb2\xbc\x11\xc2\x85\xeb\x41\x8b\xfa\xc8\x24\xc2\xab\x0b\xd7\x3b\xb0\xac\x26\x8f\x27\x82\x0e\x47\x0a\x5e\xf9\x07\xf0\xba\x72\xf8\x33\x5c\xa4\x14\x2d\xeb\x12\x45\x44\xa5\xa4\x9c\x01\x95\x30\x42\x81\xfd\x09\x0c\x05\x61\x0a\x83\x02\x0c\x04\x22\xf0\x01\xf8\x23\x22\x86\x58\x00\xc5\x81\xb0\x09\xc4\x28\x24\x67\xc0\xfb\x8a\x50\xa6\xe3\x9f\x80\xcf\xe3\x89\xc5\x07\xa0\x46\x54\x82\xe4\x03\x35\x26\x22\xd5\x90\x48\xc9\x7d\x4a\x14\x06\x10\x70\x3f\x89\x90\xa5\x13\x17\x06\x34\x44\x09\xaf\xd4\x08\xc1\xee\x65\x18\xf6\x81\x61\x12\x20\x09\x2d\xca\x40\xbf\x9b\xbd\x32\x6b\x3d\x9e\x28\x10\x28\x95\xa0\xc6\x0a\x05\xa0\xcc\x0f\x93\x40\xcb\x30\x7b\x1d\xd2\x88\x66\x1c\x34\xba\x51\x5c\x5a\x8a\x43\x22\xb1\x60\xe4\x2c\x40\xc4\x03\x3a\xd0\xff\x47\xa3\x56\x9c\xf4\x43\x2a\x47\x05\x08\xa8\x26\xdd\x4f\x14\x16\x40\xea\x41\x63\xc7\x82\xd6\xa3\xcc\x05\x48\x0c\x43\xcb\xe7\x31\x45\x09\x46\xd7\x85\x74\x06\x46\x8b\x1e\x6b\x83\xaa\xcc\x44\x52\x8f\x8c\x47\x3c\xca\x6b\x42\xa5\x35\x48\x04\xa3\x72\x84\x06\x27\xe0\x20\xb9\xe1\xa8\xa3\x59\x8f\x68\xf0\x01\x0f\x43\x3e\xd6\xaa\xf9\x9c\x05\x34\x5b\xde\x19\x27\x93\xbe\x5e\xe2\xfa\x73\xbf\x32\xae\xa8\x9f\x9a\xdb\x38\x20\x5e\x78\x35\x7b\x25\x47\x24\x0c\xa1\x8f\x99\xc1\x30\x00\xca\x80\x2c\xa9\x23\x34\x7b\xdd\x1f\x2a\x4a\x42\x88\xb9\x30\xfc\x56\xd5\x2c\x59\x96\x77\xee\x40\xaf\x73\xe6\x7d\x6c\x74\x1d\x70\x7b\x70\xd9\xed\x7c\x70\x4f\x9d\x53\xb0\x1b\x3d\x70\x7b\x76\x01\x3e\xba\xde\x79\xe7\xca\x83\x8f\x8d\x6e\xb7\xd1\xf6\x3e\x41\xe7\x0c\x1a\xed\x4f\xf0\x1f\xb7\x7d\x5a\x00\xe7\xb7\xcb\xae\xd3\xeb\x41\xa7\x6b\xb9\x17\x97\x2d\xd7\x39\x2d\x80\xdb\x6e\xb6\xae\x4e\xdd\xf6\x7b\x78\x77\xe5\x41\xbb\xe3\x41\xcb\xbd\x70\x3d\xe7\x14\xbc\x0e\x68\x86\x19\x29\xd7\xe9\x69\x62\x17\x4e\xb7\x79\xde\x68\x7b\x8d\x77\x6e\xcb\xf5\x3e\x15\xac\x33\xd7\x6b\x6b\x9a\x67\x9d\x2e\x34\xe0\xb2\xd1\xf5\xdc\xe6\x55\xab\xd1\x85\xcb\xab\xee\x65\xa7\xe7\x40\xa3\x7d\x0a\xed\x4e\xdb\x6d\x9f\x75\xdd\xf6\x7b\xe7\xc2\x69\x7b\x25\x70\xdb\xd0\xee\x80\xf3\xc1\x69\x7b\xd0\x3b\x6f\xb4\x5a\x9a\x95\xd5\xb8\xf2\xce\x3b\x5d\x2d\x1f\x34\x3b\x97\x9f\xba\xee\xfb\x73\x0f\xce\x3b\xad\x53\xa7\xdb\x83\x77\x0e\xb4\xdc\xc6\xbb\x96\x93\xb2\x6a\x7f\x82\x66\xab\xe1\x5e\x14\xe0\xb4\x71\xd1\x78\xef\x18\xac\x8e\x77\xee\x74\x2d\x0d\x96\x4a\x07\x1f\xcf\x1d\x3d\xa4\xf9\x35\xda\xd0\x68\x7a\x6e\xa7\xad\xd5\x68\x76\xda\x5e\xb7\xd1\xf4\x0a\xe0\x75\xba\xde\x1c\xf5\xa3\xdb\x73\x0a\xd0\xe8\xba\x3d\x6d\x90\xb3\x6e\xe7\xa2\x60\x69\x73\x76\xce\x34\x88\xdb\xd6\x78\x6d\x27\xa5\xa2\x4d\x0d\x39\x8f\x74\xba\xe6\xf9\xaa\xe7\xcc\x09\xc2\xa9\xd3\x68\xb9\xed\xf7\x3d\x8d\xac\x55\x9c\x01\x97\xac\x62\xf1\xc4\xaa\x99\x14\x78\x1b\x85\x4c\xd6\x37\x24\xb6\xc3\xa3\xa3\xa3\x34\x9f\xd9\xbb\x01\x49\x9d\xdc\xea\xf6\x80\x33\x55\x1c\x90\x88\x86\x93\x2a\xfc\x74\x8e\xe1\x0d\x2a\xea\x13\x68\x63\x82\x3f\x15\x60\x3e\x50\x80\x86\xa0\x24\x2c\x80\x24\x4c\x16\x25\x0a\x3a\x38\x86\x3e\xbf\x2d\x4a\xfa\x97\xae\xc5\xd0\xe7\x22\x40\x51\xec\xf3\xdb\x63\x30\x44\x25\xfd\x0b\xab\x70\xf8\x73\x7c\x7b\x0c\x11\x11\x43\xca\xaa\x50\x39\xd6\xb9\x75\x84\x24\x78\x4e\xfe\x11\x2a\x02\xba\xa2\xd6\xed\x1b\x8a\x63\x3d\x8b\x6c\x3d\x7b\x15\x32\x55\xb7\xc7\x34\x50\xa3\x7a\x80\x37\xd4\xc7\xa2\x79\x78\x3e\x63\x41\x79\x26\xae\x76\x66\x11\xff\x4c\xe8\x4d\xdd\x6e\xa6\xa2\x16\xbd\x49\x8c\x4b\x82\xeb\x56\xa4\xac\x9d\x7b\x6c\x2a\x81\x44\x55\xbf\xf2\xce\x8a\xbf\x3e\xb3\xf8\xe6\xdb\xc6\xf3\xb9\xfb\xbe\x5e\xa4\x56\x36\xc2\x9d\x58\x56\xad\xac\x83\x52\xff\xe8\xf3\x60\x02\x54\x61\x24\x7d\x1e\x63\xdd\xb6\xcd\x83\x9a\xe8\xdf\xd9\x8c\x92\xfe\x08\x23\x62\x66\x94\xa3\xab\xfb\xc5\xac\xf7\x7d\x52\x25\x8b\x63\xec\x7f\xa1\xaa\x98\xbe\x88\x38\x57\x23\x83\x94\xd6\x06\x4a\x24\x06\x0b\x20\x1d\x1b\x06\xbb\x48\x82\xcf\x89\x54\x55\x60\x9c\xe1\x31\x8c\x50\x57\xa6\x2a\x1c\x56\x2a\xff\x3a\x86\x90\x32\x2c\xce\x87\x4a\x6f\x31\x3a\x06\x33\x03\x52\x00\xf8\x81\x46\x7a\xb2\x10\xa6\x8e\xa1\x4f\xfc\x2f\x43\xc1\x13\x16\x14\x7d\x1e\x72\x51\x85\x1f\x07\x6f\xf5\xdf\xb2\xf9\x21\x26\x41\x60\xa4\xd2\xd1\xd0\x1f\x1a\xc8\xba\x9d\x41\xda\xda\xde\x8a\xf4\x9f\x3a\x3c\x96\x54\xda\x51\x8f\x8d\xb2\x03\xd4\x94\x78\xc6\x3c\x06\xa0\x25\x78\xe2\x4c\x7a\x83\x42\x13\x09\x8b\x24\xa4\x43\x56\x05\xc5\xe3\xbc\xa1\x6e\xcc\x8b\xba\xad\x78\x6c\x9f\xd4\xca\x2a\x58\x08\x9a\x66\x56\xfb\x6d\xa5\x62\xbf\x00\xa1\xb3\xa5\x55\x15\xfa\x21\xf7\xbf\xe4\x62\x3b\x22\xb7\xc5\x2c\x48\xde\x56\x2a\xf1\x6d\xee\xa5\x1f\x22\x11\x9a\xa1\x1a\xe5\xc6\xb7\x4d\x94\xb9\x71\x80\x24\x8a\xaf\x4c\x89\x9c\xb5\x8c\xa1\x00\x6a\x01\xbd\x79\xea\xb0\xca\xeb\xbb\x6a\x9c\xfb\x95\x98\xc9\xad\x9d\x6c\x26\x73\xe6\x67\x6d\x09\x1b\x7c\x0c\xc3\x0c\xba\x6e\x57\xd2\x67\x19\x13\x7f\xf6\xfc\xa4\x8a\x66\x2f\x05\x09\x68\x22\xab\xf0\xc6\x8c\x6d\x48\x00\x83\x41\x2e\x8b\xa5\x68\x55\x38\x8c\x6f\x41\xf2\x90\x06\xf0\x23\x1e\xe9\xbf\x7c\x62\x18\x0c\x96\x6c\xf1\x12\xb2\xc3\x42\x92\xa7\xcb\x12\x6f\xb7\x4e\xb8\x9c\x75\x0d\xca\x38\x2b\x35\xbf\x54\x2a\xc7\x60\x4a\x54\x06\xef\x23\x53\x28\x36\xf9\xcb\xfc\x5b\x31\x4e\x59\xf7\x9b\xf3\xf6\x97\xd7\xaf\x9b\x9b\x0b\xd0\x6b\x1d\xd7\x36\x64\xf3\x2d\x65\xb0\xec\xbd\x14\x77\xf3\x8c\x9c\xfd\xb3\xd8\x53\x9d\x6f\xa6\x82\xf9\x58\xb2\xf1\x5b\xd2\x01\x1c\xc2\x74\x2a\xe7\x1f\x3c\x60\xc0\x05\x2c\xf6\xfd\xb6\xec\xbb\xc2\x74\xba\xc2\x15\x96\x77\x01\xeb\xb9\x3d\xc0\x35\xb0\xec\xd3\x4a\xce\xf9\xf3\x1c\x3c\x7f\x16\xfb\x30\xdd\xa5\x98\x2d\x82\xe7\x30\x0d\x9e\xfb\x62\xe3\xc5\xe7\xbe\xad\x66\x7f\x59\x41\xf0\xd2\x43\xa1\x02\x95\x59\x2e\xb9\x2f\x1c\x32\x35\x08\x8c\x04\x0e\xea\xf6\x2e\x3b\x06\x4f\x1c\x0f\xb3\xa4\x79\x76\x76\x96\x25\xdf\x00\x7d\x2e\xcc\x37\xb9\xd9\xf2\x20\xb7\x20\x78\xad\x97\x03\xb9\xbc\xdd\xe7\x61\xb0\x39\x71\xfb\x89\x90\x9a\x7a\xcc\x69\x3a\x30\x6f\x28\x28\x33\x44\xb3\xbe\x62\x25\xc1\xff\xa2\x05\x33\xf4\xcc\x47\xd4\x01\x17\x51\x15\x7c\x12\x53\x45\x42\xfa\x17\x6e\x4c\xfa\x6f\x7e\xfe\x15\x03\xb2\xa1\x5e\xaf\x41\x64\xc3\xc6\xca\xd5\xb4\x90\xcf\x07\xe7\xdd\x5b\x7c\x9b\xb9\xf7\xe4\x03\xc5\x31\x50\x06\x0f\x7e\x1d\xaf\x95\xc9\xc6\x18\x5e\x49\xbc\x9b\xd3\xef\x3c\x75\xdf\xbb\xf9\xb1\xa1\x28\xec\xa7\xec\xdf\x33\x65\xa5\x12\x9c\x0d\x9f\xcf\xb4\xbf\x6f\x3f\xb9\xf5\x47\xb6\xf3\x55\x2b\xa7\x42\x7e\x87\xa8\xdb\xd0\x30\x64\x6f\x66\xc7\x93\x56\xb7\xd0\xf6\x71\xf8\xff\x11\x87\x69\x6b\x3a\x0f\xb5\x5a\x5f\x3c\xeb\x77\xc4\x4d\x36\x7a\xe0\x5c\xde\xf6\xc3\x73\xcf\xac\xcc\xf6\x79\xb7\xa9\x16\x2c\x36\xd1\xd3\x4a\xf0\xec\x91\xb1\x24\xd1\x4b\x09\x8f\x07\x2d\xfa\xe0\x61\xcb\x7f\x68\xb0\x2c\x77\x98\xab\xa7\x3f\x9f\xa9\xa1\x9c\xb5\x5b\x6b\x3d\x65\xc2\x02\x14\xba\xfb\xcb\x87\x53\x7a\x7e\x55\x37\x51\x2f\x2f\xc7\x7c\x5b\x35\xdd\xb1\xbd\x5b\x3e\x6b\xb2\xd1\xbd\xfb\xae\xf0\xc5\x54\xe3\x17\x58\xfd\x6a\xa3\x17\x28\xd3\x3f\x7a\x06\xdf\xd7\x11\xef\x27\xd6\xff\xfe\x72\x6b\x7e\x66\x6f\xb1\xe0\x9a\x0d\x3d\xc3\x92\x6b\xf9\x04\xe1\x3e\x1a\xf7\x8b\xae\xfd\xa2\x6b\xbf\xe8\xda\x2f\xba\xf6\x8b\xae\xfd\xa2\x6b\x87\x7a\x5a\x2b\x9b\xfd\xb8\x93\x47\x6c\x85\xce\x51\x16\x23\x4f\x7e\x12\x23\x77\x34\x69\xe9\xa4\xc9\xc2\xd1\x47\x47\x47\xf7\x6d\x70\xe7\x77\x76\xd7\xb7\x24\x5f\xca\x4e\xef\xcb\x69\x5f\x9e\xb2\x75\x79\xbd\xb5\x75\xd9\xb8\x89\xf6\x90\xcb\x97\x7a\x9b\x95\x73\x0d\xf9\x53\x58\xcb\xe9\x2a\x7f\x55\xdd\x7e\x5a\xd5\x73\x1a\xed\x9c\xaa\x90\x29\xe8\x4f\x76\xdb\x87\x5b\xcf\x1d\x6b\xe7\x1d\x56\x33\x43\xad\x1c\xd0\x9b\x93\xf4\xbf\x56\x3e\x4d\xfc\x43\x8e\xd7\xa5\x2a\x2e\xf2\x57\xad\xdc\xe7\xc1\x44\x8f\x8c\x54\x14\x9e\x58\xd6\xe6\xfb\x3b\x71\x22\x47\xfc\x06\xc5\x77\xb8\xff\xbd\x46\xea\xef\xbf\x0f\xf6\x7d\xae\x83\xed\x7e\x1b\xec\xfb\x5d\x06\x5b\xe2\xb9\x83\x25\x17\x77\xb2\x1f\x73\x27\x74\xf9\x36\x36\x93\xdf\xe5\x92\xd6\x32\x9d\xbd\x7b\x1f\xe3\xde\xff\x06\x00\x00\xff\xff\x0a\xd2\x4d\x62\x76\x44\x00\x00"), }, } fs["/"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ From 6ada9a634dc7acb24db462a973feaebb82205cce Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Wed, 16 Jun 2021 09:30:54 -0500 Subject: [PATCH 14/34] Cache fifo bool in the notifier Signed-off-by: Tyler Reid --- notify/sns/sns.go | 28 +++++++++++++++------------- notify/sns/sns_test.go | 4 ++-- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/notify/sns/sns.go b/notify/sns/sns.go index 7cfba6e5ec..63e40252ff 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -41,6 +41,7 @@ type Notifier struct { logger log.Logger client *http.Client retrier *notify.Retrier + isFifo *bool } // New returns a new SNS notification handler. @@ -49,7 +50,6 @@ func New(c *config.SNSConfig, t *template.Template, l log.Logger, httpOpts ...co if err != nil { return nil, err } - return &Notifier{ conf: c, tmpl: t, @@ -59,7 +59,7 @@ func New(c *config.SNSConfig, t *template.Template, l log.Logger, httpOpts ...co }, nil } -func (n Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, error) { +func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, error) { var ( err error data = notify.GetTemplateData(ctx, n.tmpl, alert, n.logger) @@ -100,16 +100,19 @@ func (n Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, erro n.conf.Attributes["truncated"] = "true" } - isFifo, err := checkTopicFifoAttribute(client, n.conf.TopicARN) - if err != nil { - if e, ok := err.(awserr.RequestFailure); ok { - return n.retrier.Check(e.StatusCode(), strings.NewReader(e.Message())) - } else { - return true, err + if n.isFifo == nil { + checkFifo, err := checkTopicFifoAttribute(client, n.conf.TopicARN) + if err != nil { + if e, ok := err.(awserr.RequestFailure); ok { + return n.retrier.Check(e.StatusCode(), strings.NewReader(e.Message())) + } else { + return true, err + } } + n.isFifo = &checkFifo } - // Deduplication key and Message Group ID are only added if it's a FIFO SNS Topic. - if isFifo { + if *n.isFifo { + // Deduplication key and Message Group ID are only added if it's a FIFO SNS Topic. key, err := notify.ExtractGroupKey(ctx) if err != nil { return false, err @@ -172,7 +175,6 @@ func (n Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, erro } func checkTopicFifoAttribute(client *sns.SNS, topicARN string) (bool, error) { - fmt.Println("Checking Attributes") topicAttributes, err := client.GetTopicAttributes(&sns.GetTopicAttributesInput{TopicArn: aws.String(topicARN)}) if err != nil { return false, err @@ -187,8 +189,8 @@ func checkTopicFifoAttribute(client *sns.SNS, topicARN string) (bool, error) { func validateAndTruncateMessage(message string) (string, bool, error) { if utf8.ValidString(message) { // if the message is larger than 256KB we have to truncate. - if len(message) > 256 * 1024 { - truncated := make([]byte, 256 * 1024, 256 * 1024) + if len(message) > 256*1024 { + truncated := make([]byte, 256*1024, 256*1024) copy(truncated, message) return string(truncated), true, nil } diff --git a/notify/sns/sns_test.go b/notify/sns/sns_test.go index 6d85d14352..9e36e5a407 100644 --- a/notify/sns/sns_test.go +++ b/notify/sns/sns_test.go @@ -20,7 +20,7 @@ import ( ) func TestValidateAndTruncateMessage(t *testing.T) { - sBuff := make([]byte, 257 * 1024) + sBuff := make([]byte, 257*1024) for i := range sBuff { sBuff[i] = byte(33) } @@ -28,7 +28,7 @@ func TestValidateAndTruncateMessage(t *testing.T) { require.True(t, isTruncated) require.NoError(t, err) require.NotEqual(t, sBuff, truncatedMessage) - require.Equal(t, len(truncatedMessage), 256 * 1024) + require.Equal(t, len(truncatedMessage), 256*1024) sBuff = make([]byte, 100) for i := range sBuff { From 756cddad9c2cd67a66f6f87bf61b4a64f329bdac Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Wed, 16 Jun 2021 09:38:18 -0500 Subject: [PATCH 15/34] Fix for golangci-lint warning Signed-off-by: Tyler Reid --- notify/sns/sns.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notify/sns/sns.go b/notify/sns/sns.go index 63e40252ff..167f7e974c 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -190,7 +190,7 @@ func validateAndTruncateMessage(message string) (string, bool, error) { if utf8.ValidString(message) { // if the message is larger than 256KB we have to truncate. if len(message) > 256*1024 { - truncated := make([]byte, 256*1024, 256*1024) + truncated := make([]byte, 256 * 1024) copy(truncated, message) return string(truncated), true, nil } From 9d37d6cc44c3776388199c754f26be1572ce5a19 Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Wed, 16 Jun 2021 09:56:55 -0500 Subject: [PATCH 16/34] More gofmt fixes Signed-off-by: Tyler Reid --- notify/sns/sns.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notify/sns/sns.go b/notify/sns/sns.go index 167f7e974c..151e62a518 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -190,7 +190,7 @@ func validateAndTruncateMessage(message string) (string, bool, error) { if utf8.ValidString(message) { // if the message is larger than 256KB we have to truncate. if len(message) > 256*1024 { - truncated := make([]byte, 256 * 1024) + truncated := make([]byte, 256*1024) copy(truncated, message) return string(truncated), true, nil } From 3446b352720dd143a8faca47da5dea37085d73ef Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Wed, 16 Jun 2021 14:27:19 -0500 Subject: [PATCH 17/34] Code review fixes: copy attributes, truncate all the messages, fix logging, remove api_version Signed-off-by: Tyler Reid --- config/notifiers.go | 4 +-- docs/configuration.md | 3 -- notify/sns/sns.go | 78 ++++++++++++++++++------------------------ notify/sns/sns_test.go | 6 ++-- 4 files changed, 38 insertions(+), 53 deletions(-) diff --git a/config/notifiers.go b/config/notifiers.go index 2797843bb6..b98108047a 100644 --- a/config/notifiers.go +++ b/config/notifiers.go @@ -133,7 +133,6 @@ var ( NotifierConfig: NotifierConfig{ VSendResolved: true, }, - APIVersion: "sns.default.api_version", Subject: `{{ template "sns.default.subject" . }}`, Message: `{{ template "sns.default.message" . }}`, } @@ -608,7 +607,6 @@ type SNSConfig struct { HTTPConfig *commoncfg.HTTPClientConfig `yaml:"http_config,omitempty" json:"http_config,omitempty"` APIUrl string `yaml:"api_url" json:"api_url"` - APIVersion string `yaml:"api_version,omitempty" json:"api_version,omitempty"` Sigv4 SigV4Config `yaml:"sigv4" json:"sigv4"` TopicARN string `yaml:"topic_arn,omitempty" json:"topic_arn,omitempty"` PhoneNumber string `yaml:"phone_number,omitempty" json:"phone_number,omitempty"` @@ -625,7 +623,7 @@ func (c *SNSConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := unmarshal((*plain)(c)); err != nil { return err } - if c.TargetARN == "" && c.TopicARN == "" && c.PhoneNumber == "" { + if (c.TargetARN == "") != (c.TopicARN == "") != (c.PhoneNumber == "") { return fmt.Errorf("must provide either a Target ARN, Topic ARN, or Phone Number for SNS config") } if (c.Sigv4.AccessKey == "") != (c.Sigv4.SecretKey == "") { diff --git a/docs/configuration.md b/docs/configuration.md index 0953febce7..7fa1f5a448 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -699,9 +699,6 @@ value: # The SNS API URL i.e. https://sns.us-east-2.amazonaws.com [api_url: ] -# The SNS API version i.e. -[ api_version: | default = sns.default.api_version ] - # Configures AWS's Signature Verification 4 signing process to sign requests. sigv4: [ ] diff --git a/notify/sns/sns.go b/notify/sns/sns.go index 151e62a518..77d4a7ae20 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -27,6 +27,7 @@ import ( "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/sns" "github.com/go-kit/kit/log" + "github.com/go-kit/kit/log/level" "github.com/prometheus/alertmanager/config" "github.com/prometheus/alertmanager/notify" "github.com/prometheus/alertmanager/template" @@ -70,6 +71,14 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err creds = credentials.NewStaticCredentials(n.conf.Sigv4.AccessKey, string(n.conf.Sigv4.SecretKey), "") } + attributes := make(map[string]*sns.MessageAttributeValue, len(n.conf.Attributes)) + if len(n.conf.Attributes) > 0 { + for k, v := range n.conf.Attributes { + attributes[tmpl(k)] = &sns.MessageAttributeValue{DataType: aws.String("String"), StringValue: aws.String(tmpl(v))} + } + + } + sess, err := session.NewSessionWithOptions(session.Options{ Config: aws.Config{ Region: aws.String(n.conf.Sigv4.Region), @@ -87,18 +96,13 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err sess.Config.Credentials = stscreds.NewCredentials(sess, n.conf.Sigv4.RoleARN) } + // Max message size for a message in a SNS publish request is 256KB, except for SMS messages where the limit is 1600 characters/runes. + messageSize := 256 * 1024 client := sns.New(sess, &aws.Config{Credentials: creds}) publishInput := &sns.PublishInput{} if n.conf.TopicARN != "" { publishInput.SetTopicArn(tmpl(n.conf.TopicARN)) - messageToSend, isTrunc, err := validateAndTruncateMessage(tmpl(n.conf.Message)) - if err != nil { - return false, err - } - if isTrunc { - n.conf.Attributes["truncated"] = "true" - } if n.isFifo == nil { checkFifo, err := checkTopicFifoAttribute(client, n.conf.TopicARN) @@ -120,43 +124,32 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err publishInput.SetMessageDeduplicationId(key.Hash()) publishInput.SetMessageGroupId(key.Hash()) } - - publishInput.SetMessage(messageToSend) } if n.conf.PhoneNumber != "" { publishInput.SetPhoneNumber(tmpl(n.conf.PhoneNumber)) - // If SMS message is over 1600 chars, SNS will reject the message. - _, isTruncated := notify.Truncate(tmpl(n.conf.Message), 1600) - if isTruncated { - return false, fmt.Errorf("SMS message exeeds length of 1600 charactors") - } else { - publishInput.SetMessage(tmpl(n.conf.Message)) - } + // If we have an SMS message, we need to truncate to 1600 characters/runes. + messageSize = 1600 } if n.conf.TargetARN != "" { publishInput.SetTargetArn(tmpl(n.conf.TargetARN)) - messageToSend, isTrunc, err := validateAndTruncateMessage(tmpl(n.conf.Message)) - if err != nil { - return false, err - } - if isTrunc { - n.conf.Attributes["truncated"] = "true" - } - publishInput.SetMessage(messageToSend) + } - if len(n.conf.Attributes) > 0 { - attributes := map[string]*sns.MessageAttributeValue{} - for k, v := range n.conf.Attributes { - attributes[tmpl(k)] = &sns.MessageAttributeValue{DataType: aws.String("String"), StringValue: aws.String(tmpl(v))} - } - publishInput.SetMessageAttributes(attributes) + messageToSend, isTrunc, err := validateAndTruncateMessage(tmpl(n.conf.Message), messageSize) + if err != nil { + return false, err } + if isTrunc { + attributes[tmpl("truncated")] = &sns.MessageAttributeValue{DataType: aws.String("String"), StringValue: aws.String(tmpl("true"))} + } + publishInput.SetMessage(messageToSend) if n.conf.Subject != "" { publishInput.SetSubject(tmpl(n.conf.Subject)) } + publishInput.SetMessageAttributes(attributes) + publishOutput, err := client.Publish(publishInput) if err != nil { if e, ok := err.(awserr.RequestFailure); ok { @@ -166,10 +159,7 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err } } - err = n.logger.Log(publishOutput.String()) - if err != nil { - return false, err - } + level.Debug(n.logger).Log("msg", "SNS publish successfully sent", "message_id", publishOutput.MessageId, "sequence number", publishOutput.SequenceNumber) return false, nil } @@ -180,21 +170,21 @@ func checkTopicFifoAttribute(client *sns.SNS, topicARN string) (bool, error) { return false, err } ta := topicAttributes.Attributes["FifoTopic"] - if ta != nil && *ta == "true" { + if aws.StringValue(ta) == "true" { return true, nil } return false, nil } -func validateAndTruncateMessage(message string) (string, bool, error) { - if utf8.ValidString(message) { - // if the message is larger than 256KB we have to truncate. - if len(message) > 256*1024 { - truncated := make([]byte, 256*1024) - copy(truncated, message) - return string(truncated), true, nil - } +func validateAndTruncateMessage(message string, sizeInBytes int) (string, bool, error) { + if !utf8.ValidString(message) { + return "", false, fmt.Errorf("non utf8 encoded message string") + } + if len(message) <= sizeInBytes { return message, false, nil } - return "", false, fmt.Errorf("non utf8 encoded message string") + // if the message is larger than our specified size we have to truncate. + truncated := make([]byte, sizeInBytes) + copy(truncated, message) + return string(truncated), true, nil } diff --git a/notify/sns/sns_test.go b/notify/sns/sns_test.go index 9e36e5a407..7d300ab1f6 100644 --- a/notify/sns/sns_test.go +++ b/notify/sns/sns_test.go @@ -24,7 +24,7 @@ func TestValidateAndTruncateMessage(t *testing.T) { for i := range sBuff { sBuff[i] = byte(33) } - truncatedMessage, isTruncated, err := validateAndTruncateMessage(string(sBuff)) + truncatedMessage, isTruncated, err := validateAndTruncateMessage(string(sBuff), 256*1024) require.True(t, isTruncated) require.NoError(t, err) require.NotEqual(t, sBuff, truncatedMessage) @@ -34,12 +34,12 @@ func TestValidateAndTruncateMessage(t *testing.T) { for i := range sBuff { sBuff[i] = byte(33) } - truncatedMessage, isTruncated, err = validateAndTruncateMessage(string(sBuff)) + truncatedMessage, isTruncated, err = validateAndTruncateMessage(string(sBuff), 100) require.False(t, isTruncated) require.NoError(t, err) require.Equal(t, string(sBuff), truncatedMessage) invalidUtf8String := "\xc3\x28" - _, _, err = validateAndTruncateMessage(invalidUtf8String) + _, _, err = validateAndTruncateMessage(invalidUtf8String, 100) require.Error(t, err) } From a56305a3c09ffdad1cae0944358f953679202f2c Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Wed, 16 Jun 2021 14:41:30 -0500 Subject: [PATCH 18/34] Fix spacing from removing default api version Signed-off-by: Tyler Reid --- config/notifiers.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/notifiers.go b/config/notifiers.go index b98108047a..a61d96c346 100644 --- a/config/notifiers.go +++ b/config/notifiers.go @@ -133,8 +133,8 @@ var ( NotifierConfig: NotifierConfig{ VSendResolved: true, }, - Subject: `{{ template "sns.default.subject" . }}`, - Message: `{{ template "sns.default.message" . }}`, + Subject: `{{ template "sns.default.subject" . }}`, + Message: `{{ template "sns.default.message" . }}`, } ) From d4ff90b55545b7d30ea9c279ff6f8e7c43fe0640 Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Wed, 16 Jun 2021 16:42:55 -0500 Subject: [PATCH 19/34] Add missing template for aws region Signed-off-by: Tyler Reid --- notify/sns/sns.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notify/sns/sns.go b/notify/sns/sns.go index 77d4a7ae20..49cf774044 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -81,7 +81,7 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err sess, err := session.NewSessionWithOptions(session.Options{ Config: aws.Config{ - Region: aws.String(n.conf.Sigv4.Region), + Region: aws.String(tmpl(n.conf.Sigv4.Region)), Credentials: creds, Endpoint: aws.String(tmpl(n.conf.APIUrl)), }, From b9b53f172d13f3814d9e41fd2ae16fed47e76d2c Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Thu, 17 Jun 2021 08:51:20 -0500 Subject: [PATCH 20/34] Code review fixes Signed-off-by: Tyler Reid --- docs/configuration.md | 1 + notify/sns/sns.go | 35 +++++++++++++++-------------------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 7fa1f5a448..fddc787534 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -727,6 +727,7 @@ attributes: # The HTTP client's configuration. [ http_config: | default = global.http_config ] + ``` ###`` ```yaml diff --git a/notify/sns/sns.go b/notify/sns/sns.go index 49cf774044..cd2e3adcdf 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -72,16 +72,13 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err } attributes := make(map[string]*sns.MessageAttributeValue, len(n.conf.Attributes)) - if len(n.conf.Attributes) > 0 { - for k, v := range n.conf.Attributes { - attributes[tmpl(k)] = &sns.MessageAttributeValue{DataType: aws.String("String"), StringValue: aws.String(tmpl(v))} - } - + for k, v := range n.conf.Attributes { + attributes[tmpl(k)] = &sns.MessageAttributeValue{DataType: aws.String("String"), StringValue: aws.String(tmpl(v))} } sess, err := session.NewSessionWithOptions(session.Options{ Config: aws.Config{ - Region: aws.String(tmpl(n.conf.Sigv4.Region)), + Region: aws.String(n.conf.Sigv4.Region), Credentials: creds, Endpoint: aws.String(tmpl(n.conf.APIUrl)), }, @@ -97,15 +94,16 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err } // Max message size for a message in a SNS publish request is 256KB, except for SMS messages where the limit is 1600 characters/runes. - messageSize := 256 * 1024 + messageSizeLimit := 256 * 1024 client := sns.New(sess, &aws.Config{Credentials: creds}) publishInput := &sns.PublishInput{} if n.conf.TopicARN != "" { - publishInput.SetTopicArn(tmpl(n.conf.TopicARN)) + topicTmpl := tmpl(n.conf.TopicARN) + publishInput.SetTopicArn(topicTmpl) if n.isFifo == nil { - checkFifo, err := checkTopicFifoAttribute(client, n.conf.TopicARN) + checkFifo, err := checkTopicFifoAttribute(client, topicTmpl) if err != nil { if e, ok := err.(awserr.RequestFailure); ok { return n.retrier.Check(e.StatusCode(), strings.NewReader(e.Message())) @@ -128,19 +126,19 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err if n.conf.PhoneNumber != "" { publishInput.SetPhoneNumber(tmpl(n.conf.PhoneNumber)) // If we have an SMS message, we need to truncate to 1600 characters/runes. - messageSize = 1600 + messageSizeLimit = 1600 } if n.conf.TargetARN != "" { publishInput.SetTargetArn(tmpl(n.conf.TargetARN)) } - messageToSend, isTrunc, err := validateAndTruncateMessage(tmpl(n.conf.Message), messageSize) + messageToSend, isTrunc, err := validateAndTruncateMessage(tmpl(n.conf.Message), messageSizeLimit) if err != nil { return false, err } if isTrunc { - attributes[tmpl("truncated")] = &sns.MessageAttributeValue{DataType: aws.String("String"), StringValue: aws.String(tmpl("true"))} + attributes["truncated"] = &sns.MessageAttributeValue{DataType: aws.String("String"), StringValue: aws.String("true")} } publishInput.SetMessage(messageToSend) @@ -159,7 +157,7 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err } } - level.Debug(n.logger).Log("msg", "SNS publish successfully sent", "message_id", publishOutput.MessageId, "sequence number", publishOutput.SequenceNumber) + level.Debug(n.logger).Log("msg", "SNS message successfully published", "message_id", publishOutput.MessageId, "sequence number", publishOutput.SequenceNumber) return false, nil } @@ -170,21 +168,18 @@ func checkTopicFifoAttribute(client *sns.SNS, topicARN string) (bool, error) { return false, err } ta := topicAttributes.Attributes["FifoTopic"] - if aws.StringValue(ta) == "true" { - return true, nil - } - return false, nil + return aws.StringValue(ta) == "true", nil } -func validateAndTruncateMessage(message string, sizeInBytes int) (string, bool, error) { +func validateAndTruncateMessage(message string, maxMessageSizeInBytes int) (string, bool, error) { if !utf8.ValidString(message) { return "", false, fmt.Errorf("non utf8 encoded message string") } - if len(message) <= sizeInBytes { + if len(message) <= maxMessageSizeInBytes { return message, false, nil } // if the message is larger than our specified size we have to truncate. - truncated := make([]byte, sizeInBytes) + truncated := make([]byte, maxMessageSizeInBytes) copy(truncated, message) return string(truncated), true, nil } From 63f9082ec48dd6364a7dab99dadc890e0dbb47ba Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Thu, 17 Jun 2021 10:45:27 -0500 Subject: [PATCH 21/34] Fix docs spacing Signed-off-by: Tyler Reid --- docs/configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index fddc787534..b5b762403d 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -727,8 +727,8 @@ attributes: # The HTTP client's configuration. [ http_config: | default = global.http_config ] - ``` + ###`` ```yaml # The AWS region. If blank, the region from the default credentials chain is used. From 891105177066746e0050c776c00b1f319fe24510 Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Mon, 21 Jun 2021 12:29:03 -0500 Subject: [PATCH 22/34] Make API URL optional, clear up credential logic Signed-off-by: Tyler Reid --- config/notifiers.go | 2 +- docs/configuration.md | 3 ++- notify/sns/sns.go | 5 ----- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/config/notifiers.go b/config/notifiers.go index a61d96c346..de4095696c 100644 --- a/config/notifiers.go +++ b/config/notifiers.go @@ -606,7 +606,7 @@ type SNSConfig struct { HTTPConfig *commoncfg.HTTPClientConfig `yaml:"http_config,omitempty" json:"http_config,omitempty"` - APIUrl string `yaml:"api_url" json:"api_url"` + APIUrl string `yaml:"api_url,omitempty" json:"api_url,omitempty"` Sigv4 SigV4Config `yaml:"sigv4" json:"sigv4"` TopicARN string `yaml:"topic_arn,omitempty" json:"topic_arn,omitempty"` PhoneNumber string `yaml:"phone_number,omitempty" json:"phone_number,omitempty"` diff --git a/docs/configuration.md b/docs/configuration.md index fcf932a5fd..38465f6259 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -698,7 +698,8 @@ value: # Whether or not to notify about resolved alerts. [ send_resolved: | default = false ] -# The SNS API URL i.e. https://sns.us-east-2.amazonaws.com +# The SNS API URL i.e. https://sns.us-east-2.amazonaws.com. +# If not specified, the SNS API URL from the SNS SDK will be used. [api_url: ] # Configures AWS's Signature Verification 4 signing process to sign requests. diff --git a/notify/sns/sns.go b/notify/sns/sns.go index cd2e3adcdf..04cf6fb2cd 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -79,16 +79,11 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err sess, err := session.NewSessionWithOptions(session.Options{ Config: aws.Config{ Region: aws.String(n.conf.Sigv4.Region), - Credentials: creds, Endpoint: aws.String(tmpl(n.conf.APIUrl)), }, Profile: n.conf.Sigv4.Profile, }) - if _, err := sess.Config.Credentials.Get(); err != nil { - return false, fmt.Errorf("could not get SigV4 credentials: %w", err) - } - if n.conf.Sigv4.RoleARN != "" { sess.Config.Credentials = stscreds.NewCredentials(sess, n.conf.Sigv4.RoleARN) } From dfb4d1fba17add3fcff49011107acf80821e6493 Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Mon, 21 Jun 2021 12:32:36 -0500 Subject: [PATCH 23/34] Fix linter error Signed-off-by: Tyler Reid --- notify/sns/sns.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notify/sns/sns.go b/notify/sns/sns.go index 04cf6fb2cd..ee60c8ad2b 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -78,8 +78,8 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err sess, err := session.NewSessionWithOptions(session.Options{ Config: aws.Config{ - Region: aws.String(n.conf.Sigv4.Region), - Endpoint: aws.String(tmpl(n.conf.APIUrl)), + Region: aws.String(n.conf.Sigv4.Region), + Endpoint: aws.String(tmpl(n.conf.APIUrl)), }, Profile: n.conf.Sigv4.Profile, }) From 9ff4ac33018b1dadef31d03403f3997313e4a008 Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Mon, 21 Jun 2021 13:41:53 -0500 Subject: [PATCH 24/34] Create new session if needed to get STS Creds Signed-off-by: Tyler Reid --- notify/sns/sns.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/notify/sns/sns.go b/notify/sns/sns.go index ee60c8ad2b..b065a0eec4 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -85,9 +85,27 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err }) if n.conf.Sigv4.RoleARN != "" { - sess.Config.Credentials = stscreds.NewCredentials(sess, n.conf.Sigv4.RoleARN) + var stsSess *session.Session + if n.conf.APIUrl == "" { + stsSess = sess + } else { + // If we have set the API URL we need to create a new session to get the STS Credentials. + stsSess, err = session.NewSessionWithOptions(session.Options{ + Config: aws.Config{ + Region: aws.String(n.conf.Sigv4.Region), + }, + Profile: n.conf.Sigv4.Profile, + }) + if err != nil { + if e, ok := err.(awserr.RequestFailure); ok { + return n.retrier.Check(e.StatusCode(), strings.NewReader(e.Message())) + } else { + return true, err + } + } + } + creds = stscreds.NewCredentials(stsSess, n.conf.Sigv4.RoleARN) } - // Max message size for a message in a SNS publish request is 256KB, except for SMS messages where the limit is 1600 characters/runes. messageSizeLimit := 256 * 1024 client := sns.New(sess, &aws.Config{Credentials: creds}) From 30a83f7bf78385f29de1328a86d881cf522762cd Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Tue, 22 Jun 2021 14:43:41 -0500 Subject: [PATCH 25/34] Use supplied user creds when creating an STS client Signed-off-by: Tyler Reid --- notify/sns/sns.go | 1 + 1 file changed, 1 insertion(+) diff --git a/notify/sns/sns.go b/notify/sns/sns.go index b065a0eec4..5977f27d04 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -93,6 +93,7 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err stsSess, err = session.NewSessionWithOptions(session.Options{ Config: aws.Config{ Region: aws.String(n.conf.Sigv4.Region), + Credentials: creds, }, Profile: n.conf.Sigv4.Profile, }) From bd82f70bc20ef3c535037c91bb4e125699670d77 Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Tue, 22 Jun 2021 14:44:33 -0500 Subject: [PATCH 26/34] Fix spacing for client config Signed-off-by: Tyler Reid --- notify/sns/sns.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notify/sns/sns.go b/notify/sns/sns.go index 5977f27d04..90fb684260 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -92,7 +92,7 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err // If we have set the API URL we need to create a new session to get the STS Credentials. stsSess, err = session.NewSessionWithOptions(session.Options{ Config: aws.Config{ - Region: aws.String(n.conf.Sigv4.Region), + Region: aws.String(n.conf.Sigv4.Region), Credentials: creds, }, Profile: n.conf.Sigv4.Profile, From 25e6d4efd9b8f1005d1b681153db077e98e73c72 Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Wed, 23 Jun 2021 09:00:47 -0500 Subject: [PATCH 27/34] Add common/sigv4 with the sigv4 config Signed-off-by: Tyler Reid --- config/notifiers.go | 15 +-- go.mod | 7 +- go.sum | 274 +++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 265 insertions(+), 31 deletions(-) diff --git a/config/notifiers.go b/config/notifiers.go index de4095696c..157f61c4d9 100644 --- a/config/notifiers.go +++ b/config/notifiers.go @@ -20,6 +20,7 @@ import ( "time" "github.com/pkg/errors" + "github.com/prometheus/common/sigv4" commoncfg "github.com/prometheus/common/config" ) @@ -589,25 +590,13 @@ func (c *PushoverConfig) UnmarshalYAML(unmarshal func(interface{}) error) error return nil } -// SigV4Config is the configuration for signing remote write requests with -// AWS's SigV4 verification process. Empty values will be retrieved using the -// AWS default credentials chain. -// TODO: Move to common. -type SigV4Config struct { - Region string `yaml:"region,omitempty"` - AccessKey string `yaml:"access_key,omitempty"` - SecretKey Secret `yaml:"secret_key,omitempty"` - Profile string `yaml:"profile,omitempty"` - RoleARN string `yaml:"role_arn,omitempty"` -} - type SNSConfig struct { NotifierConfig `yaml:",inline" json:",inline"` HTTPConfig *commoncfg.HTTPClientConfig `yaml:"http_config,omitempty" json:"http_config,omitempty"` APIUrl string `yaml:"api_url,omitempty" json:"api_url,omitempty"` - Sigv4 SigV4Config `yaml:"sigv4" json:"sigv4"` + Sigv4 sigv4.SigV4Config `yaml:"sigv4" json:"sigv4"` TopicARN string `yaml:"topic_arn,omitempty" json:"topic_arn,omitempty"` PhoneNumber string `yaml:"phone_number,omitempty" json:"phone_number,omitempty"` TargetARN string `yaml:"target_arn,omitempty" json:"target_arn,omitempty"` diff --git a/go.mod b/go.mod index 5b1e95b684..a80ed35469 100644 --- a/go.mod +++ b/go.mod @@ -23,8 +23,9 @@ require ( github.com/oklog/run v1.1.0 github.com/oklog/ulid v1.3.1 github.com/pkg/errors v0.9.1 - github.com/prometheus/client_golang v1.10.0 - github.com/prometheus/common v0.24.0 + github.com/prometheus/client_golang v1.11.0 + github.com/prometheus/common v0.29.0 + github.com/prometheus/common/sigv4 v0.1.0 github.com/prometheus/exporter-toolkit v0.5.1 github.com/rs/cors v1.7.0 github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 @@ -32,7 +33,7 @@ require ( github.com/stretchr/testify v1.7.0 github.com/xlab/treeprint v1.1.0 go.uber.org/atomic v1.5.0 - golang.org/x/net v0.0.0-20210421230115-4e50805a0758 + golang.org/x/net v0.0.0-20210525063256-abc453219eb5 golang.org/x/tools v0.1.0 gopkg.in/alecthomas/kingpin.v2 v2.2.6 gopkg.in/yaml.v2 v2.4.0 diff --git a/go.sum b/go.sum index 604168acec..df3f13039f 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,38 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= +cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= +cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= +cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= +cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= +cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= @@ -57,8 +89,12 @@ github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -80,7 +116,9 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1 github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= @@ -89,10 +127,15 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0 h1:dXFJfIHVvUcpSgDOV+Ne6t7jXri8Tfv2uOLHUZ2XNuo= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= +github.com/go-kit/log v0.1.0 h1:DGJh0Sm43HbOeYDNnVZFl8BvcYVvjD5bqYJvp0REbwQ= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0 h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih4= @@ -229,15 +272,27 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69 github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= @@ -250,14 +305,29 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5a github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= @@ -298,6 +368,7 @@ github.com/hashicorp/memberlist v0.2.3/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOn github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= +github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc= @@ -317,6 +388,9 @@ github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCV github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U= @@ -434,8 +508,8 @@ github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.10.0 h1:/o0BDeWzLWXNZ+4q5gXltUvaMpJqckTa+jTNoB+z4cg= -github.com/prometheus/client_golang v1.10.0/go.mod h1:WJM3cc3yu7XKBKa/I8WeZm+V3eltZnBwfENSU7mdogU= +github.com/prometheus/client_golang v1.11.0 h1:HNkLOAEQMIDv/K+04rukrLx6ch7msSRwf3/SASFAGtQ= +github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -448,9 +522,11 @@ github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.18.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.24.0 h1:aIycr3wRFxPUq8XlLQlGQ9aNXV3dFi5y62pe/SB262k= -github.com/prometheus/common v0.24.0/go.mod h1:H6QK/N6XVT42whUeIdI3dp36w49c+/iMDk7UAI2qm7Q= +github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= +github.com/prometheus/common v0.29.0 h1:3jqPBvKT4OHAbje2Ql7KeaaSicDBCxMYwEJU1zRJceE= +github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common/sigv4 v0.1.0 h1:qoVebwtwwEhS85Czm2dSROY5fTo2PAPEVdDeppTwGX4= +github.com/prometheus/common/sigv4 v0.1.0/go.mod h1:2Jkxxk9yYvCkE5G1sQT7GuEXm57JrvHu9k5YwTjsNtI= github.com/prometheus/exporter-toolkit v0.5.1 h1:9eqgis5er9xN613ZSADjypCJaDGj9ZlcWBvsIHa8/3c= github.com/prometheus/exporter-toolkit v0.5.1/go.mod h1:OCkM4805mmisBhLmVFw858QYi3v0wKdY6/UxrT0pZVg= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= @@ -520,7 +596,9 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q github.com/xlab/treeprint v1.1.0 h1:G/1DjNkPpfZCFt9CSh6b5/nY4VimlbHF3Rh4obvtzDk= github.com/xlab/treeprint v1.1.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= @@ -535,7 +613,11 @@ go.mongodb.org/mongo-driver v1.5.1 h1:9nOVLGDfOaZ9R0tBumx/BcuqkbFpyTCU2r/Po7A2az go.mongodb.org/mongo-driver v1.5.1/go.mod h1:gRXCHX4Jo7J0IJ1oDQyUxF7jfy19UfxniMS4xxMmUqw= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0 h1:OI5t8sDa1Or+q8AeE+yKeB/SDYioSHAgcVljj9JIETY= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -551,6 +633,7 @@ golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -561,14 +644,34 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9 h1:sYNJzB4J8toYPQTM6pAkcmBRgw9SnQKP9oXCHfgy604= golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -586,26 +689,45 @@ golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210421230115-4e50805a0758 h1:aEpZnXcAmXkd6AvLb2OPt+EN1Zu/8Ne3pCqPjja5PXY= -golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= +golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo= +golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421 h1:Wo7BWFiOk0QRFMLYMqJGFMd9CgUAcGx7V+qEg/h5IBI= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c h1:pkQiBZBvdos9qq4wBAHqlzuZHEXo07pqV06ef90u1WI= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -613,6 +735,8 @@ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a h1:DcqTD9SDLc+1P/r1EmRBwnVsrOwW+kk2vWf9n+1sGhs= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -625,35 +749,56 @@ golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190321052220-f7bb7a8bee54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe h1:WdX7u8s3yOigWAhHEaDl8r9G+4XwFQEQFtBMYyN+kXQ= -golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 h1:JWgyZ1qgdTaF3N3oxC+MdTV7qvEEgHo3otj+HB5CM7Q= +golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -661,6 +806,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -670,22 +817,54 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= @@ -695,31 +874,89 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1 h1:7QnIQpGRHE5RnLKnESfDoxm2dTapTZua5a0kS0A+VXQ= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -750,7 +987,14 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= From 208bed6dee7d9f73171b46a601866e9d31e96684 Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Sun, 27 Jun 2021 20:26:44 -0500 Subject: [PATCH 28/34] Update config docs to clarify fifo SNS deduplication strategy. Remove extra api call get topic attributes and use '.fifo' strategy instead Signed-off-by: Tyler Reid --- docs/configuration.md | 2 ++ notify/sns/sns.go | 10 +--------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 38465f6259..c7b7b04709 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -708,6 +708,8 @@ sigv4: # SNS topic ARN, i.e. arn:aws:sns:us-east-2:698519295917:My-Topic # If you don't specify this value, you must specify a value for the phone_number or target_arn. +# If you are using a FIFO SNS topic you should set a message group interval longer than 5 minutes +# to prevent messages with the same group key being deduplicated by the SNS default deduplication window [ topic_arn: ] # Subject line when the message is delivered to email endpoints. diff --git a/notify/sns/sns.go b/notify/sns/sns.go index 90fb684260..ce4b558b13 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -117,15 +117,7 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err publishInput.SetTopicArn(topicTmpl) if n.isFifo == nil { - checkFifo, err := checkTopicFifoAttribute(client, topicTmpl) - if err != nil { - if e, ok := err.(awserr.RequestFailure); ok { - return n.retrier.Check(e.StatusCode(), strings.NewReader(e.Message())) - } else { - return true, err - } - } - n.isFifo = &checkFifo + n.isFifo = aws.Bool(n.conf.TopicARN[len(n.conf.TopicARN)-5:] == ".fifo") } if *n.isFifo { // Deduplication key and Message Group ID are only added if it's a FIFO SNS Topic. From 1322abdc08696ec97c5d544241c964e261dba9d7 Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Sun, 27 Jun 2021 21:02:20 -0500 Subject: [PATCH 29/34] Remove unused checkTopicFifoAttribute function Signed-off-by: Tyler Reid --- notify/sns/sns.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/notify/sns/sns.go b/notify/sns/sns.go index ce4b558b13..5b88250db3 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -168,15 +168,6 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err return false, nil } -func checkTopicFifoAttribute(client *sns.SNS, topicARN string) (bool, error) { - topicAttributes, err := client.GetTopicAttributes(&sns.GetTopicAttributesInput{TopicArn: aws.String(topicARN)}) - if err != nil { - return false, err - } - ta := topicAttributes.Attributes["FifoTopic"] - return aws.StringValue(ta) == "true", nil -} - func validateAndTruncateMessage(message string, maxMessageSizeInBytes int) (string, bool, error) { if !utf8.ValidString(message) { return "", false, fmt.Errorf("non utf8 encoded message string") From 077b20dd9a17149585d44e45d517c9ec7494eb32 Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Thu, 1 Jul 2021 09:19:25 -0500 Subject: [PATCH 30/34] Add error check when creating sns session Signed-off-by: Tyler Reid --- notify/sns/sns.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/notify/sns/sns.go b/notify/sns/sns.go index 5b88250db3..77501f66e8 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -83,6 +83,13 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err }, Profile: n.conf.Sigv4.Profile, }) + if err != nil { + if e, ok := err.(awserr.RequestFailure); ok { + return n.retrier.Check(e.StatusCode(), strings.NewReader(e.Message())) + } else { + return true, err + } + } if n.conf.Sigv4.RoleARN != "" { var stsSess *session.Session From 7ecb6bcb22de9b658403ab9b88d5bc7ab75f4c50 Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Tue, 6 Jul 2021 18:17:40 -0500 Subject: [PATCH 31/34] Check Error in unit test and clean up docs Signed-off-by: Tyler Reid --- config/config_test.go | 4 ++++ docs/configuration.md | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/config/config_test.go b/config/config_test.go index d37860e7bf..b787b18185 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -1032,6 +1032,10 @@ func TestInvalidSNSConfig(t *testing.T) { if err == nil { t.Fatalf("expected error with missing fields on SNS config") } + const expectedErr = `must provide either a Target ARN, Topic ARN, or Phone Number for SNS config` + if err.Error() != expectedErr { + t.Errorf("Expected: %s\nGot: %s", expectedErr, err.Error()) + } } func TestUnmarshalHostPort(t *testing.T) { diff --git a/docs/configuration.md b/docs/configuration.md index c7b7b04709..fe288e684b 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -700,7 +700,7 @@ value: # The SNS API URL i.e. https://sns.us-east-2.amazonaws.com. # If not specified, the SNS API URL from the SNS SDK will be used. -[api_url: ] +[ api_url: ] # Configures AWS's Signature Verification 4 signing process to sign requests. sigv4: @@ -710,7 +710,7 @@ sigv4: # If you don't specify this value, you must specify a value for the phone_number or target_arn. # If you are using a FIFO SNS topic you should set a message group interval longer than 5 minutes # to prevent messages with the same group key being deduplicated by the SNS default deduplication window -[ topic_arn: ] +[ topic_arn: ] # Subject line when the message is delivered to email endpoints. [ subject: | default = '{{ template "sns.default.subject" .}}' ] @@ -728,7 +728,7 @@ sigv4: # SNS message attributes. attributes: - [key : value] + [ : ... ] # The HTTP client's configuration. [ http_config: | default = global.http_config ] From 4c2a5f156c0337f658b3bd3de1b9af02400d56f3 Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Wed, 7 Jul 2021 18:45:58 -0500 Subject: [PATCH 32/34] Add sigv4 as a global config option Signed-off-by: Tyler Reid --- config/config.go | 82 ++++++++++++++++++++------ config/testdata/conf.sns-topic-arn.yml | 10 ++-- docs/configuration.md | 13 ++-- 3 files changed, 77 insertions(+), 28 deletions(-) diff --git a/config/config.go b/config/config.go index e8c4287f70..4bbd041658 100644 --- a/config/config.go +++ b/config/config.go @@ -28,6 +28,7 @@ import ( "github.com/pkg/errors" commoncfg "github.com/prometheus/common/config" "github.com/prometheus/common/model" + "github.com/prometheus/common/sigv4" "gopkg.in/yaml.v2" "github.com/prometheus/alertmanager/pkg/labels" @@ -454,6 +455,7 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { if sns.HTTPConfig == nil { sns.HTTPConfig = c.Global.HTTPConfig } + sns.Sigv4 = mergeSigV4Configs(sns.Sigv4, c.Global.Sigv4) } names[rcv.Name] = struct{}{} } @@ -522,6 +524,49 @@ func checkTimeInterval(r *Route, timeIntervals map[string]struct{}) error { return nil } +func mergeSigV4Configs(snsSigV4Config sigv4.SigV4Config, globalSigV4Config sigv4.SigV4Config) sigv4.SigV4Config { + var ( + accessKey string + secretKey commoncfg.Secret + region string + profile string + roleARN string + ) + + if snsSigV4Config.AccessKey == "" { + accessKey = globalSigV4Config.AccessKey + } else { + accessKey = snsSigV4Config.AccessKey + } + if snsSigV4Config.SecretKey == "" { + secretKey = globalSigV4Config.SecretKey + } else { + secretKey = snsSigV4Config.SecretKey + } + if snsSigV4Config.Region == "" { + region = globalSigV4Config.Region + } else { + region = snsSigV4Config.Region + } + if snsSigV4Config.Profile == "" { + profile = globalSigV4Config.Profile + } else { + profile = snsSigV4Config.Profile + } + if snsSigV4Config.RoleARN == "" { + roleARN = globalSigV4Config.RoleARN + } else { + roleARN = snsSigV4Config.RoleARN + } + return sigv4.SigV4Config{ + Region: region, + AccessKey: accessKey, + SecretKey: secretKey, + Profile: profile, + RoleARN: roleARN, + } +} + // DefaultGlobalConfig returns GlobalConfig with default values. func DefaultGlobalConfig() GlobalConfig { var defaultHTTPConfig = commoncfg.DefaultHTTPClientConfig @@ -636,24 +681,25 @@ type GlobalConfig struct { HTTPConfig *commoncfg.HTTPClientConfig `yaml:"http_config,omitempty" json:"http_config,omitempty"` - SMTPFrom string `yaml:"smtp_from,omitempty" json:"smtp_from,omitempty"` - SMTPHello string `yaml:"smtp_hello,omitempty" json:"smtp_hello,omitempty"` - SMTPSmarthost HostPort `yaml:"smtp_smarthost,omitempty" json:"smtp_smarthost,omitempty"` - SMTPAuthUsername string `yaml:"smtp_auth_username,omitempty" json:"smtp_auth_username,omitempty"` - SMTPAuthPassword Secret `yaml:"smtp_auth_password,omitempty" json:"smtp_auth_password,omitempty"` - SMTPAuthSecret Secret `yaml:"smtp_auth_secret,omitempty" json:"smtp_auth_secret,omitempty"` - SMTPAuthIdentity string `yaml:"smtp_auth_identity,omitempty" json:"smtp_auth_identity,omitempty"` - SMTPRequireTLS bool `yaml:"smtp_require_tls" json:"smtp_require_tls,omitempty"` - SlackAPIURL *SecretURL `yaml:"slack_api_url,omitempty" json:"slack_api_url,omitempty"` - SlackAPIURLFile string `yaml:"slack_api_url_file,omitempty" json:"slack_api_url_file,omitempty"` - PagerdutyURL *URL `yaml:"pagerduty_url,omitempty" json:"pagerduty_url,omitempty"` - OpsGenieAPIURL *URL `yaml:"opsgenie_api_url,omitempty" json:"opsgenie_api_url,omitempty"` - OpsGenieAPIKey Secret `yaml:"opsgenie_api_key,omitempty" json:"opsgenie_api_key,omitempty"` - WeChatAPIURL *URL `yaml:"wechat_api_url,omitempty" json:"wechat_api_url,omitempty"` - WeChatAPISecret Secret `yaml:"wechat_api_secret,omitempty" json:"wechat_api_secret,omitempty"` - WeChatAPICorpID string `yaml:"wechat_api_corp_id,omitempty" json:"wechat_api_corp_id,omitempty"` - VictorOpsAPIURL *URL `yaml:"victorops_api_url,omitempty" json:"victorops_api_url,omitempty"` - VictorOpsAPIKey Secret `yaml:"victorops_api_key,omitempty" json:"victorops_api_key,omitempty"` + SMTPFrom string `yaml:"smtp_from,omitempty" json:"smtp_from,omitempty"` + SMTPHello string `yaml:"smtp_hello,omitempty" json:"smtp_hello,omitempty"` + SMTPSmarthost HostPort `yaml:"smtp_smarthost,omitempty" json:"smtp_smarthost,omitempty"` + SMTPAuthUsername string `yaml:"smtp_auth_username,omitempty" json:"smtp_auth_username,omitempty"` + SMTPAuthPassword Secret `yaml:"smtp_auth_password,omitempty" json:"smtp_auth_password,omitempty"` + SMTPAuthSecret Secret `yaml:"smtp_auth_secret,omitempty" json:"smtp_auth_secret,omitempty"` + SMTPAuthIdentity string `yaml:"smtp_auth_identity,omitempty" json:"smtp_auth_identity,omitempty"` + SMTPRequireTLS bool `yaml:"smtp_require_tls" json:"smtp_require_tls,omitempty"` + SlackAPIURL *SecretURL `yaml:"slack_api_url,omitempty" json:"slack_api_url,omitempty"` + SlackAPIURLFile string `yaml:"slack_api_url_file,omitempty" json:"slack_api_url_file,omitempty"` + PagerdutyURL *URL `yaml:"pagerduty_url,omitempty" json:"pagerduty_url,omitempty"` + OpsGenieAPIURL *URL `yaml:"opsgenie_api_url,omitempty" json:"opsgenie_api_url,omitempty"` + OpsGenieAPIKey Secret `yaml:"opsgenie_api_key,omitempty" json:"opsgenie_api_key,omitempty"` + WeChatAPIURL *URL `yaml:"wechat_api_url,omitempty" json:"wechat_api_url,omitempty"` + WeChatAPISecret Secret `yaml:"wechat_api_secret,omitempty" json:"wechat_api_secret,omitempty"` + WeChatAPICorpID string `yaml:"wechat_api_corp_id,omitempty" json:"wechat_api_corp_id,omitempty"` + VictorOpsAPIURL *URL `yaml:"victorops_api_url,omitempty" json:"victorops_api_url,omitempty"` + VictorOpsAPIKey Secret `yaml:"victorops_api_key,omitempty" json:"victorops_api_key,omitempty"` + Sigv4 sigv4.SigV4Config `yaml:"sigv4,omitempty" json:"sigv4,omitempty"` } // UnmarshalYAML implements the yaml.Unmarshaler interface for GlobalConfig. diff --git a/config/testdata/conf.sns-topic-arn.yml b/config/testdata/conf.sns-topic-arn.yml index ab83ed9e06..43b8876d6e 100644 --- a/config/testdata/conf.sns-topic-arn.yml +++ b/config/testdata/conf.sns-topic-arn.yml @@ -1,15 +1,15 @@ route: receiver: 'sns-api-notifications' group_by: [alertname] - +global: + sigv4: + region: us-east-2 + access_key: access_key + secret_key: secret_ket receivers: - name: 'sns-api-notifications' sns_configs: - api_url: https://sns.us-east-2.amazonaws.com topic_arn: arn:aws:sns:us-east-2:123456789012:My-Topic - sigv4: - region: us-east-2 - access_key: access_key - secret_key: secret_ket attributes: severity: Sev2 diff --git a/docs/configuration.md b/docs/configuration.md index fe288e684b..86e656ccc9 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -90,6 +90,9 @@ global: [ wechat_api_url: | default = "https://qyapi.weixin.qq.com/cgi-bin/" ] [ wechat_api_secret: ] [ wechat_api_corp_id: ] + # Configures AWS's Signature Verification 4 signing process to sign requests. + sigv4: + [ ] # The default HTTP client configuration [ http_config: ] @@ -737,18 +740,18 @@ attributes: ###`` ```yaml # The AWS region. If blank, the region from the default credentials chain is used. -[ region: ] +[ region: | default = global.sigv4.region ] # The AWS API keys. Both access_key and secret_key must be supplied or both must be blank. # If blank the environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` are used. -[ access_key: ] -[ secret_key: ] +[ access_key: | default = global.sigv4.access_key ] +[ secret_key: | default = global.sigv4.secret_key ] # Named AWS profile used to authenticate. -[ profile: ] +[ profile: | default = global.sigv4.profile ] # AWS Role ARN, an alternative to using AWS API keys. -[ role_arn: ] +[ role_arn: | default = global.sigv4.role_arn ] ``` ## `` From 51b93681b2fb9fe72813967978c2439a82c1705c Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Fri, 9 Jul 2021 08:54:41 -0500 Subject: [PATCH 33/34] Revert "Add sigv4 as a global config option" This reverts commit 4c2a5f156c0337f658b3bd3de1b9af02400d56f3. Signed-off-by: Tyler Reid --- config/config.go | 82 ++++++-------------------- config/testdata/conf.sns-topic-arn.yml | 10 ++-- docs/configuration.md | 13 ++-- 3 files changed, 28 insertions(+), 77 deletions(-) diff --git a/config/config.go b/config/config.go index 4bbd041658..e8c4287f70 100644 --- a/config/config.go +++ b/config/config.go @@ -28,7 +28,6 @@ import ( "github.com/pkg/errors" commoncfg "github.com/prometheus/common/config" "github.com/prometheus/common/model" - "github.com/prometheus/common/sigv4" "gopkg.in/yaml.v2" "github.com/prometheus/alertmanager/pkg/labels" @@ -455,7 +454,6 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { if sns.HTTPConfig == nil { sns.HTTPConfig = c.Global.HTTPConfig } - sns.Sigv4 = mergeSigV4Configs(sns.Sigv4, c.Global.Sigv4) } names[rcv.Name] = struct{}{} } @@ -524,49 +522,6 @@ func checkTimeInterval(r *Route, timeIntervals map[string]struct{}) error { return nil } -func mergeSigV4Configs(snsSigV4Config sigv4.SigV4Config, globalSigV4Config sigv4.SigV4Config) sigv4.SigV4Config { - var ( - accessKey string - secretKey commoncfg.Secret - region string - profile string - roleARN string - ) - - if snsSigV4Config.AccessKey == "" { - accessKey = globalSigV4Config.AccessKey - } else { - accessKey = snsSigV4Config.AccessKey - } - if snsSigV4Config.SecretKey == "" { - secretKey = globalSigV4Config.SecretKey - } else { - secretKey = snsSigV4Config.SecretKey - } - if snsSigV4Config.Region == "" { - region = globalSigV4Config.Region - } else { - region = snsSigV4Config.Region - } - if snsSigV4Config.Profile == "" { - profile = globalSigV4Config.Profile - } else { - profile = snsSigV4Config.Profile - } - if snsSigV4Config.RoleARN == "" { - roleARN = globalSigV4Config.RoleARN - } else { - roleARN = snsSigV4Config.RoleARN - } - return sigv4.SigV4Config{ - Region: region, - AccessKey: accessKey, - SecretKey: secretKey, - Profile: profile, - RoleARN: roleARN, - } -} - // DefaultGlobalConfig returns GlobalConfig with default values. func DefaultGlobalConfig() GlobalConfig { var defaultHTTPConfig = commoncfg.DefaultHTTPClientConfig @@ -681,25 +636,24 @@ type GlobalConfig struct { HTTPConfig *commoncfg.HTTPClientConfig `yaml:"http_config,omitempty" json:"http_config,omitempty"` - SMTPFrom string `yaml:"smtp_from,omitempty" json:"smtp_from,omitempty"` - SMTPHello string `yaml:"smtp_hello,omitempty" json:"smtp_hello,omitempty"` - SMTPSmarthost HostPort `yaml:"smtp_smarthost,omitempty" json:"smtp_smarthost,omitempty"` - SMTPAuthUsername string `yaml:"smtp_auth_username,omitempty" json:"smtp_auth_username,omitempty"` - SMTPAuthPassword Secret `yaml:"smtp_auth_password,omitempty" json:"smtp_auth_password,omitempty"` - SMTPAuthSecret Secret `yaml:"smtp_auth_secret,omitempty" json:"smtp_auth_secret,omitempty"` - SMTPAuthIdentity string `yaml:"smtp_auth_identity,omitempty" json:"smtp_auth_identity,omitempty"` - SMTPRequireTLS bool `yaml:"smtp_require_tls" json:"smtp_require_tls,omitempty"` - SlackAPIURL *SecretURL `yaml:"slack_api_url,omitempty" json:"slack_api_url,omitempty"` - SlackAPIURLFile string `yaml:"slack_api_url_file,omitempty" json:"slack_api_url_file,omitempty"` - PagerdutyURL *URL `yaml:"pagerduty_url,omitempty" json:"pagerduty_url,omitempty"` - OpsGenieAPIURL *URL `yaml:"opsgenie_api_url,omitempty" json:"opsgenie_api_url,omitempty"` - OpsGenieAPIKey Secret `yaml:"opsgenie_api_key,omitempty" json:"opsgenie_api_key,omitempty"` - WeChatAPIURL *URL `yaml:"wechat_api_url,omitempty" json:"wechat_api_url,omitempty"` - WeChatAPISecret Secret `yaml:"wechat_api_secret,omitempty" json:"wechat_api_secret,omitempty"` - WeChatAPICorpID string `yaml:"wechat_api_corp_id,omitempty" json:"wechat_api_corp_id,omitempty"` - VictorOpsAPIURL *URL `yaml:"victorops_api_url,omitempty" json:"victorops_api_url,omitempty"` - VictorOpsAPIKey Secret `yaml:"victorops_api_key,omitempty" json:"victorops_api_key,omitempty"` - Sigv4 sigv4.SigV4Config `yaml:"sigv4,omitempty" json:"sigv4,omitempty"` + SMTPFrom string `yaml:"smtp_from,omitempty" json:"smtp_from,omitempty"` + SMTPHello string `yaml:"smtp_hello,omitempty" json:"smtp_hello,omitempty"` + SMTPSmarthost HostPort `yaml:"smtp_smarthost,omitempty" json:"smtp_smarthost,omitempty"` + SMTPAuthUsername string `yaml:"smtp_auth_username,omitempty" json:"smtp_auth_username,omitempty"` + SMTPAuthPassword Secret `yaml:"smtp_auth_password,omitempty" json:"smtp_auth_password,omitempty"` + SMTPAuthSecret Secret `yaml:"smtp_auth_secret,omitempty" json:"smtp_auth_secret,omitempty"` + SMTPAuthIdentity string `yaml:"smtp_auth_identity,omitempty" json:"smtp_auth_identity,omitempty"` + SMTPRequireTLS bool `yaml:"smtp_require_tls" json:"smtp_require_tls,omitempty"` + SlackAPIURL *SecretURL `yaml:"slack_api_url,omitempty" json:"slack_api_url,omitempty"` + SlackAPIURLFile string `yaml:"slack_api_url_file,omitempty" json:"slack_api_url_file,omitempty"` + PagerdutyURL *URL `yaml:"pagerduty_url,omitempty" json:"pagerduty_url,omitempty"` + OpsGenieAPIURL *URL `yaml:"opsgenie_api_url,omitempty" json:"opsgenie_api_url,omitempty"` + OpsGenieAPIKey Secret `yaml:"opsgenie_api_key,omitempty" json:"opsgenie_api_key,omitempty"` + WeChatAPIURL *URL `yaml:"wechat_api_url,omitempty" json:"wechat_api_url,omitempty"` + WeChatAPISecret Secret `yaml:"wechat_api_secret,omitempty" json:"wechat_api_secret,omitempty"` + WeChatAPICorpID string `yaml:"wechat_api_corp_id,omitempty" json:"wechat_api_corp_id,omitempty"` + VictorOpsAPIURL *URL `yaml:"victorops_api_url,omitempty" json:"victorops_api_url,omitempty"` + VictorOpsAPIKey Secret `yaml:"victorops_api_key,omitempty" json:"victorops_api_key,omitempty"` } // UnmarshalYAML implements the yaml.Unmarshaler interface for GlobalConfig. diff --git a/config/testdata/conf.sns-topic-arn.yml b/config/testdata/conf.sns-topic-arn.yml index 43b8876d6e..ab83ed9e06 100644 --- a/config/testdata/conf.sns-topic-arn.yml +++ b/config/testdata/conf.sns-topic-arn.yml @@ -1,15 +1,15 @@ route: receiver: 'sns-api-notifications' group_by: [alertname] -global: - sigv4: - region: us-east-2 - access_key: access_key - secret_key: secret_ket + receivers: - name: 'sns-api-notifications' sns_configs: - api_url: https://sns.us-east-2.amazonaws.com topic_arn: arn:aws:sns:us-east-2:123456789012:My-Topic + sigv4: + region: us-east-2 + access_key: access_key + secret_key: secret_ket attributes: severity: Sev2 diff --git a/docs/configuration.md b/docs/configuration.md index 86e656ccc9..fe288e684b 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -90,9 +90,6 @@ global: [ wechat_api_url: | default = "https://qyapi.weixin.qq.com/cgi-bin/" ] [ wechat_api_secret: ] [ wechat_api_corp_id: ] - # Configures AWS's Signature Verification 4 signing process to sign requests. - sigv4: - [ ] # The default HTTP client configuration [ http_config: ] @@ -740,18 +737,18 @@ attributes: ###`` ```yaml # The AWS region. If blank, the region from the default credentials chain is used. -[ region: | default = global.sigv4.region ] +[ region: ] # The AWS API keys. Both access_key and secret_key must be supplied or both must be blank. # If blank the environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` are used. -[ access_key: | default = global.sigv4.access_key ] -[ secret_key: | default = global.sigv4.secret_key ] +[ access_key: ] +[ secret_key: ] # Named AWS profile used to authenticate. -[ profile: | default = global.sigv4.profile ] +[ profile: ] # AWS Role ARN, an alternative to using AWS API keys. -[ role_arn: | default = global.sigv4.role_arn ] +[ role_arn: ] ``` ## `` From a1260af1c325e3158400a9179584f592c39b5a98 Mon Sep 17 00:00:00 2001 From: Tyler Reid Date: Fri, 9 Jul 2021 09:24:05 -0500 Subject: [PATCH 34/34] Break notify into submethods to create the session then create the publish input to send. Check we populate a region for all requests. This reverts commit 4c2a5f156c0337f658b3bd3de1b9af02400d56f3. Signed-off-by: Tyler Reid --- notify/sns/sns.go | 106 ++++++++++++++++++++++++++++------------------ 1 file changed, 65 insertions(+), 41 deletions(-) diff --git a/notify/sns/sns.go b/notify/sns/sns.go index 77501f66e8..dbd1ccc145 100644 --- a/notify/sns/sns.go +++ b/notify/sns/sns.go @@ -62,20 +62,45 @@ func New(c *config.SNSConfig, t *template.Template, l log.Logger, httpOpts ...co func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, error) { var ( - err error - data = notify.GetTemplateData(ctx, n.tmpl, alert, n.logger) - tmpl = notify.TmplText(n.tmpl, data, &err) - creds *credentials.Credentials = nil + err error + data = notify.GetTemplateData(ctx, n.tmpl, alert, n.logger) + tmpl = notify.TmplText(n.tmpl, data, &err) ) - if n.conf.Sigv4.AccessKey != "" && n.conf.Sigv4.SecretKey != "" { - creds = credentials.NewStaticCredentials(n.conf.Sigv4.AccessKey, string(n.conf.Sigv4.SecretKey), "") + + client, err := createSNSClient(n, tmpl) + if err != nil { + if e, ok := err.(awserr.RequestFailure); ok { + return n.retrier.Check(e.StatusCode(), strings.NewReader(e.Message())) + } else { + return true, err + } } - attributes := make(map[string]*sns.MessageAttributeValue, len(n.conf.Attributes)) - for k, v := range n.conf.Attributes { - attributes[tmpl(k)] = &sns.MessageAttributeValue{DataType: aws.String("String"), StringValue: aws.String(tmpl(v))} + publishInput, err := createPublishInput(ctx, n, tmpl) + if err != nil { + return true, err + } + + publishOutput, err := client.Publish(publishInput) + if err != nil { + if e, ok := err.(awserr.RequestFailure); ok { + return n.retrier.Check(e.StatusCode(), strings.NewReader(e.Message())) + } else { + return true, err + } } + level.Debug(n.logger).Log("msg", "SNS message successfully published", "message_id", publishOutput.MessageId, "sequence number", publishOutput.SequenceNumber) + + return false, nil +} + +func createSNSClient(n *Notifier, tmpl func(string) string) (*sns.SNS, error) { + var creds *credentials.Credentials = nil + // If there are provided sigV4 credentials we want to use those to create a session. + if n.conf.Sigv4.AccessKey != "" && n.conf.Sigv4.SecretKey != "" { + creds = credentials.NewStaticCredentials(n.conf.Sigv4.AccessKey, string(n.conf.Sigv4.SecretKey), "") + } sess, err := session.NewSessionWithOptions(session.Options{ Config: aws.Config{ Region: aws.String(n.conf.Sigv4.Region), @@ -84,11 +109,7 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err Profile: n.conf.Sigv4.Profile, }) if err != nil { - if e, ok := err.(awserr.RequestFailure); ok { - return n.retrier.Check(e.StatusCode(), strings.NewReader(e.Message())) - } else { - return true, err - } + return nil, err } if n.conf.Sigv4.RoleARN != "" { @@ -105,32 +126,37 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err Profile: n.conf.Sigv4.Profile, }) if err != nil { - if e, ok := err.(awserr.RequestFailure); ok { - return n.retrier.Check(e.StatusCode(), strings.NewReader(e.Message())) - } else { - return true, err - } + return nil, err } } creds = stscreds.NewCredentials(stsSess, n.conf.Sigv4.RoleARN) } - // Max message size for a message in a SNS publish request is 256KB, except for SMS messages where the limit is 1600 characters/runes. - messageSizeLimit := 256 * 1024 + // Use our generated session with credentials to create the SNS Client. client := sns.New(sess, &aws.Config{Credentials: creds}) - publishInput := &sns.PublishInput{} + // We will always need a region to be set by either the local config or the environment. + if aws.StringValue(sess.Config.Region) == "" { + return nil, fmt.Errorf("region not configured in sns.sigv4.region or in default credentials chain") + } + return client, nil +} +func createPublishInput(ctx context.Context, n *Notifier, tmpl func(string) string) (*sns.PublishInput, error) { + publishInput := &sns.PublishInput{} + messageAttributes := createMessageAttributes(n, tmpl) + // Max message size for a message in a SNS publish request is 256KB, except for SMS messages where the limit is 1600 characters/runes. + messageSizeLimit := 256 * 1024 if n.conf.TopicARN != "" { topicTmpl := tmpl(n.conf.TopicARN) publishInput.SetTopicArn(topicTmpl) - if n.isFifo == nil { + // If we are using a topic ARN it could be a FIFO topic specified by the topic postfix .fifo. n.isFifo = aws.Bool(n.conf.TopicARN[len(n.conf.TopicARN)-5:] == ".fifo") } if *n.isFifo { // Deduplication key and Message Group ID are only added if it's a FIFO SNS Topic. key, err := notify.ExtractGroupKey(ctx) if err != nil { - return false, err + return nil, err } publishInput.SetMessageDeduplicationId(key.Hash()) publishInput.SetMessageGroupId(key.Hash()) @@ -143,36 +169,25 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err } if n.conf.TargetARN != "" { publishInput.SetTargetArn(tmpl(n.conf.TargetARN)) - } messageToSend, isTrunc, err := validateAndTruncateMessage(tmpl(n.conf.Message), messageSizeLimit) if err != nil { - return false, err + return nil, err } if isTrunc { - attributes["truncated"] = &sns.MessageAttributeValue{DataType: aws.String("String"), StringValue: aws.String("true")} + // If we truncated the message we need to add a message attribute showing that it was truncated. + messageAttributes["truncated"] = &sns.MessageAttributeValue{DataType: aws.String("String"), StringValue: aws.String("true")} } + publishInput.SetMessage(messageToSend) + publishInput.SetMessageAttributes(messageAttributes) if n.conf.Subject != "" { publishInput.SetSubject(tmpl(n.conf.Subject)) } - publishInput.SetMessageAttributes(attributes) - - publishOutput, err := client.Publish(publishInput) - if err != nil { - if e, ok := err.(awserr.RequestFailure); ok { - return n.retrier.Check(e.StatusCode(), strings.NewReader(e.Message())) - } else { - return true, err - } - } - - level.Debug(n.logger).Log("msg", "SNS message successfully published", "message_id", publishOutput.MessageId, "sequence number", publishOutput.SequenceNumber) - - return false, nil + return publishInput, nil } func validateAndTruncateMessage(message string, maxMessageSizeInBytes int) (string, bool, error) { @@ -187,3 +202,12 @@ func validateAndTruncateMessage(message string, maxMessageSizeInBytes int) (stri copy(truncated, message) return string(truncated), true, nil } + +func createMessageAttributes(n *Notifier, tmpl func(string) string) map[string]*sns.MessageAttributeValue { + // Convert the given attributes map into the AWS Message Attributes Format + attributes := make(map[string]*sns.MessageAttributeValue, len(n.conf.Attributes)) + for k, v := range n.conf.Attributes { + attributes[tmpl(k)] = &sns.MessageAttributeValue{DataType: aws.String("String"), StringValue: aws.String(tmpl(v))} + } + return attributes +}