3 ms·
I’d love to hear more about your setup. I want to do that…
by _boffin_ 4y ago
I’d love to hear more about your setup. I want to do that…
- zamubafoo 4y agoLoki and Grafana running locally on a server (raspberry pi 3B+), your preferred userscript extension plus a script that POSTs to Loki's API [1]. The post function: function post_to_loki () { const data = {"streams":[ { "stream": { "job":"browser", "user_agent":Navigator.userAgent, "nodename":"desktop", }, "values":[ [Date.now()*1000000, {"location":window.location, "referrer":document.referrer}] ] }]}; let control = GM_xmlhttpRequest({ "url": "https://loki.example.lan/loki/api/v1/push", "method": "POST", "headers": {"Content-Type": "application/json"}, "data": JSON.stringify(data) }); } Now whatever actually triggers the POST function is up to you (I ended up using [2]). In Grafana, I have a few dashboards specific to the facets I want to see. I have one for Dev stuff which tracks the latest 100 urls, the frequency count of websites, and a State Timeline of all the events. This filters specifically stackoverflow, MDN, any url contains "docs", github, and a few internal urls. In an other dashboard I have a view of all the places I read online with similar panels to Dev, but with different filters. Then I have a final dashboard which works solely on Google search queries, but instead of grabbing the search page's URL, I grab the search term from the page I actually clicked on which makes searches much more interesting. --- [1] https://grafana.com/docs/loki/latest/api/#post-lokiapiv1push https://grafana.com/docs/loki/latest/api/#post-lokiapiv1push [2] https://stackoverflow.com/a/18997637 https://stackoverflow.com/a/18997637