-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathsend-metrics.sh
executable file
·50 lines (45 loc) · 1.09 KB
/
send-metrics.sh
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
#!/bin/bash
# Metrics Origin details:
# https://github.com/DataDog/dd-source/blob/a060ce7a403c2215c44ebfbcc588e42cd9985aeb/domains/metrics/shared/libs/proto/origin/origin.proto#L144
if [ "$#" -ne 3 ]; then
echo "usage: $0 <image> <size> <branch>"
exit 1
fi
IMAGE=$1
SIZE=$2
BRANCH=$3
set -e
set +x
API_KEY=$(aws ssm get-parameter --region us-east-1 --name ci.datadog-agent.datadog_api_key_org2 --with-decryption --query Parameter.Value --out text)
NOW="$(date '+%s')"
curl -X POST "https://api.datadoghq.com/api/v2/series" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${API_KEY}" \
--silent -S \
-d @- << EOF
{
"series": [
{
"metadata": {
"origin": {
"origin_product": 17,
"origin_sub_product": 0,
"origin_product_detail": 0
}
},
"metric": "datadog.buildimages.size",
"points": [
{
"timestamp": ${NOW},
"value": ${SIZE}
}
],
"tags": [
"image:${IMAGE}",
"branch:${BRANCH}"
]
}
]
}
EOF