|
27 | 27 | if [ -n "${{ secrets.DATADOG_API_KEY }}" ]; then
|
28 | 28 | echo "✅ API Key is set, proceeding with test..."
|
29 | 29 |
|
30 |
| - # Prepare the JSON payload (v2 API format) |
| 30 | + # Prepare the JSON payload (v2 API format) - Testing CI metrics |
31 | 31 | json_payload="{
|
32 | 32 | \"series\": [{
|
33 | 33 | \"metric\": \"test.datadog.integration\",
|
|
37 | 37 | \"metric\": \"test.datadog.simple\",
|
38 | 38 | \"points\": [{\"timestamp\": $(date +%s), \"value\": 100}],
|
39 | 39 | \"tags\": [\"service:lace-wallet\", \"env:test\", \"workflow:test-datadog\"]
|
| 40 | + }, { |
| 41 | + \"metric\": \"github.ci.pipeline.duration\", |
| 42 | + \"points\": [{\"timestamp\": $(date +%s), \"value\": 120}], |
| 43 | + \"tags\": [\"service:lace-wallet\", \"env:test\", \"workflow:test-datadog\", \"job:test-datadog\"] |
| 44 | + }, { |
| 45 | + \"metric\": \"github.ci.pipeline.status\", |
| 46 | + \"points\": [{\"timestamp\": $(date +%s), \"value\": 1}], |
| 47 | + \"tags\": [\"service:lace-wallet\", \"env:test\", \"workflow:test-datadog\", \"status:success\"] |
40 | 48 | }]
|
41 | 49 | }"
|
42 | 50 |
|
@@ -86,12 +94,50 @@ jobs:
|
86 | 94 | echo " 4. Ensure you're looking at us5.datadoghq.com"
|
87 | 95 | fi
|
88 | 96 |
|
| 97 | + # Test CI Events functionality |
| 98 | + echo "" |
| 99 | + echo "📝 Testing CI Events..." |
| 100 | + event_payload="{ |
| 101 | + \"title\": \"Test Datadog CI Event: ${{ github.workflow }}\", |
| 102 | + \"text\": \"Test workflow ${{ github.workflow }} completed successfully\\nRepository: ${{ github.repository }}\\nBranch: ${{ github.ref_name }}\\nCommit: ${{ github.sha }}\", |
| 103 | + \"tags\": [\"service:lace-wallet\", \"env:test\", \"workflow:test-datadog\", \"status:success\", \"repo:${{ github.repository }}\"], |
| 104 | + \"alert_type\": \"info\", |
| 105 | + \"source_type_name\": \"github\" |
| 106 | + }" |
| 107 | + |
| 108 | + echo "📤 Sending CI event payload:" |
| 109 | + echo "$event_payload" |
| 110 | + echo "" |
| 111 | + |
| 112 | + event_response=$(curl -s -w "\nHTTP_STATUS_CODE:%{http_code}\nTOTAL_TIME:%{time_total}s\n" \ |
| 113 | + -X POST "https://api.us5.datadoghq.com/api/v1/events" \ |
| 114 | + -H "Content-Type: application/json" \ |
| 115 | + -H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \ |
| 116 | + -d "$event_payload") |
| 117 | + |
| 118 | + event_http_code=$(echo "$event_response" | grep "HTTP_STATUS_CODE:" | cut -d: -f2) |
| 119 | + event_response_body=$(echo "$event_response" | sed '/HTTP_STATUS_CODE:/d' | sed '/TOTAL_TIME:/d') |
| 120 | + |
| 121 | + if [ "$event_http_code" = "202" ]; then |
| 122 | + echo "✅ SUCCESS: CI Event sent successfully to Datadog!" |
| 123 | + else |
| 124 | + echo "❌ ERROR: Failed to send CI Event to Datadog" |
| 125 | + echo " Status: $event_http_code" |
| 126 | + echo " Error: $event_response_body" |
| 127 | + fi |
| 128 | + |
89 | 129 | echo ""
|
90 | 130 | echo "🔍 To verify in Datadog UI:"
|
91 | 131 | echo " 1. Go to Metrics Explorer"
|
92 | 132 | echo " 2. Search for: test.datadog.integration"
|
93 | 133 | echo " 3. Set time range to 'Last 1 hour'"
|
94 | 134 | echo " 4. Look for metrics with tags: service:lace-wallet, env:test"
|
| 135 | + echo "" |
| 136 | + echo "📊 Also check for CI metrics:" |
| 137 | + echo " 5. Search for: github.ci.pipeline.duration" |
| 138 | + echo " 6. Search for: github.ci.pipeline.status" |
| 139 | + echo " 7. Check Events tab for CI events" |
| 140 | + echo " 8. Look for event titled: 'Test Datadog CI Event: test-datadog'" |
95 | 141 |
|
96 | 142 | else
|
97 | 143 | echo "❌ ERROR: DATADOG_API_KEY secret is not set"
|
|
0 commit comments