diff --git a/prometheus-monitoring/alertmanager-config.yaml b/prometheus-monitoring/alertmanager-config.yaml new file mode 100644 index 0000000..dd3e9d7 --- /dev/null +++ b/prometheus-monitoring/alertmanager-config.yaml @@ -0,0 +1,32 @@ +apiVersion: monitoring.coreos.com/v1alpha1 +kind: AlertmanagerConfig +metadata: + name: config-example + labels: + alertmanagerConfig: example +spec: + route: + groupBy: ['alertname', 'job'] + groupWait: 30s + groupInterval: 1m + repeatInterval: 3h + receiver: 'slack-monitoring' + receivers: + - name: 'slack-monitoring' + slackConfigs: + - channel: '#devops-monitoring' + title: "K8S {{ range .Alerts }}{{ .Annotations.summary }}\n{{ end }}" + text: "K8S {{ range .Alerts }}{{ .Annotations.description }}\n{{ end }}" + sendResolved: true + apiURL: + name: 'slackapisecret' + key: 'url' + +--- +apiVersion: v1 +kind: Secret +type: Opaque +metadata: + name: slackapisecret +stringData: + url: 'https://hooks.slack.com/services/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' diff --git a/prometheus-monitoring/alertmanagerconfig.yaml b/prometheus-monitoring/alertmanagerconfig.yaml new file mode 100644 index 0000000..7113a2a --- /dev/null +++ b/prometheus-monitoring/alertmanagerconfig.yaml @@ -0,0 +1,30 @@ +apiVersion: monitoring.coreos.com/v1alpha1 +kind: AlertmanagerConfig +metadata: + name: config-example + labels: + alertmanagerConfig: example +spec: + route: + groupBy: ['job'] + groupWait: 30s + groupInterval: 5m + repeatInterval: 12h + receiver: 'wechat-example' + receivers: + - name: 'wechat-example' + wechatConfigs: + - apiURL: 'http://wechatserver:8080/' + corpID: 'wechat-corpid' + apiSecret: + name: 'wechat-config' + key: 'apiSecret' + +--- +apiVersion: v1 +kind: Secret +type: Opaque +metadata: + name: wechat-config +data: + apiSecret: d2VjaGF0LXNlY3JldAo= diff --git a/prometheus-monitoring/prometheus-rule.yaml b/prometheus-monitoring/prometheus-rule.yaml index a644846..a13f430 100644 --- a/prometheus-monitoring/prometheus-rule.yaml +++ b/prometheus-monitoring/prometheus-rule.yaml @@ -11,10 +11,10 @@ spec: - name: ./example.rules rules: - alert: RAMUsage - expr: (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) < 0.25 + expr: (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) < 0.95 for: 5m labels: severity: info annotations: - summary: "Server {{ $labels.instance }} has a less than 25% RAM available" - description: "Server {{ $labels.instance }} has only {{ $value }}% of its total amount of RAM available!" + summary: "K8SServerTest {{ $labels.instance }} has a less than 95% RAM available" + description: "K8SServerTest {{ $labels.instance }} has only {{ $value }}% of its total amount of RAM available!"