* Docs: Plugins doc reorganization, part 1 (#69864)
* Initial commit
* Prettier fixes
* Doc-validator fixes part 1
* Doc-validator fixes part 2
* More doc-validator fixes
* More doc-validator fixes
* Test
* link test
* Linnk test
* Link test
* More fixes
* More fixes
* Doc-validator fixes
* Doc-validator fixes
* fix broken link
* Fix
* Testing
* Doc fixes
* Link fixes
* Fix links
* Update docs/sources/developers/plugins/create-a-grafana-plugin/_index.md
Co-authored-by: David Harris <david.harris@grafana.com>
* Testing
* Testing
* Testing
* Testing
* Doc-validator fixes
* Doc-validator fixes
* Doc-validator fixes
* Fix broken links for plugins reorganization project
* Prettier fixes
* Prettier fixes
* Incorporate reviewer feedback
* Link fixes
* Link fixes
* Link fixes
* Link fix
* Deleted space
* Codeowners fix
* Change grafana.com links to absolute URLs for Hugo
---------
Co-authored-by: David Harris <david.harris@grafana.com>
(cherry picked from commit f9df1f3051)
* Prettier fix
30 lines
2.2 KiB
Markdown
30 lines
2.2 KiB
Markdown
---
|
|
title: Plugin Anatomy
|
|
---
|
|
|
|
Plugins come in different shapes and sizes. Before we dive deeper, let's look at some of the properties that are shared by all of them.
|
|
|
|
Every plugin you create will require at least two files: `plugin.json` and `src/module.ts`.
|
|
|
|
### plugin.json
|
|
|
|
When Grafana starts, it scans the plugin directory for any subdirectory that contains a `plugin.json` file. The `plugin.json` file contains information about your plugin, and tells Grafana about what capabilities and dependencies your plugin needs.
|
|
|
|
While certain plugin types can have specific configuration options, let's look at the mandatory ones:
|
|
|
|
- `type` tells Grafana what type of plugin to expect. Grafana supports three types of plugins: `panel`, `datasource`, and `app`.
|
|
- `name` is what users will see in the list of plugins. If you're creating a data source, this is typically the name of the database it connects to, such as Prometheus, PostgreSQL, or Stackdriver.
|
|
- `id` uniquely identifies your plugin, and should start with your Grafana username, to avoid clashing with other plugins. [Sign up for a Grafana account](https://grafana.com/signup/) to claim your username.
|
|
|
|
To see all the available configuration settings for the `plugin.json`, refer to the [plugin.json Schema](/docs/grafana/latest/plugins/developing/plugin.json/).
|
|
|
|
### module.ts
|
|
|
|
After discovering your plugin, Grafana loads the `module.ts` file, the entrypoint for your plugin. `module.ts` exposes the implementation of your plugin, which depends on the type of plugin you're building.
|
|
|
|
Specifically, `module.ts` needs to expose an object that extends [GrafanaPlugin](https://github.com/grafana/grafana/blob/08bf2a54523526a7f59f7c6a8dafaace79ab87db/packages/grafana-data/src/types/plugin.ts#L124), and can be any of the following:
|
|
|
|
- [PanelPlugin](https://github.com/grafana/grafana/blob/08bf2a54523526a7f59f7c6a8dafaace79ab87db/packages/grafana-data/src/types/panel.ts#L73)
|
|
- [DataSourcePlugin](https://github.com/grafana/grafana/blob/08bf2a54523526a7f59f7c6a8dafaace79ab87db/packages/grafana-data/src/types/datasource.ts#L33)
|
|
- [AppPlugin](https://github.com/grafana/grafana/blob/45b7de1910819ad0faa7a8aeac2481e675870ad9/packages/grafana-data/src/types/app.ts#L27)
|