Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store state in share link url #86

Open
junosuarez opened this issue Feb 17, 2023 · 1 comment
Open

Store state in share link url #86

junosuarez opened this issue Feb 17, 2023 · 1 comment

Comments

@junosuarez
Copy link

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:

  1. user clicks "share link" button in client UI
  2. client sends JSON of page state to server
  3. server takes JSON string and generates a hash to use as the key and stores the JSON string at key
  4. server returns key to client
  5. 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:

  1. user clicks "share link" button in client UI
  2. client serializes page state (eg, base64 encoded json) and appends to URL as query fragment, eg https://promlens-instance/#<state>
  3. client shows UI

or further:

  1. as page state changes, client serializes page state into location hash with History.replaceState
  2. 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.

@atsu85
Copy link

atsu85 commented Sep 6, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants