Search code examples
htmllogginglogstashsplunklogentries

Logging service allowing simple <img/> interface


I'm looking to do some dead-simple logging from a web app (client-side) to some remote service/endpoint. Sure, I could roll my own, but for the purpose of this task, let's assume I want an existing service like Logentries/Splunk/Logstash so that my viewers can still log debugging info if my backend goes down.

Most logging services offer an API where I can import some <script/> onto my page and then use an API like LE.log('string', data); [Logentries example]. However that pulls in a JS dependency and uses cross-domain XHR for probably well-founded reasons (like URI length limitations).

My question is if anyone can point me to a service that will let me send simple query params to a "pixel" endpoint (similar to how Google Analytics does it). Something like:

<script>
new Image().src = 'http://something.io/pixel/log/<API_TOKEN>?some_data=1234';
</script>

-- or, in pure HTML --

<img src="http://something.io/pixel/log/<API_TOKEN>?some_data=1234" style="display:none" />

I'd assume some of the big names in the logging-as-a-service space would have something like this but I've not found anything (or it's too specific to turn up any search results).

This would not be for analytics so much as error logging, debugging, etc. Fire-and-forget sort of stuff.

Any advice appreciated.


Solution

  • It's possible to do this with Logentries, they offer a pixel tracker.

    They require that data is sent in a base64 encoding, but that's quite simple in Javascript.

    From their documentation:

    var encoded = encodeURIComponent(btoa("Log message"));
    

    This data can then be used in a pixel tracker like this:

    <img src="https://js.logentries.com/v1/logs/{API-TOKEN}?e={ENCODED_DATA}/">