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

Docs: Add how to develop locally #137

Merged
merged 3 commits into from
Apr 7, 2022
Merged

Docs: Add how to develop locally #137

merged 3 commits into from
Apr 7, 2022

Conversation

andresmgot
Copy link
Contributor

I have received the same question lately a couple of times. It's not documented anywhere how to develop a plugin locally with Grafana so adding it here. Maybe @grafana/docs-squad can suggest a better place for a guide like this? (rather than having to write this for each plugin).

@andresmgot andresmgot requested a review from a team as a code owner March 29, 2022 11:01
@andresmgot andresmgot requested review from sarahzinger and kevinwcyu and removed request for a team March 29, 2022 11:01
@github-actions
Copy link

Code coverage report for PR #137

Go TypeScript
main 46.2% 88.19%
PR 46.2% 88.19%
difference 0% 0%

CONTRIBUTING.md Outdated
yarn install
```

3. Grafana will look for plugins, by default, on its `data/plugins` directory. You can create a symbolic link to your plugin repository to detect new changes:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth mentioning that it can be done in a conf/custom.ini file too?
Or would you say a symlink is a preferred way?

[paths]
provisioning = /Users/xxx/code/plugin-provisioning/provisioning
 
plugins = /Users/xxx/code/plugins

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both approaches are valid 👍

CONTRIBUTING.md Outdated
yarn start
```

After this, you should be able to see your plugin listed in Grafana and test your changes. Note that any change in the fronted will require you to refresh your browser while changes in the backend may require to rebuild your plugin binaries and restart the Grafana backend.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for backend using mage && mage reloadPlugin ?

Copy link
Contributor

@yaelleC yaelleC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A very nice addition ! 👏

It does seem tedious to add in every plugin repo but I feel it's a good start and definitely worth having that somewhere!

I agree that @grafana/docs-squad might be able to point us towards somewhere else, maybe in grafana's own contributing file ?

https://github.com/grafana/grafana/blob/280b1ee8283fca083422c005f86769edd4cc6913/contribute/developer-guide.md?plain=1#L181

CONTRIBUTING.md Outdated
@@ -46,6 +46,45 @@ Make sure you have the following dependencies installed first:
mage -v
```

## Local development with Grafana
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Local development with local Grafana?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(avoided one "local" because of redundancy)

Copy link
Collaborator

@sunker sunker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Not all contributors have the need to run grafana locally. I wonder if we should also start providing docker-compose files for all our plugins that will allow enable running the plugin without cloning Grafana? I sometimes find this useful myself. Thoughts @andresmgot @yaelleC?

version: '3.7'

services:
  grafana:
    image: grafana/grafana:latest
    ports:
      - '3000:3000'
    volumes:
      - ./:/var/lib/grafana/plugins/redshift-datasource
      - ./provisioning:/etc/grafana/provisioning
    environment:
      - TERM=linux
      - GF_LOG_LEVEL=debug
      - GF_DATAPROXY_LOGGING=true

@yaelleC
Copy link
Contributor

yaelleC commented Mar 29, 2022

Nice!

Not all contributors have the need to run grafana locally. I wonder if we should also start providing docker-compose files for all our plugins that will allow enable running the plugin without cloning Grafana? I sometimes find this useful myself. Thoughts @andresmgot @yaelleC?

version: '3.7'

services:
  grafana:
    image: grafana/grafana:latest
    ports:
      - '3000:3000'
    volumes:
      - ./:/var/lib/grafana/plugins/redshift-datasource
      - ./provisioning:/etc/grafana/provisioning
    environment:
      - TERM=linux
      - GF_LOG_LEVEL=debug
      - GF_DATAPROXY_LOGGING=true

Good call!
I was starting to look into something along these lines too for the e2e tests. Something with GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS too?

That seems very useful to plugin contributors, less hassle 👍

@achatterjee-grafana
Copy link

This information will surely help the community. Thanks for putting this together.

Are these instructions generic and can be used to build any plugin? As far as location goes, I will recommend that we add this content as a topic after this: https://grafana.com/docs/grafana/latest/developers/plugins/. What do you think?

@sunker
Copy link
Collaborator

sunker commented Mar 30, 2022

I was starting to look into something along these lines too for the e2e tests. Something with GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS too?

Yes good catch! Probably good to include a storage volume too. Something like this

version: '3.7'

services:
  grafana:
    image: grafana/grafana:latest
    ports:
      - '3090:3000'
    volumes:
      - ./:/var/lib/grafana/plugins/redshift-datasource
      - grafana-storage:/var/lib/grafana
      - ./[path-to-provisioning]:/etc/grafana/provisioning
    environment:
      - COMPOSE_INTERACTIVE_NO_CLI=1
      - TERM=linux
      - GF_LOG_LEVEL=debug
      - GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=grafana-redshift-datasource
volumes:
  grafana-storage:

@andresmgot
Copy link
Contributor Author

Thanks for the comments! I am going to move now this guide to https://grafana.com/docs/grafana/latest/developers/plugins/.

@andresmgot
Copy link
Contributor Author

Moved the doc to grafana/grafana#47121 :)

Copy link
Contributor

@yaelleC yaelleC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!
No doubt that will be quite useful!

We could wait until the grafana guide is up before merging this PR ;)

@andresmgot
Copy link
Contributor Author

This can be finally merged

@andresmgot andresmgot merged commit ad000ee into main Apr 7, 2022
@andresmgot andresmgot deleted the contributingLocal branch April 7, 2022 15:06
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

Successfully merging this pull request may close these issues.

None yet

4 participants