如何解决在Prometheus仪表板上触发警报
是否可以通过手动停止Kubernetes集群上的相应服务来触发Prometheus仪表板上的某些警报,以验证我是否收到Prometheus仪表板上的问题警报?
解决方法
我建议使用chaos toolkit之类的工具以声明方式自动执行此操作,而不要手动执行。这通常被称为混沌工程。
{
"title": "Do we remain available in face of pod going down?","description": "We expect Kubernetes to handle the situation gracefully when a pod goes down","tags": ["kubernetes"],"steady-state-hypothesis": {
"title": "Verifying service remains healthy","probes": [
{
"name": "all-our-microservices-should-be-healthy","type": "probe","tolerance": true,"provider": {
"type": "python","module": "chaosk8s.probes","func": "microservice_available_and_healthy","arguments": {
"name": "myapp"
}
}
}
]
},"method": [
{
"type": "action","name": "terminate-db-pod","provider": {
"type": "python","module": "chaosk8s.pod.actions","func": "terminate_pods","arguments": {
"label_selector": "app=my-app","name_pattern": "my-app-[0-9]$","rand": true
}
},"pauses": {
"after": 5
}
}
]
}
,
您也可以使用 Gremlin 来实现此目标。首先,使用 helm chart 在您的 Kubernetes 集群上安装 Gremlin 代理:https://github.com/gremlin/helm/
接下来,使用 Gremlin 中的 Kubernetes 功能关闭特定服务。您可以通过选择 1 个 pod/1 个服务或多个 pod/服务来控制爆炸半径。这是我写的关于这个主题的教程:https://www.gremlin.com/community/tutorials/how-to-install-and-use-gremlin-with-kubernetes/。
验证监控和警报是混沌工程的一个很好的用例。正如您所说,通过手动停止 Kubernetes 集群上的相应服务来触发 Prometheus 仪表板上的警报。这将使您能够在 Prometheus 仪表板上验证问题警报。本教程介绍了如何将 Gremlin webhooks 与 Grafana 和 Prometheus 结合使用:https://www.gremlin.com/community/tutorials/visualize-chaos-experiments-in-grafana-with-gremlin-webhooks/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。