TGViewer
Make. Build. Break. Reflect. Make. Build. Break. Reflect. @makebreakreflect · 1.37K subscribers
Post #81 615
2) "как дебажить vmrule?"
Например чтобы отправить собственную метрику для проверки каких-то кондишнов
- коннектимся к vmagent
>k port-forward svc/vmagent-tratata-prod-aks-us-1 8429

- отправляем придуманное событие в vmagent
curl -X POST http://localhost:8429/api/v1/import/prometheus \
-d 'kube_pod_status_phase{phase="Pending",exported_namespace="test-namespace",pod="logical-backup-pgsql-test-pod",cluster="test-prod-cluster"} 1'

- проверяем что этот алёрт ок в виктории метрикс, например нам важно какой северити у него стал/есть (этот кусок прям в Prometheus/VM/Grafana explore вводить)
ALERTS{alertname="KubernetesPodNotHealthy", pod="logical-backup-pgsql-test-pod"}
- не забываем потушить алёрт, иначе он будет висеть вечно
curl -X POST http://localhost:8429/api/v1/import/prometheus \
-d 'kube_pod_status_phase{phase="Pending",exported_namespace="test-namespace",pod="logical-backup-pgsql-test-pod",cluster="test-prod-cluster"} 0'

Удаление нужно в том случае, когда вы не хотите, чтобы это попало в алёртменеджер. Вам же просто протестировать vmrules.
❕vmalert происходит ДО попадания в alertmanager.

3) "как проверить рулесы алертменеджера"
отправить курл запрос типа
curl -X POST https://alertmanager.domain.com/api/v1/alerts \
-H "Content-Type: application/json" \
-d '[
{
"labels": {
"alertname": "KubernetesPodNotHealthy",
"cluster": "test-prod-cluster",
"exported_namespace": "test-namespace",
"pod": "logical-backup-pgsql-test-pod",
"phase": "Pending",
"emoji": "🔥",
"incident_type": "outage"
},
"annotations": {
"summary": "POD'"'"'s state is `Pending` for `test-prod-cluster`/`test-namespace`/`logical-backup-pgsql-test-pod`",
"description": "Pod test-namespace/logical-backup-pgsql-test-pod has been in a non-running state for longer than 15 minutes.\n VALUE = 1\n LABELS = map[cluster:test-prod-cluster exported_namespace:test-namespace phase:Pending pod:logical-backup-pgsql-test-pod]"
},
"startsAt": "'$(date -u +"%Y-%m-%dT%H:%M:%SZ")'",
"endsAt": "'$(date -u -d "+3 minutes" +"%Y-%m-%dT%H:%M:%SZ")'"
}
]'

#alertmanager
  • ✍ 4
More from @makebreakreflect
  1. Sep 25, 2026#пятница Ждём, чо. А вообще да, заебали эти охринительно полезные новости с невероятными д…
  2. Sep 25, 2026#kubernetes - https://laravel-news.com/laravel-health-kubernetes-prometheus Жаль, что тако…
  3. Sep 24, 2026Но стоит взять задачу из смежной области, где общее понимание есть, а глубокой экспертизы…
  4. Sep 23, 2026В удивительнейшее время живём. - https://typesafe.ai/blog/introducing-system-one-models-an…
  5. Sep 22, 2026#aws #elasticache #redis #kubernetes #troubleshooting #devops #sre #longread Ничего не пре…
  6. Sep 18, 2026Вся эта неделя была очень странной. Опус отупел до уровня 3 модели. Фейбл сжигает токены б…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →