Last active
July 20, 2023 10:12
-
-
Save cgoldberg/5f6bfe9c5827354bfe7b to your computer and use it in GitHub Desktop.
send metric data to hosted graphite via HTTP POST.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 :)