How can I test the Librato service?¶
A quick way to test the Librato Metrics service is sending a
measurement from the command-line with curl
.
Set your your user id, api token and the location of the Librato Metrics API in your environment: (Your tokens are on the https://metrics.librato.com/tokens page).
LIBRATO_USERID="Librato Metrics userid (email address)"
LIBRATO_API_TOKEN="Librato Metrics API Token, (long alpha numeric string)"
LIBRATO_CREDENTIALS="${LIBRATO_USERID}:${LIBRATO_API_TOKEN}"
LIBRATO_API="https://metrics-api.librato.com"
When submitting measurements there are two ways to submit the POST request to our API:
- As individual arguments
- As parts of a single JSON document
- Submitting measurements as individual arguments:
curl -g \
--include \
-u ${LIBRATO_CREDENTIALS} \
-d 'gauges[0][name]=test_post_metric' \
-d 'gauges[0][value]=1.23' \
-X POST \
${LIBRATO_API}/v1/metrics
- Submitting measurements as a single JSON document
cat << EOF | curl \
--include \
-u ${LIBRATO_CREDENTIALS} \
-H 'Content-Type: application/json' \
-d @- \
${LIBRATO_API}/v1/metrics
{"gauges":[{"value":1.23,"name":"test_post_metric"}]}
EOF
Both curl commands should produce output similar to this:
HTTP/1.1 200 OK
Content-Type: application/json;charset=utf-8
Date: Tue, 13 Nov 2012 14:44:57 GMT
Server: nginx/1.0.14
Status: 200 OK
Content-Length: 0
Connection: keep-alive
Note: If you use measure_time
to send a time stamp with your metric
make sure you use the unix timestamp format in seconds not milliseconds