From 9c94ce052e54806407d740fa0a2a070697b85ec0 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Fri, 6 Apr 2012 10:43:09 -0700 Subject: [PATCH] Add a script which posts JSON to librato --- bin/post_json_to_librato | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 bin/post_json_to_librato diff --git a/bin/post_json_to_librato b/bin/post_json_to_librato new file mode 100755 index 0000000..c1010a8 --- /dev/null +++ b/bin/post_json_to_librato @@ -0,0 +1,19 @@ +#!/bin/bash + +# Simple bash wrapper around curl to submit a JSON file to Librato +# Usage: ./post_json_to_librato foo.json + +# Advanced Usage: You can write a script which generates Librato JSON in any language and then +# use bash process substitution with this script: +# ./post_json_to_librato <(script_that_prints_json) + +LIBRATO_CREDS="$LIBRATO_USERNAME:$LIBRATO_API_KEY" + +LIBRATO_URL="https://metrics-api.librato.com/v1/metrics" + +JSON_FILE=`mktemp` +cat $1 >> $JSON_FILE + +curl -s -H "Content-Type: application/json" -u $LIBRATO_CREDS -X POST $LIBRATO_URL --data @${JSON_FILE} + +rm ${JSON_FILE}