-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.vtl
More file actions
27 lines (27 loc) · 1.03 KB
/
template.vtl
File metadata and controls
27 lines (27 loc) · 1.03 KB
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
#set($inputRoot = $util.parseJson($input.json('$.resourceMetrics')))
{
"gauge": [
#foreach($resourceMetric in $inputRoot)
#foreach($scopeMetric in $resourceMetric.scopeMetrics)
#foreach($metric in $scopeMetric.metrics)
#if($metric.gauge && $metric.gauge.dataPoints && $metric.gauge.dataPoints.size() > 0)
#set($dataPoint = $metric.gauge.dataPoints[0])
#set($timestampMilli = $dataPoint.timeUnixNano.substring(0, 13)) ## Convert nanoseconds to milliseconds
{
"metric": "$metric.name",
"value": $dataPoint.asDouble,
"dimensions": {
#foreach($attribute in $resourceMetric.resource.attributes)
#if($attribute.key.substring(0,10) != "telemetry." && $attribute.key != "service.name")
"$attribute.key": "$attribute.value.stringValue"#if(!$foreach.last),#end
#end
#end
},
"timestamp": $timestampMilli
}#if($foreach.hasNext),#end
#end
#end
#end
#end
]
}