我有Prometheus运算符,它的按预期的方式工作
https://github.com/coreos/prometheus-operator
现在我想从头开始应用alert manager
阅读文档后,即时通讯就出现了这些Yaml。
但是问题是当我进入用户界面时
什么都没显示,我在这里想念什么吗?
http://localhost:9090/alerts
我使用端口转发...
这是all
我已应用于我的k8s集群的配置文件
我只想做一些简单的测试,看看它是否有效,然后将其扩展到我们的需求...alertmanger_main.yml
---
apiVersion: monitoring.coreos.com/v1
kind: Alertmanager
metadata:
name: main
labels:
alertmanager: main
spec:
replicas: 3
version: v0.14.0
alertmanger_service.yml
apiVersion: v1
kind: Service
metadata:
name: alertmanager-main
spec:
type: LoadBalancer
ports:
- name: web
port: 9093
protocol: TCP
targetPort: web
selector:
alertmanager: main
testalert.yml
kind: ConfigMap
apiVersion: v1
metadata:
name: prometheus-example-rules
labels:
role: prometheus-rulefiles
prometheus: prometheus
data:
example.rules.yaml: |+
groups:
- name: ./example.rules
rules:
- alert: ExampleAlert
expr: vector(1)
alertmanager.yml
global:
resolve_timeout: 5m
route:
group_by: ['job']
group_wait: 30s
group_interval: 5m
repeat_interval: 12h
receiver: 'webhook'
receivers:
- name: 'webhook'
webhook_configs:
- url: 'http://alertmanagerwh:30500/'
并创建我使用的 secret
kubectl create secret generic alertmanager-main --from-file=alertmanager.yaml
我需要的是K8S中的一些基本警报,我遵循了文档说明但没有找到任何循序渐进的好教程
to check my sys for monitoring namespace
~ kubectl get pods -n monitoring 13.4m Sun Feb 17 18:48:16 2019
NAME READY STATUS RESTARTS AGE
kube-state-metrics-593czc6b4-mrtkb 2/2 Running 0 12h
monitoring-grafana-771155cbbb-scqvx 1/1 Running 0 12h
prometheus-operator-79f345dc67-nw5zc 1/1 Running 0 12h
prometheus-prometheus-0 3/3 Running 1 12h
~ kubectl get svc -n monitoring 536ms Sun Feb 17 21:04:51 2019
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
alertmanager-main NodePort 100.22.170.666 <none> 9093:30904/TCP 4m53s
kube-state-metrics ClusterIP 100.34.212.596 <none> 8080/TCP 4d7h
monitoring-grafana ClusterIP 100.67.230.884 <none> 80/TCP 4d7h
prometheus-operated ClusterIP None <none> 9090/TCP 4d7h
我现在也将服务更改为LoadBalancer,我尝试输入
~ kubectl get svc -n monitoring 507ms Sun Feb 17 21:23:56 2019
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
alertmanager-main LoadBalancer 100.22.170.666 38.482.152.331 9093:30904/TCP 23m
当我点击浏览器
38.482.152.331:9093
38.482.152.331:30904
什么都没发生...
最佳答案
当您考虑使用AlertManager时,除了常规配置和应用警报规则外,AlertManager
还需要与Prometheus服务器集成。然后,Prometheus实例可以跟踪任何传入的一系列事件,并且一旦检测到任何可识别的规则,就会向嵌套的alertmanager触发警报。
为了启用警报,可能有必要在Prometheus实例上附加以下配置:
alerting:
alertmanagers:
- static_configs:
- targets:
- 'alertmanagerIP:9093'
具体来说,对于CoreOS中的
AlertManager
实现,您可以按照Alerting官方文档中描述的步骤进行操作;但是,下面您可以从上述指南中找到有关Prometheus Pod警报配置的示例:apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
name: example
spec:
replicas: 2
alerting:
alertmanagers:
- namespace: default
name: alertmanager-example
port: web
serviceMonitorSelector:
matchLabels:
team: frontend
resources:
requests:
memory: 400Mi
ruleSelector:
matchLabels:
role: prometheus-rulefiles
prometheus: example
关于kubernetes - K8S-无法通过以下方式查看警报-alertmanager,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54731179/