Skip to content

Instantly share code, notes, and snippets.

@jesusvazquez
Created June 4, 2024 09:14
Show Gist options
  • Save jesusvazquez/fc0573daa293da677f0efe5a92da9840 to your computer and use it in GitHub Desktop.
Save jesusvazquez/fc0573daa293da677f0efe5a92da9840 to your computer and use it in GitHub Desktop.
test write otlp metric with curl
now=$(date +%s)
data="
{
\"resourceMetrics\": [
{
\"resource\": {
\"attributes\": [
{
\"key\": \"service.name\",
\"value\": {
\"stringValue\": \"service_foo\"
}
}
]
},
\"scopeMetrics\": [
{
\"metrics\": [
{
\"name\": \"test_metric\",
\"unit\": \"s\",
\"description\": \"\",
\"gauge\": {
\"dataPoints\": [
{
\"asInt\": 1,
\"timeUnixNano\": ${now}000000000
}
]
}
}
]
}
]
}
]
}
"
curl \
-k \
-i \
-XPOST \
-H 'Content-Type: application/json' \
https://${HOST}/otlp/v1/metrics -d "${data}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment