-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloud-run-logs.sh
More file actions
executable file
·57 lines (49 loc) · 1.52 KB
/
Copy pathcloud-run-logs.sh
File metadata and controls
executable file
·57 lines (49 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# Script to check Cloud Run logs for debugging
echo "📋 Fetching Cloud Run logs..."
echo ""
# Get the latest revision
REVISION=$(gcloud run revisions list \
--service=wecareehr-backend \
--region=africa-south1 \
--format="value(name)" \
--limit=1)
echo "Latest revision: $REVISION"
echo ""
# Get logs from the last 5 minutes
echo "=== Container Logs (last 5 minutes) ==="
gcloud logging read "resource.type=cloud_run_revision
resource.labels.service_name=wecareehr-backend
resource.labels.revision_name=$REVISION
timestamp>\"$(date -u -d '5 minutes ago' '+%Y-%m-%dT%H:%M:%SZ')\"" \
--limit=100 \
--format=json \
--project=team-ehr | jq -r '.[] | .textPayload // .jsonPayload.message // empty'
echo ""
echo "=== Error Logs ==="
gcloud logging read "resource.type=cloud_run_revision
resource.labels.service_name=wecareehr-backend
resource.labels.revision_name=$REVISION
severity>=ERROR
timestamp>\"$(date -u -d '5 minutes ago' '+%Y-%m-%dT%H:%M:%SZ')\"" \
--limit=50 \
--format=json \
--project=team-ehr | jq -r '.[] | .textPayload // .jsonPayload.message // empty'
echo ""
echo "=== Service Status ==="
gcloud run services describe wecareehr-backend \
--region=africa-south1 \
--format="table(
status.conditions.type,
status.conditions.status,
status.conditions.message
)"
echo ""
echo "=== Latest Revision Status ==="
gcloud run revisions describe $REVISION \
--region=africa-south1 \
--format="table(
status.conditions.type,
status.conditions.status,
status.conditions.message
)"