feat(observability): push nxtgauge endpoint health checks to openobserve

This commit is contained in:
Ashwin Kumar Sivakumar 2026-04-13 22:42:59 +05:30
parent ceebc13e79
commit ace5873261
3 changed files with 64 additions and 0 deletions

View file

@ -44,4 +44,6 @@ resources:
- ugc-content-creators-deployment.yaml
- ugc-content-creators-service.yaml
- cron-deployment.yaml
- openobserve-endpoint-monitor-secret.yaml
- openobserve-endpoint-monitor-cronjob.yaml
- k8s-migration-job.yaml

View file

@ -0,0 +1,51 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: nxtgauge-openobserve-endpoint-monitor
namespace: nxtgauge
spec:
schedule: "*/1 * * * *"
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 3
jobTemplate:
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: endpoint-monitor
image: curlimages/curl:8.10.1
imagePullPolicy: IfNotPresent
envFrom:
- secretRef:
name: nxtgauge-openobserve-endpoint-monitor-secret
command: ["/bin/sh", "-ec"]
args:
- |
post_result() {
name="$1"
url="$2"
checked_at="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
out="$(curl -sS -o /dev/null -w '%{http_code} %{time_total}' --max-time 15 "$url" || true)"
code="$(printf '%s' "$out" | awk '{print $1}')"
total="$(printf '%s' "$out" | awk '{print $2}')"
[ -n "$code" ] || code="0"
[ -n "$total" ] || total="0"
latency_ms="$(awk "BEGIN { printf \"%.0f\", $total * 1000 }")"
if [ "$code" -ge 200 ] && [ "$code" -lt 400 ]; then
ok="true"
else
ok="false"
fi
payload="$(printf '[{"endpoint":"%s","url":"%s","status_code":%s,"ok":%s,"latency_ms":%s,"checked_at":"%s"}]' "$name" "$url" "$code" "$ok" "$latency_ms" "$checked_at")"
curl -sS -X POST \
"${OO_ENDPOINT}/api/${OO_ORG}/${OO_STREAM}/_json" \
-H "Authorization: ${OO_AUTH_HEADER}" \
-H "Content-Type: application/json" \
-d "$payload" >/dev/null
}
post_result "frontend" "https://test121.nxtgauge.com/"
post_result "admin" "https://admin.nxtgauge.com/"
post_result "api-health" "https://api.nxtgauge.com/health"

View file

@ -0,0 +1,11 @@
apiVersion: v1
kind: Secret
metadata:
name: nxtgauge-openobserve-endpoint-monitor-secret
namespace: nxtgauge
type: Opaque
stringData:
OO_ENDPOINT: "http://o2-openobserve-standalone.openobserve.svc.cluster.local:5080"
OO_ORG: "default"
OO_STREAM: "nxtgauge_endpoints"
OO_AUTH_HEADER: "Basic cm9vdEBleGFtcGxlLmNvbTpDb21wbGV4cGFzcyMxMjM="