Skip to content

Commit 5a6a8f4

Browse files
committed
chore: mimimum datadog test
1 parent ebefcf1 commit 5a6a8f4

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

.github/workflows/test-datadog.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Test Datadog v2 API
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ berno_prom_metrics ]
7+
8+
jobs:
9+
test-datadog:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
15+
- name: Test Datadog v2 API
16+
run: |
17+
echo "🔍 Starting Datadog v2 API test..."
18+
echo "📊 API Key present: $([ -n "${{ secrets.DATADOG_API_KEY }}" ] && echo "YES" || echo "NO")"
19+
echo "🌐 Datadog Site: us5.datadoghq.com"
20+
echo "⏰ Timestamp: $(date)"
21+
echo "📝 Workflow: ${{ github.workflow }}"
22+
echo "🏷️ Repository: ${{ github.repository }}"
23+
echo "🌿 Branch: ${{ github.ref_name }}"
24+
echo "🔗 Commit: ${{ github.sha }}"
25+
echo ""
26+
27+
if [ -n "${{ secrets.DATADOG_API_KEY }}" ]; then
28+
echo "✅ API Key is set, proceeding with test..."
29+
30+
# Get current timestamp
31+
timestamp=$(date +%s)
32+
echo "📅 Using timestamp: $timestamp"
33+
34+
# Prepare the JSON payload
35+
json_payload="{
36+
\"series\": [{
37+
\"metric\": \"test.datadog.integration\",
38+
\"points\": [{\"timestamp\": $timestamp, \"value\": 42}],
39+
\"tags\": [\"service:lace-wallet\", \"env:test\", \"workflow:test-datadog\", \"repo:${{ github.repository }}\", \"branch:${{ github.ref_name }}\", \"commit:${{ github.sha }}\"]
40+
}, {
41+
\"metric\": \"test.datadog.timestamp\",
42+
\"points\": [{\"timestamp\": $timestamp, \"value\": $timestamp}],
43+
\"tags\": [\"service:lace-wallet\", \"env:test\", \"workflow:test-datadog\"]
44+
}]
45+
}"
46+
47+
echo "📤 Sending JSON payload:"
48+
echo "$json_payload"
49+
echo ""
50+
51+
# Send metrics to Datadog v2 API
52+
echo "🚀 Sending request to Datadog v2 API..."
53+
response=$(curl -s -w "\nHTTP_STATUS_CODE:%{http_code}\nTOTAL_TIME:%{time_total}s\n" \
54+
-X POST "https://api.us5.datadoghq.com/api/v2/series" \
55+
-H "Content-Type: application/json" \
56+
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
57+
-d "$json_payload")
58+
59+
echo "📥 Raw response:"
60+
echo "$response"
61+
echo ""
62+
63+
# Extract HTTP status code
64+
http_code=$(echo "$response" | grep "HTTP_STATUS_CODE:" | cut -d: -f2)
65+
total_time=$(echo "$response" | grep "TOTAL_TIME:" | cut -d: -f2)
66+
response_body=$(echo "$response" | sed '/HTTP_STATUS_CODE:/d' | sed '/TOTAL_TIME:/d')
67+
68+
echo "📊 Response Analysis:"
69+
echo " HTTP Status Code: $http_code"
70+
echo " Response Time: ${total_time}s"
71+
echo " Response Body: $response_body"
72+
echo ""
73+
74+
if [ "$http_code" = "202" ]; then
75+
echo "✅ SUCCESS: Metrics sent successfully to Datadog!"
76+
echo " Status: $http_code"
77+
echo " Time: ${total_time}s"
78+
else
79+
echo "❌ ERROR: Failed to send metrics to Datadog"
80+
echo " Status: $http_code"
81+
echo " Error: $response_body"
82+
echo ""
83+
echo "🔍 Troubleshooting tips:"
84+
echo " 1. Check API key permissions in Datadog"
85+
echo " 2. Verify the API key is correct"
86+
echo " 3. Check if the key has 'Metrics Write' permission"
87+
echo " 4. Ensure you're looking at us5.datadoghq.com"
88+
fi
89+
90+
echo ""
91+
echo "🔍 To verify in Datadog UI:"
92+
echo " 1. Go to Metrics Explorer"
93+
echo " 2. Search for: test.datadog.integration"
94+
echo " 3. Set time range to 'Last 1 hour'"
95+
echo " 4. Look for metrics with tags: service:lace-wallet, env:test"
96+
97+
else
98+
echo "❌ ERROR: DATADOG_API_KEY secret is not set"
99+
echo ""
100+
echo "🔧 To fix this:"
101+
echo " 1. Go to repository Settings → Secrets and variables → Actions"
102+
echo " 2. Add a new repository secret named 'DATADOG_API_KEY'"
103+
echo " 3. Set the value to your Datadog API key"
104+
echo " 4. Make sure the key has 'Metrics Write' permission"
105+
fi
106+
107+
echo ""
108+
echo "🏁 Test completed at $(date)"

0 commit comments

Comments
 (0)