Skip to content

Instantly share code, notes, and snippets.

@cgoldberg
Last active July 20, 2023 10:12
Show Gist options
  • Save cgoldberg/5f6bfe9c5827354bfe7b to your computer and use it in GitHub Desktop.
Save cgoldberg/5f6bfe9c5827354bfe7b to your computer and use it in GitHub Desktop.
send metric data to hosted graphite via HTTP POST.
/* send a metric to hosted graphite via HTTP POST (async). */
function sendMetricToGraphite(metricName, value) {
var apiKey = YOUR-API-KEY;
var url = "https://" + apiKey + "@www.hostedgraphite.com/api/v1/sink";
var request = new XMLHttpRequest();
request.open("POST", url, true);
request.send(metricName + " " + value);
};
/* usage: */
sendMetricToGraphite("load_time", 59)
@patoroco
Copy link

Just a note about that, because Chrome is blocking basic auth in URLs. More info: https://medium.com/@lmakarov/say-goodbye-to-urls-with-embedded-credentials-b051f6c7b6a3

I'll continue trying to make it works, thanks for your first clue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment