gpt4 book ai didi

kubernetes - K8S - 无法通过 - alertmanager 查看警报

转载 作者:行者123 更新时间:2023-12-03 17:41:45 26 4
gpt4 key购买 nike

我有 Prometheus 运算符,它按预期工作 https://github.com/coreos/prometheus-operator

现在我想申请 alert manager从零开始

阅读文档后,我得出了那些 yaml。但问题是当我进入用户界面时什么都没有显示,知道我在这里想念什么吗?

http://localhost:9090/alerts我使用端口转发...

这是我应用于我的 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 中的一些基本警报,我遵循文档但没有找到任何好的分步教程

enter image description here

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com