Skip to content

Commit 0ed6e57

Browse files
committed
chore: troubleshooting events
1 parent 0c1b5b0 commit 0ed6e57

File tree

1 file changed

+69
-32
lines changed

1 file changed

+69
-32
lines changed

.github/workflows/test-datadog.yml

Lines changed: 69 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ jobs:
9797
# Test CI Events functionality
9898
echo ""
9999
echo "📝 Testing CI Events..."
100+
echo "🔍 Debug Info:"
101+
echo " Datadog Site: us5.datadoghq.com"
102+
echo " Events API: https://api.us5.datadoghq.com/api/v1/events"
103+
echo " API Key: $([ -n "${{ secrets.DATADOG_API_KEY }}" ] && echo "SET" || echo "NOT SET")"
104+
echo ""
105+
100106
event_payload="{
101107
\"title\": \"Test Datadog CI Event: ${{ github.workflow }}\",
102108
\"text\": \"Test workflow ${{ github.workflow }} completed successfully\\nRepository: ${{ github.repository }}\\nBranch: ${{ github.ref_name }}\\nCommit: ${{ github.sha }}\",
@@ -148,38 +154,69 @@ jobs:
148154
echo " 4. Ensure you're using the correct endpoint"
149155
fi
150156
151-
# Try alternative event format if first one failed
152-
if [ "$event_http_code" != "202" ]; then
153-
echo ""
154-
echo "🔄 Trying alternative event format..."
155-
simple_event_payload="{
156-
\"title\": \"Test CI Event\",
157-
\"text\": \"Simple test event from GitHub Actions\",
158-
\"tags\": [\"service:lace-wallet\", \"env:test\"],
159-
\"alert_type\": \"info\"
160-
}"
161-
162-
echo "📤 Sending simple event payload:"
163-
echo "$simple_event_payload"
164-
echo ""
165-
166-
simple_event_response=$(curl -s -w "\nHTTP_STATUS_CODE:%{http_code}\nTOTAL_TIME:%{time_total}s\n" \
167-
-X POST "https://api.us5.datadoghq.com/api/v1/events" \
168-
-H "Content-Type: application/json" \
169-
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
170-
-d "$simple_event_payload")
171-
172-
simple_event_http_code=$(echo "$simple_event_response" | grep "HTTP_STATUS_CODE:" | cut -d: -f2)
173-
simple_event_response_body=$(echo "$simple_event_response" | sed '/HTTP_STATUS_CODE:/d' | sed '/TOTAL_TIME:/d')
174-
175-
if [ "$simple_event_http_code" = "202" ]; then
176-
echo "✅ SUCCESS: Simple CI Event sent successfully to Datadog!"
177-
else
178-
echo "❌ ERROR: Simple CI Event also failed"
179-
echo " Status: $simple_event_http_code"
180-
echo " Error: $simple_event_response_body"
181-
fi
182-
fi
157+
# Test API permissions and try different event formats
158+
echo ""
159+
echo "🔍 Testing API permissions and alternative formats..."
160+
161+
# Test 1: Check if we can read events (permissions test)
162+
echo "📋 Test 1: Checking API permissions..."
163+
permissions_response=$(curl -s -w "\nHTTP_STATUS_CODE:%{http_code}\n" \
164+
-X GET "https://api.us5.datadoghq.com/api/v1/events?start=$(date -d '1 hour ago' +%s)&end=$(date +%s)" \
165+
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
166+
-H "Content-Type: application/json")
167+
168+
permissions_http_code=$(echo "$permissions_response" | grep "HTTP_STATUS_CODE:" | cut -d: -f2)
169+
echo " Events Read Permission: $permissions_http_code"
170+
171+
# Test 2: Try minimal event format
172+
echo ""
173+
echo "📋 Test 2: Minimal event format..."
174+
minimal_event_payload="{
175+
\"title\": \"Minimal Test\",
176+
\"text\": \"Minimal test event\",
177+
\"tags\": [\"test:minimal\"]
178+
}"
179+
180+
minimal_response=$(curl -s -w "\nHTTP_STATUS_CODE:%{http_code}\nTOTAL_TIME:%{time_total}s\n" \
181+
-X POST "https://api.us5.datadoghq.com/api/v1/events" \
182+
-H "Content-Type: application/json" \
183+
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
184+
-d "$minimal_event_payload")
185+
186+
minimal_http_code=$(echo "$minimal_response" | grep "HTTP_STATUS_CODE:" | cut -d: -f2)
187+
minimal_response_body=$(echo "$minimal_response" | sed '/HTTP_STATUS_CODE:/d' | sed '/TOTAL_TIME:/d')
188+
189+
echo " Minimal Event Status: $minimal_http_code"
190+
echo " Minimal Event Response: $minimal_response_body"
191+
192+
# Test 3: Try with different site (if us5 doesn't work)
193+
echo ""
194+
echo "📋 Test 3: Testing with datadoghq.com (not us5)..."
195+
alt_site_response=$(curl -s -w "\nHTTP_STATUS_CODE:%{http_code}\nTOTAL_TIME:%{time_total}s\n" \
196+
-X POST "https://api.datadoghq.com/api/v1/events" \
197+
-H "Content-Type: application/json" \
198+
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
199+
-d "$minimal_event_payload")
200+
201+
alt_site_http_code=$(echo "$alt_site_response" | grep "HTTP_STATUS_CODE:" | cut -d: -f2)
202+
alt_site_response_body=$(echo "$alt_site_response" | sed '/HTTP_STATUS_CODE:/d' | sed '/TOTAL_TIME:/d')
203+
204+
echo " Alt Site Status: $alt_site_http_code"
205+
echo " Alt Site Response: $alt_site_response_body"
206+
207+
# Summary
208+
echo ""
209+
echo "📊 API Test Summary:"
210+
echo " Original Event: $event_http_code"
211+
echo " Read Permission: $permissions_http_code"
212+
echo " Minimal Event: $minimal_http_code"
213+
echo " Alt Site Test: $alt_site_http_code"
214+
echo ""
215+
echo "🔍 Troubleshooting Guide:"
216+
echo " - 202: Success (but events not visible - check permissions)"
217+
echo " - 403: Forbidden (API key lacks permissions)"
218+
echo " - 401: Unauthorized (invalid API key)"
219+
echo " - 400: Bad Request (payload format issue)"
183220
184221
echo ""
185222
echo "🔍 To verify in Datadog UI:"

0 commit comments

Comments
 (0)