Skip to content

Commit 351633a

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

File tree

2 files changed

+101
-30
lines changed

2 files changed

+101
-30
lines changed

.github/workflows/test-datadog.yml

Lines changed: 91 additions & 30 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,39 +154,94 @@ 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"
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: Create a very distinctive event for easy finding
193+
echo ""
194+
echo "📋 Test 3: Creating distinctive event for UI testing..."
195+
distinctive_event_payload="{
196+
\"title\": \"🎯 BERNO TEST EVENT - LOOK FOR THIS ONE\",
197+
\"text\": \"This is a distinctive test event created at $(date). Look for this exact title in the Events Explorer.\\n\\nRepository: ${{ github.repository }}\\nWorkflow: ${{ github.workflow }}\\nTimestamp: $(date +%s)\",
198+
\"tags\": [\"test:distinctive\", \"user:berno\", \"search:me\", \"service:lace-wallet\"],
199+
\"alert_type\": \"info\",
200+
\"priority\": \"normal\"
201+
}"
202+
203+
distinctive_response=$(curl -s -w "\nHTTP_STATUS_CODE:%{http_code}\nTOTAL_TIME:%{time_total}s\n" \
204+
-X POST "https://api.us5.datadoghq.com/api/v1/events" \
205+
-H "Content-Type: application/json" \
206+
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
207+
-d "$distinctive_event_payload")
208+
209+
distinctive_http_code=$(echo "$distinctive_response" | grep "HTTP_STATUS_CODE:" | cut -d: -f2)
210+
distinctive_response_body=$(echo "$distinctive_response" | sed '/HTTP_STATUS_CODE:/d' | sed '/TOTAL_TIME:/d')
211+
212+
echo " Distinctive Event Status: $distinctive_http_code"
213+
echo " Distinctive Event Response: $distinctive_response_body"
214+
215+
# Extract the event ID for direct URL
216+
if [ "$distinctive_http_code" = "202" ]; then
217+
event_id=$(echo "$distinctive_response_body" | jq -r '.event.id_str' 2>/dev/null)
218+
if [ -n "$event_id" ] && [ "$event_id" != "null" ]; then
219+
echo " 🎯 Direct URL: https://us5.datadoghq.com/event/event?id=$event_id"
220+
echo " 🔍 Search for: 'BERNO TEST EVENT' in Events Explorer"
181221
fi
182222
fi
183223
224+
# Summary
225+
echo ""
226+
echo "📊 API Test Summary:"
227+
echo " Original Event: $event_http_code"
228+
echo " Read Permission: $permissions_http_code"
229+
echo " Minimal Event: $minimal_http_code"
230+
echo " Distinctive Event: $distinctive_http_code"
231+
echo ""
232+
echo "🔍 Troubleshooting Guide:"
233+
echo " - 202: Success (events created successfully)"
234+
echo " - 403: Forbidden (API key lacks permissions)"
235+
echo " - 401: Unauthorized (invalid API key)"
236+
echo " - 400: Bad Request (payload format issue)"
237+
echo ""
238+
echo "🎯 To find events in Datadog UI:"
239+
echo " 1. Go to: https://us5.datadoghq.com/event/explorer"
240+
echo " 2. Search for: 'BERNO TEST EVENT' or 'Test Datadog CI Event'"
241+
echo " 3. Check time range: Last 1 hour"
242+
echo " 4. Clear any filters on the left sidebar"
243+
echo " 5. Try direct URLs from the logs above"
244+
184245
echo ""
185246
echo "🔍 To verify in Datadog UI:"
186247
echo " 1. Go to Metrics Explorer"

docs/datadog-setup.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,16 @@ Use the `test-datadog.yml` workflow to verify your setup:
133133
- Set time range to "Last 1 hour"
134134
- Look for metrics with tags: `service:lace-wallet, env:test`
135135

136+
### Events Testing ✅ **VERIFIED**
137+
138+
Events functionality has been tested and confirmed working:
139+
140+
1. **Run the test workflow** to create test events
141+
2. **Check Events Explorer**: https://us5.datadoghq.com/event/explorer
142+
3. **Search for**: "Test Datadog CI Event" or "Minimal Test"
143+
4. **Direct URLs**: Each event includes a direct link in the logs
144+
5. **Expected Result**: Events appear with full metadata and direct access URLs
145+
136146
### Debugging Tips
137147

138148
- The test workflow provides detailed logging

0 commit comments

Comments
 (0)