Store state in share link url
Feature request
As an administrator, I want to enable link sharing without configuring a backing store.
eg, Grafana's Explore page encodes relevant state like:
https://example.com/grafana/explore?orgId=1&left=%7B%22datasource%22:%228M8oDGJVz%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22datasource%22:%7B%22type%22:%22prometheus%22,%22uid%22:%228M8oDGJVz%22%7D,%22editorMode%22:%22builder%22,%22expr%22:%22go_build_info%22,%22legendFormat%22:%22__auto%22,%22range%22:true,%22instant%22:true%7D%5D,%22range%22:%7B%22from%22:%22now-1h%22,%22to%22:%22now%22%7D%7D
Benefit
Users could simply copy/paste the URL from the browser, without using the special share link UI. It would also make Promlens operationally simpler, without requiring additional external resources.
Background
Currently, Promlens requires a storage provider (eg postgres or sqlite) to enable the share link functionality.
Looking at https://github.com/prometheus/promlens/blob/0e62d284ab9b15ef9ba380adb795bda5d8922621/pkg/sharer/sharer.go , this happens by approximately like:
- user clicks "share link" button in client UI
- client sends JSON of page state to server
- server takes JSON string and generates a hash to use as the key and stores the JSON string at key
- server returns key to client
- client shows link in UI e.g.
https://promlens-instance/?l=<key>
If the state were serialized in the link itself, the flow would be simplied:
- user clicks "share link" button in client UI
- client serializes page state (eg, base64 encoded json) and appends to URL as query fragment, eg
https://promlens-instance/#<state> - client shows UI
or further:
- as page state changes, client serializes page state into location hash with History.replaceState
- at any point, user can copy the URL from the browser address bar
The above examples are a sketch, I'm flexible to other implementation approaches.
Is this in line with the direction for this project? I'm happy to help implement and test or discuss further.
at minimum it would be nice if PromLens was able to load state from Prometheus UI compatible url (i don't care so much about generating new shared links, that might initially only get saved to DB as they are right now).
This would allow using PromLens UI instead of Prometheus UI for prometheus compatible tools that don't have Prometheus compatible UI (like Grafana Mimir) with other tools, that would like to generate Prometheus UI compatible links (like pyrra or nobl9 or Grafana if they allow separating Prometheus compatible datasource from Prometheus compatible UI)