pollypkg / polly

Parameterized Observability Packages
https://pollypkg.github.io/polly/
Apache License 2.0
84 stars 8 forks source link

Interactive Editing #36

Open sh0rez opened 3 years ago

sh0rez commented 3 years ago

Rather large PR implementing a (very basic) interactive editing flow.

Usage:

# run Grafana locally
$ docker run -p 3000:3000 grafana/grafana
$ export GRAFANA_URL=http://localhost:3000
$ export GRAFANA_TOKEN=<token>

# start the react ui (currently standalone)
$ cd pkg/edit/ui && yarn install && yarn start

# interactively edit the 'cert-manager' pop:
$ go run ./cmd/pop edit ./examples/cert-manager

Then visit http://localhost:3001 and edit the one dashboard. Changes made in Grafana will be reflected on disk.

Warning: Because the schema currently in main seems to lack the stat panel (ping @sdboyer), above actually leads to a CUE error. So either fix that schema, or revert to the previous one: git revert 9ab7ea1360a379c65df6199539f97ba3ca92bce1

Packages

Internals

Grafana pushes notifications over a special WebSocket API using centrifuge, when dashboards are saved. edit.Grafana uses a grafana.Watcher to be notified by that, queries the current dashboard model using the deprecated (but only) API client and saves it to disk.

edit.Server and edit.DashboardService implement a gRPC (and gRPC-web) server for interacting with this exact edit.Grafana, allowing easy control of the edit session.

Both the frontend and the backend use strongly typed gRPC messages, which fits nicely with the overall schema awareness of Polly

sdboyer commented 3 years ago

Because the schema currently in main seems to lack the stat panel (ping @sdboyer)

Quick note that i am actively working on a fix for this in grafana/grafana#38727 which will unblock a pile of things, this included. Right now it's looking rosy that i deal with a bunch of the fugly awkwardness around using scuemata from CUE, in fact