Compare commits

..

149 Commits

Author SHA1 Message Date
Grot (@grafanabot)
29e75ad97b Make Datetime local (No date if today) working (#31274) (#31275)
(cherry picked from commit 0253685304)

Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
2021-02-17 12:39:25 +01:00
Grot (@grafanabot)
0cc1a4369a "Release: Updated versions in package to 7.4.2" (#31272) 2021-02-17 12:38:23 +01:00
Jack Westbrook
ef677f34b1 [v7.4.x] Chore: grafana-toolkit uses grafana-ui and grafana-data workspaces (#31269)
* Chore: grafana-toolkit uses grafana-ui and grafana-data workspaces (#30701)

* chore(grafana-toolkit): use workspace versions of grafana/ui and grafana/data

* chore: replace references to popperjs 1 typings with popperjs 2 typings

(cherry picked from commit 4b25310941)

* revert(grafana-toolkit): put back 7.4 version of eslint-config (2.1.0)
2021-02-17 11:05:27 +01:00
Grot (@grafanabot)
064546f382 Snapshots: Disallow anonymous user to create snapshots (#31263) (#31266)
(cherry picked from commit 8f20b13f1c)

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2021-02-17 10:12:44 +01:00
Grot (@grafanabot)
b85da0cc0a only update usagestats every 30min (#31131) (#31262)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
(cherry picked from commit b5cbbc3db1)

Co-authored-by: Carl Bergquist <carl.bergquist@gmail.com>
2021-02-17 09:33:25 +01:00
Grot (@grafanabot)
8b4c370752 Prometheus: Fix enabling of disabled queries when editing in dashboard (#31055) (#31248)
* Fix disable bug by passing hide prop

* Make more universal fix

* Revert to original fix

* Update public/app/plugins/datasource/prometheus/components/PromQueryEditor.tsx

Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>

Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
(cherry picked from commit 4f61edd28d)

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
2021-02-16 16:55:02 +01:00
Grot (@grafanabot)
44008445b8 CloudWatch: Ensure empty query row errors are not passed to the panel (#31172) (#31245)
* ensure empty errors are not passed to the panel

* make it a oneliner

(cherry picked from commit 92ae019f8e)

Co-authored-by: Erik Sundell <erik.sundell@grafana.com>
2021-02-16 16:23:17 +01:00
Grot (@grafanabot)
65d8420007 StatPanels: Fixes to palette color scheme is not cleared when loading panel (#31126) (#31246)
(cherry picked from commit b3c32277dd)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-02-16 16:09:07 +01:00
Grot (@grafanabot)
0e60372c09 QueryEditors: Fixes issue that happens after moving queries then editing would update other queries (#31193) (#31244)
(cherry picked from commit 0c3c17592e)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-02-16 16:05:02 +01:00
Grot (@grafanabot)
dafb37e819 LibraryPanels: Disconnect before connect during dashboard save (#31235) (#31238)
* LibraryPanels: Disconnect before connect during dashboard save

* Tests: fixed test

* Chore: updates after PR comments

* Chore: changes from context.Background() to c.Context.Req.Context()

* Chore: fixes lint issue

(cherry picked from commit 06e6bcf091)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-02-16 13:27:19 +01:00
Grot (@grafanabot)
170b0f329c SqlDataSources: Fixes the Show Generated SQL button in query editors (#31236) (#31239)
* SqlDataSources: Fixes the Show Generated SQL button in query editors

* No need to protect against duplicate events now that the event emitter is isolated for each editor

(cherry picked from commit e4672906f0)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-02-16 13:12:06 +01:00
Grot (@grafanabot)
1c4712aeeb Variables: Adds back default option for data source variable (#31208) (#31232)
* Variables: Adds back default option for data source variable

* Chore: updates after PR comments

(cherry picked from commit f993f2c7cc)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-02-16 07:51:01 +01:00
Grot (@grafanabot)
c4774ec6ae IPv6: Support host address configured with enclosing square brackets (#31226) (#31228)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
(cherry picked from commit d27a72f859)

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
2021-02-15 18:21:47 +01:00
Grot (@grafanabot)
dda38c55e5 Postgres: Fix timeGroup macro converts long intervals to invalid numbers when TimescaleDB is enabled (#31179) (#31224)
Fixes #27253

(cherry picked from commit d56c5285e2)

Co-authored-by: Ricky Putra <kurokochin@users.noreply.github.com>
2021-02-15 17:51:39 +01:00
Grot (@grafanabot)
d087a69e2e Remove last synchronisation field from LDAP debug view (#30984) (#31221)
* Remove last synchronisation field from LDAP debug view

* Apply review comments

(cherry picked from commit f9a293afea)

Co-authored-by: Tania B <yalyna.ts@gmail.com>
2021-02-15 17:58:18 +02:00
Torkel Ödegaard
1adce1fcfc [v7.4.x]: Sync drone config from master to stable release branch (#31213) 2021-02-15 12:26:43 +01:00
Grot (@grafanabot)
dbad6a9182 DataSourceSrv: Filter out non queryable data sources by default (#31144) (#31214)
(cherry picked from commit 50faeb3078)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-02-15 12:06:27 +01:00
Grot (@grafanabot)
3efcb19cb2 Alerting: Fix modal text for deleting obsolete notifier (#31171) (#31209)
(cherry picked from commit dde11215e9)

Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>
2021-02-15 11:01:51 +02:00
Grot (@grafanabot)
6e68a7ac59 Variables: Fixes missing empty elements from regex filters (#31156) (#31201)
* Variables: Fixes missing empty elements from regex filters

* Chore: cleanup comment

* Chore: removes unused import

(cherry picked from commit 39993a6884)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-02-15 06:24:57 +01:00
Grot (@grafanabot)
b0f6cf8669 DashboardLinks: Fixes links always cause full page reload (#31178) (#31181)
(cherry picked from commit 9629dded42)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-02-12 18:14:45 +01:00
Grot (@grafanabot)
e42d6931c4 DashboardListPanel: Fixes issue with folder picker always showing All and using old form styles (#31160) (#31162)
(cherry picked from commit a17661d198)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-02-12 16:36:35 +01:00
Grot (@grafanabot)
c8a7044504 Permissions: Fix team and role permissions on folders/dashboards not displayed for non Grafana Admin users (#31132) (#31176)
* Cfg: fix hidden users initialization

* add tests

* do not call isHiddenUser function for non-user permission

* do not call isHiddenUser function for non-user permission

(cherry picked from commit 7f1f559929)

Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>
2021-02-12 16:32:35 +01:00
Grot (@grafanabot)
5f20a59b85 Prometheus: Multiply exemplars timestamp to follow api change (#31143) (#31170)
(cherry picked from commit 8c35ed4014)

Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
2021-02-12 15:16:18 +01:00
Grot (@grafanabot)
07649d1313 "Release: Updated versions in package to 7.4.1" (#31128) 2021-02-11 12:08:13 +00:00
Grot (@grafanabot)
994326759e Transforms: Fixes Outer join issue with duplicate field names not getting the same unique field names as before (#31121) (#31127)
* Transformations: Fixed duplicate name issue in outer join transform

* Think this is working

* Updated tests

* Updated snapshot

* Fix broken tests (#31123)

* Fix broken tests

* Fix remaining faling tests

Co-authored-by: Giordano Ricci <gio.ricci@grafana.com>
(cherry picked from commit 699724581d)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-02-11 11:58:55 +00:00
Grot (@grafanabot)
2c3eb7ddae MuxWriter: Handle error for already closed file (#31119) (#31120)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
(cherry picked from commit 7394c98d38)

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
2021-02-11 11:06:32 +01:00
Grot (@grafanabot)
b9d92efdff Logging: sourcemap transform asset urls from CDN in logged stacktraces (#31115) (#31117)
(cherry picked from commit 5c9a10d423)

Co-authored-by: Domas <domasx2@gmail.com>
2021-02-11 11:20:11 +02:00
Grot (@grafanabot)
ba9ab09ad6 Exemplars: Change CTA style (#30880) (#31105)
* Exemplars: Change CTA style

* Address review feedbacks

* Fix table column aligning

* Minor alignments + uncontrolled component warning fix

(cherry picked from commit cc463f30a4)

Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
2021-02-10 18:46:58 +01:00
Grot (@grafanabot)
14a89707e6 test: add support for timeout to be passed in for addDatasource (#30736) (#31090)
* add support for timeout to be passed in for addDatasource

* fix merge update

(cherry picked from commit 25bcbb7d8e)

Co-authored-by: Vicky Lee <36230812+vickyyyyyyy@users.noreply.github.com>
2021-02-10 15:51:21 +00:00
Andrej Ocenas
fada9fcbff Influx: Make max series limit configurable and show the limiting message if applied (#31025) (#31100)
* Add configuration in ConfigEditor and default to 1000

* Show data in explore if any even if there is an error

* Update pkg/tsdb/influxdb/flux/executor.go

* Better handling of defaults

* Add test for runQuery to show data even with error

* Update public/app/store/configureStore.ts

Co-authored-by: Giordano Ricci <gio.ricci@grafana.com>

* Update public/app/plugins/datasource/influxdb/components/ConfigEditor.tsx

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>

* Update tooltip

* Update input

* Lint fixes

* Update snapshots

* Update decorator tests

Co-authored-by: Giordano Ricci <gio.ricci@grafana.com>
Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
(cherry picked from commit e0448513eb)
2021-02-10 16:01:21 +01:00
Grot (@grafanabot)
762c694092 Elasticsearch: fix log row context erroring out (#31088) (#31094)
(cherry picked from commit c7e007d199)

Co-authored-by: Giordano Ricci <gio.ricci@grafana.com>
2021-02-10 13:57:00 +00:00
Grot (@grafanabot)
02cd1faf88 test: update addDashboard flow for v7.4.0 changes (#31059) (#31084)
* update addDashboard flow for v7.4.0 changes

* remove hide flow and if around set time range

(cherry picked from commit cff6f5fec3)

Co-authored-by: Vicky Lee <36230812+vickyyyyyyy@users.noreply.github.com>
2021-02-10 12:11:07 +01:00
Grot (@grafanabot)
368bd2d7bb Usage stats: Adds source/distributor setting (#31039) (#31076)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
(cherry picked from commit d1b9fddb4f)

Co-authored-by: Carl Bergquist <carl.bergquist@gmail.com>
2021-02-10 11:08:14 +01:00
Grot (@grafanabot)
97f8bc7250 DashboardLinks: Fixes crash when link has no title (#31008) (#31050)
* DashboardLinks: Fixes crash when link misses title

* Chore: updates after PR comments

(cherry picked from commit 297ff9a168)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-02-10 06:08:11 +01:00
Grot (@grafanabot)
73f933b691 Make value mappings correctly interpret numeric-like strings (#30893) (#30912)
* Make value mappings corectly interprete numeric-like strings

* More tests

* Update packages/grafana-data/src/utils/valueMappings.ts

* Update packages/grafana-data/src/utils/valueMappings.ts

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>

* Fix issue detected by singlestat test

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
(cherry picked from commit f47b72304c)

Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
2021-02-09 18:03:44 +01:00
Grot (@grafanabot)
7924e6fec6 Elasticsearch: Fix alias field value not being shown in query editor (#30992) (#31037)
* Make imports relative

* Fix Alias field value not being shown

(cherry picked from commit b46235715d)

Co-authored-by: Giordano Ricci <gio.ricci@grafana.com>
2021-02-09 17:56:04 +01:00
Grot (@grafanabot)
cefbec44fb BarGauge: Improvements to value sizing and table inner width calculations (#30990) (#31032)
* BarGauge: Increase min value width and fix height when setting manual text size

* updated snapshot

* Big improvement to bar gauge value sizing and fixing table gauge sizing

* removed unused const

* added a unit test

(cherry picked from commit 39d7ebc7d1)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-02-09 17:51:50 +01:00
Grot (@grafanabot)
a200db0d05 convert path to posix by default (#31045) (#31053)
(cherry picked from commit da3f963987)

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
2021-02-09 16:28:02 +01:00
Grot (@grafanabot)
989f6933cd Alerting: Fixes so notification channels are properly deleted (#31040) (#31046)
(cherry picked from commit f43d834a59)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-02-09 15:50:13 +01:00
Arve Knudsen
4d74e49285 Drone: Fix deployment image (#31027) (#31029)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
(cherry picked from commit d963c6d868)
2021-02-09 14:05:10 +01:00
Grot (@grafanabot)
b98b3cf260 Graph: Fixes so graph is shown for non numeric time values (#30972) (#31014)
* Graph: Fixes so graph is shown for non numeric time values

* Tests: changes times to UTC

* Tests: forgot one value in time array

* GraphNG: make time series panel work with string time stamps (#30981)

* Make Time series panel work with data that time is represented as string

* Map to for

Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
(cherry picked from commit bd28512d29)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-02-09 10:05:11 +01:00
Grot (@grafanabot)
9a4fe5d17f instrumentation: make the first database histogram bucket smaller (#30995) (#31001)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
(cherry picked from commit 49e394e167)

Co-authored-by: Carl Bergquist <carl.bergquist@gmail.com>
2021-02-09 09:54:13 +01:00
Grot (@grafanabot)
840b55926b Build: Releases e2e and e2e-selectors too (#31006) (#31007)
(cherry picked from commit 410ab72bc4)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-02-09 07:53:13 +01:00
Grot (@grafanabot)
7e7f90ed6c TextPanel: Fixes so panel title is updated when variables change (#30884) (#31005)
* TextPanel: Fixes so panel title is updated when variables change

* Tests: fixes tests

* Chore: updates after PR comments

(cherry picked from commit f42bb84cbf)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-02-09 06:23:22 +01:00
Grot (@grafanabot)
68597e8cfb StatPanel: Fixes issue formatting date values using unit option (#30979) (#30991)
(cherry picked from commit 907d3a2aac)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-02-08 17:24:47 +01:00
Grot (@grafanabot)
a4f8c56a0a Units: Fixes formatting of duration units (#30982) (#30986)
(cherry picked from commit 3a6af0a639)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-02-08 13:23:33 +01:00
Grot (@grafanabot)
e7ea30c8fd Elasticsearch: Show Size setting for raw_data metric (#30980) (#30983)
(cherry picked from commit 0a7c6c689f)

Co-authored-by: Giordano Ricci <gio.ricci@grafana.com>
2021-02-08 11:13:12 +00:00
Grot (@grafanabot)
b4181a077f Logging: sourcemap support for frontend stacktraces (#30590) (#30976)
(cherry picked from commit 21817055bd)

Co-authored-by: Domas <domasx2@gmail.com>
2021-02-08 12:09:34 +02:00
Grot (@grafanabot)
bc1f03403b e2e: extends selector factory to plugins (#30932) (#30934)
(cherry picked from commit 32dde95a7b)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-02-05 14:23:48 +01:00
Grot (@grafanabot)
8b79f0d7c5 Variables: Adds queryparam formatting option (#30858) (#30924)
* Variables: Adds queryparam formatting option

* Chore: fixes strict errors

* Chore: changes after PR comments

(cherry picked from commit 2a3aa95163)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-02-05 08:04:45 +01:00
Grot (@grafanabot)
8c52f69395 Exemplars: change api to reflect latest changes (#30910) (#30915)
(cherry picked from commit 48334ab863)

Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
2021-02-04 20:21:26 +01:00
Grot (@grafanabot)
c2203b9859 "Release: Updated versions in package to 7.4.0" (#30898) 2021-02-04 11:11:00 +00:00
Grot (@grafanabot)
089d84cf5c DataSourceSettings: Adds info box and link to Grafana Cloud (#30891) (#30896)
* Updated

* DataSourceSettings: Adds info box and link to Grafana Cloud

* Updated wording

* Less words

* use variables

* Fixing ts issues

* fixed import

(cherry picked from commit 56ef7c4a4c)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-02-04 11:58:02 +01:00
Grot (@grafanabot)
0c3bee2530 GrafanaUI: Add a way to persistently close InfoBox (#30716) (#30895)
* GrafanaUI: Add a way to persistently close InfoBox

InfoBox and FeatureInfoBox can take up a lot of screen realestate. This makes it easy to let the user close the boxes.

* Migrate InfoBox story to controls

(cherry picked from commit 99acad4448)

Co-authored-by: Oscar Kilhed <oscar.kilhed@grafana.com>
2021-02-04 11:31:31 +01:00
Peter Holmberg
403b7c6177 [7.4.x] AlertingNG: List saved Alert definitions in Alert Rule list (30890)(30603) 2021-02-04 10:34:52 +01:00
Grot (@grafanabot)
3cfa2c12db Alerting: Fixes alert panel header icon not showing (#30840) (#30885)
* Alerting: Fixes alert panel header icon not showing

* Remove as any

(cherry picked from commit 01b10ab436)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-02-04 09:18:19 +01:00
Leonard Gram
fdf52dd45c Plugins: Requests validator (#30445) (#30877)
* Introduce PluginRequestValidator abstraction with a NoOp implementation

* Update PluginRequestValidator abstraction to use the dsURL instead

* Inject PluginRequestValidator into the HTTPServer and validate requests going through data source proxy

* Inject PluginRequestValidator into the BackendPluginManager and validate requests going through it

* Validate requests going through QueryMetrics & QueryMetricsV2

* Validate BackendPluginManager health requests

* Fix backend plugins manager tests

* Validate requests going through alerting service

* Fix tests

* fix tests

* goimports

Co-authored-by: Leonard Gram <leo@xlson.com>
(cherry picked from commit 6415d2802e)

Co-authored-by: Joan López de la Franca Beltran <joanjan14@gmail.com>
2021-02-04 08:05:18 +01:00
Grot (@grafanabot)
87cb290cbd PanelLibrary: Adds library panel meta information to dashboard json (#30770) (#30883)
(cherry picked from commit 179f35a537)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-02-04 06:53:07 +01:00
Grot (@grafanabot)
39aae712cf bump grabpl version to 0.5.36 (#30874) (#30878)
* bump grabpl version to 0.5.36

* 2 missing shell script

(cherry picked from commit c24a4c1803)

Co-authored-by: ying-jeanne <74549700+ying-jeanne@users.noreply.github.com>
2021-02-03 23:20:57 +01:00
Grot (@grafanabot)
dd957acc5b Chore: remove __debug_bin (#30725) (#30857)
(cherry picked from commit e0356f7b13)

Co-authored-by: 大可 <hnlq.sysu@gmail.com>
2021-02-03 18:49:54 +02:00
Grot (@grafanabot)
b6e65e8b3c Grafana-ui: fixes closing modals with escape key (#30745) (#30873)
* feat(grafana-ui): add an escape key listener to Modal

* Update packages/grafana-ui/src/components/Modal/Modal.tsx

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>

* feat(grafana-ui): add closeOnEscape prop to control Modal behaviour

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
(cherry picked from commit 3066b38c5e)

Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
2021-02-03 17:23:05 +01:00
Grot (@grafanabot)
5fa729804a DashboardLinks: Support variable expression in to tooltip - Issue #30409 (#30569) (#30852)
* add compile variable in tooltip link

* test(link_srv): introduce getAnchorInfo test

* test(link_srv): introduce tests for getLinkUrl

* test(link_srv): refer to anchorInfo.url rather than hardcode expected

Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
(cherry picked from commit 141202f518)

Co-authored-by: Ha. Huynh Sam <huynhha12798@gmail.com>
2021-02-03 17:22:00 +01:00
Grot (@grafanabot)
299759c1ba Add alt text to plugin logos (#30710) (#30872)
(cherry picked from commit 3390c6a852)

Co-authored-by: Besart Berisha <besart.ber@gmail.com>
2021-02-03 17:17:06 +01:00
Grot (@grafanabot)
0cf5d1c561 InfluxDB: Add http configuration when selecting InfluxDB v2 flavor (#30827) (#30870)
* Add dev env block for influx2

* Add http settings to influx config

* Update devenv/docker/blocks/influxdb2/docker-compose.yaml

Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>

Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>
(cherry picked from commit 7db00ed6a0)

Co-authored-by: Andrej Ocenas <mr.ocenas@gmail.com>
2021-02-03 17:15:54 +01:00
Grot (@grafanabot)
6a74859ca1 Prometheus: Set type of labels to string (#30831) (#30835)
(cherry picked from commit 0427df8f60)

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
2021-02-03 17:11:10 +01:00
Grot (@grafanabot)
d2dc8416f6 AlertingNG: change API permissions (#30781) (#30814)
(cherry picked from commit 5d029abc42)

Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>
2021-02-03 17:35:44 +02:00
Grot (@grafanabot)
bf9940b3b2 Grafana-ui: fixes no data message in Table component (#30821) (#30855)
* Wip

* fix(grafana-ui): add no data message to Table component

(cherry picked from commit 4f684cc498)

Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
2021-02-03 10:29:27 +01:00
Grot (@grafanabot)
6c3abc6d01 Prometheus: Add tooltip to explain possibility to use patterns in text and title fields in annotations (#30825) (#30843)
* Add tip for using pattern

* Update public/app/plugins/datasource/prometheus/partials/annotations.editor.html

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
(cherry picked from commit 25ef563a53)

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
2021-02-03 09:33:22 +01:00
Grot (@grafanabot)
45bad20884 Chore: add more docs annotations (#30847) (#30851)
(cherry picked from commit 3a343aa547)

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2021-02-02 22:45:53 -08:00
Grot (@grafanabot)
a612211ce3 BarChart: inside-align strokes, upgrade uPlot to 1.6.4. (#30806) (#30846)
(cherry picked from commit b5400922e2)

Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
2021-02-02 15:09:25 -06:00
Grot (@grafanabot)
1108da9574 Transforms: allow boolean in field calculations (#30802) (#30845)
(cherry picked from commit c9c7bfbcaa)

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2021-02-02 12:51:28 -08:00
Grot (@grafanabot)
880c78f1d7 CDN: Fixes cdn path when Grafana is under sub path (#30822) (#30823)
(cherry picked from commit 64254eaa82)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-02-02 14:03:17 +01:00
Grot (@grafanabot)
22171be811 bump cypress to 6.3.0 (#30644) (#30819)
* bump cypress to 6.3.0

* fix inspect-drawer spec

* fix panelEdit_base spec

* fix select-focus spec

* Apply suggestions from code review

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>

* add be.visible assertion to new-query-variable spec to avoid flakiness

* increase waits in new-query-variable spec to avoid flakiness

* increase waits in new-query-variable spec by another 500

* remove be.visible assertion added before

* Chore: trying to fix flakiness

* skip the new-variable-query e2e test

* Chore: refactor so we might avoid flakiness

* Revert "skip the new-variable-query e2e test"

This reverts commit 203c1875c2.

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
Co-authored-by: Hugo Häggmark <hugo.haggmark@gmail.com>
(cherry picked from commit b8dd50c297)

Co-authored-by: Vicky Lee <36230812+vickyyyyyyy@users.noreply.github.com>
2021-02-02 11:56:39 +01:00
Grot (@grafanabot)
5428200593 Expressions: Measure total transformation requests and elapsed time (#30514) (#30789)
* Measure transformation number and elapsed time

* Change histogram to summary

* Apply suggestions from code review

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
(cherry picked from commit 2f394a219b)

Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>
2021-02-02 12:49:00 +02:00
Grot (@grafanabot)
a39c19dfa5 Grafana-UI: Add story/docs for ErrorBoundary (#30304) (#30811)
(cherry picked from commit eb83135ba9)

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
2021-02-02 12:05:00 +02:00
Torkel Ödegaard
9dc3574cc1 [v7.4.x]: Menu: Mark menu components as internal (#30801) 2021-02-02 10:19:59 +01:00
Grot (@grafanabot)
0f6d0f40ff Graph: Fixes auto decimals issue in legend and tooltip (#30628) (#30635)
* Graph: Fixes auto decimals issue in legend and tooltip

* Updated decimals

(cherry picked from commit f109f06485)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-02-02 09:54:17 +01:00
Grot (@grafanabot)
e489013ae1 GraphNG: Disable Plot logging by default (#30390) (#30500)
* Disable Plot loggging by default

* Fix

(cherry picked from commit ffa68f6f91)

Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
2021-02-02 09:54:03 +01:00
Grot (@grafanabot)
3969177094 Storybook: Migrate card story to use controls (#30535) (#30549)
(cherry picked from commit 9c20698dfe)

Co-authored-by: Peter Holmberg <peterholmberg@users.noreply.github.com>
2021-02-02 09:53:55 +01:00
Grot (@grafanabot)
f2d07b6b8e GraphNG: add bar alignment option (#30499) (#30790)
* GraphNG: add bar alignment option

* Fix builders

(cherry picked from commit 820866e425)

Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
2021-02-02 09:53:30 +01:00
Grot (@grafanabot)
2b3f48a44c Variables: Clears drop down state when leaving dashboard (#30810) (#30812)
(cherry picked from commit 6994f19d1f)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-02-02 09:37:55 +01:00
Grot (@grafanabot)
8b1c6ed1b3 Add missing callback dependency (#30797) (#30809)
(cherry picked from commit 64a1003a28)

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
2021-02-02 10:05:53 +02:00
Grot (@grafanabot)
6c9e8549ca GraphNG: improve behavior when switching between solid/dash/dots (#30796) (#30799)
(cherry picked from commit fcac59107c)

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2021-02-01 10:07:17 -08:00
Grot (@grafanabot)
4fc57f13ab Add width for Variable Editors (#30791) (#30795)
(cherry picked from commit 76f77f86c5)

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
2021-02-01 17:12:08 +01:00
Grot (@grafanabot)
d1c95055ca Panels: Fixes so panels are refreshed when scrolling past them fast (#30784) (#30792)
(cherry picked from commit 08eee87148)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-02-01 15:25:25 +01:00
Grot (@grafanabot)
264f790728 PanelEdit: Trigger refresh when changing data source (#30744) (#30767)
(cherry picked from commit a8a3e02699)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-02-01 12:18:17 +01:00
Grot (@grafanabot)
60e7db2346 AlertingNG: Enable UI to Save Alert Definitions (#30394) (#30548)
* transform state to what the api expects

* add expr prop to dataquery

* Add evalutate field

* add refid picker to options

* minor fix to enable save

* fix  import

* more fixes after merge

* use default datasource if not changed

* replace name with title

* Change name in ui as well

* remove not used loadDataSources function

* prettier fixes

* look up datasource

* correct datasource per query model

* revert dataquery change, use expressionid const

* fix for type

* fix faulty const

* description readonly

(cherry picked from commit 529f564bd4)

Co-authored-by: Peter Holmberg <peterholmberg@users.noreply.github.com>
2021-02-01 11:49:52 +01:00
Grot (@grafanabot)
7374a963be CDN: Fix passing correct prefix to GetContentDeliveryURL (#30777) (#30779)
(cherry picked from commit 561a0a2995)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-02-01 11:42:45 +01:00
Grot (@grafanabot)
64c13cd46b CDN: Adds support for serving assets over a CDN (#30691) (#30776)
* CDN: Initial poc support for serving assets over a CDN

* Minor fix

* added build path and test

* fix lint error

* Added edition to cdn path

* Move master builds to a separate path

* Added error handling for the url parsing, changed setting name, and added docs

* Updated sample.ini

* Some property renames

* updated

* Minor update to html

* index template improvements

* Update docs/sources/administration/configuration.md

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

* Update docs/sources/administration/configuration.md

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

* Added ContentDeliveryPrefix to Licence service

* updated docs

* Updated test mock

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
(cherry picked from commit c04bc805b5)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-02-01 11:00:46 +01:00
Grot (@grafanabot)
5bb9731a84 Explore: Update styling of buttons (#30493) (#30508)
* Switch deprecared toggle group for radio buttons

* Create transparent version of field, label and witch

* Replace divs wiith components

* Move styling from scss to js

* Update buttons

* Remove log generating file

* Update level button

(cherry picked from commit 56fb04e94c)

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
2021-02-01 10:56:17 +01:00
Grot (@grafanabot)
836a07a670 Loki: Append refId to logs uid (#30418) (#30537)
* Append refId to Loki uid, add tests

* Fix linting

* Fix linting

* Hopefully finally fix linting errors

(cherry picked from commit 6692e1c332)

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
2021-02-01 10:28:42 +01:00
Grot (@grafanabot)
b78166f8df skip symlinks to directories when generating plugin manifest (#30721) (#30738)
(cherry picked from commit 06061c8741)

Co-authored-by: Dan Cech <dcech@grafana.com>
2021-01-29 13:43:57 -08:00
Grot (@grafanabot)
563e98d334 Mobile: Fixes issue scrolling on mobile in chrome (#30746) (#30750)
(cherry picked from commit 5e37361182)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-01-29 13:43:11 -08:00
Grot (@grafanabot)
12a9097742 BarChart: add alpha bar chart panel (#30323) (#30754)
(cherry picked from commit 26b168f7eb)

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2021-01-29 13:42:20 -08:00
Grot (@grafanabot)
021ef24ea9 Datasource: Use json-iterator configuration compatible with standard library (#30732) (#30739)
This will make sure that any map keys in JSON is ordered in /api/ds/query response.

(cherry picked from commit f62eb28f3e)

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2021-01-29 16:17:03 +01:00
Grot (@grafanabot)
1e8019aff5 Variables: Fixes so text format will show All instead of custom all (#30730) (#30731)
(cherry picked from commit 8744ad361b)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-01-29 09:45:55 +01:00
Grot (@grafanabot)
cd4524aba0 AlertingNG: pause/unpause definitions via the API (#30627) (#30672)
* AlertingNG: pause/unpause definitions via the API

* Apply suggestions from code review

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>

* Enable pausing/unpausing multiple definitions

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
(cherry picked from commit 1c158744e8)

Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>
2021-01-29 10:01:03 +02:00
Grot (@grafanabot)
a2e638352b PanelLibrary: better handling of deleted panels (#30709) (#30726)
(cherry picked from commit 0b1f5c5e32)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-01-29 06:39:42 +01:00
Grot (@grafanabot)
91f5cd23c2 Transform: improve the "outer join" performance/behavior (#30407) (#30722)
(cherry picked from commit db9a8bf04a)

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2021-01-28 16:34:15 -08:00
Grot (@grafanabot)
7aa169af9e DashboardPicker: switch to promise-based debounce, return dashboard UID (#30706) (#30714)
* Use uid in dashboard picker

* Set both id and uid from picker

* Use debounce-promise

* Simplify logic

* Use exact package versions

(cherry picked from commit e36b035c05)

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
2021-01-28 20:12:51 +02:00
Grot (@grafanabot)
b22ecf33f1 Use connected GraphNG in Explore (#30707) (#30708)
(cherry picked from commit 78433032ab)

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
2021-01-28 14:55:35 +01:00
Grot (@grafanabot)
31df45f316 PanelLibrary: changes casing of responses and adds meta property (#30668) (#30711)
* PanelLibrary: changes casing of responses and adds meta property

* Chore: updates comments

* Chore: updates after PR comments

* Chore: changes casing of orgId

(cherry picked from commit 0a8eae2c12)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-01-28 14:52:08 +01:00
Grot (@grafanabot)
5e20794cfe DeployImage: Switch base images to Debian (#30684) (#30699)
* DeployImage: Switch base images to Debian

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
(cherry picked from commit fdd6a84d82)

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
2021-01-28 13:49:32 +01:00
Grot (@grafanabot)
b768649a10 Trace: trace to logs design update (#30637) (#30702)
* Add new icon to custom icons

* Show button in span detail

(cherry picked from commit 4147c3b907)

Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
2021-01-28 12:56:42 +01:00
Grot (@grafanabot)
007efb3691 Influx: Show all datapoints for dynamically windowed flux query (#30688) (#30703)
(cherry picked from commit 1bdd3eb3dd)

Co-authored-by: David <david.kaltschmidt@gmail.com>
2021-01-28 12:16:22 +01:00
Grot (@grafanabot)
d38179bc79 ci(npm-publish): add missing github package token to env vars (#30665) (#30673)
(cherry picked from commit 54b1ce2cdb)

Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
2021-01-28 09:49:56 +01:00
Ivana Huckova
05f18add0b Loki: Improve live tailing errors and fix Explore's logs container type errors (#30517) (#30681)
* If error - catch and show, if no logs - return null

* Refactor LogsContainer to use ConnectedProps

* Fix typescript error

* Remove no logs check

* Include review feedback

* Add SplitOpen type to createSpanLink and TraceView

(cherry picked from commit 347343f583)
2021-01-28 09:07:07 +01:00
Grot (@grafanabot)
b3425159e1 Grafana-UI: Fix setting default value for MultiSelect (#30671) (#30687)
* Grafana-ui: Default value to undefned vs empty array

* Grafana-ui: Remove log

* Grafana-ui: Update tests

(cherry picked from commit aad7d495ec)

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
2021-01-28 09:39:00 +02:00
Grot (@grafanabot)
89d5428954 Explore: Fix jumpy live tailing (#30650) (#30677)
* Fix jumpy live tailing

* Fix test

(cherry picked from commit e34d9e1c32)

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
2021-01-27 16:41:54 +01:00
Grot (@grafanabot)
844c5a14e8 Docs: Refer to product docs in whats new for alerting templating feature (#30652) (#30670)
* Docs: Refer to product docs in whats new for alerting templating feature

* move link below image

* remove whitespace

(cherry picked from commit bdf00d3a59)

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
2021-01-27 15:25:58 +01:00
Grot (@grafanabot)
7d670ee7e1 Variables: Fixes display value when using capture groups in regex (#30636) (#30661)
* Variables: Fixes display value for variables with regex

* Chore: adds a test for getAllMatches

(cherry picked from commit b5d7f1e7d8)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-01-27 07:13:17 +01:00
Grot (@grafanabot)
b6acd8b685 Docs: Fix expressions enabled description (#30589) (#30651)
(cherry picked from commit 94a29759ab)

Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>
2021-01-26 10:16:44 -08:00
Grot (@grafanabot)
b4cc173235 Licensing Docs: Adding license restrictions docs (#30216) (#30648)
(cherry picked from commit 12a7b342b9)

Co-authored-by: Vardan Torosyan <vardants@gmail.com>
2021-01-26 18:22:16 +01:00
Grot (@grafanabot)
0664013253 DashboardSettings: fixes vertical scrolling (#30640) (#30643)
* fix(dashboardsettings): allow view to scroll vertically

* refactor(dashboardsettings): use theme bg colour instead of palette colour

(cherry picked from commit aaa6ebb231)

Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
2021-01-26 16:01:57 +01:00
Jack Westbrook
365c008d70 chore: bump redux toolkit to 1.5.0 for immer 8.0.1 vulnerability fix (#30605) (#30631)
(cherry picked from commit 10aabe8ce3)
2021-01-26 14:08:34 +01:00
Grot (@grafanabot)
ca6a767dc0 Explore: Fix loading visualisation on the top of the new time series panel (#30553) (#30557)
* Fix loading for time series graph panel

* Fix test by adding loading prop to dummyProps

(cherry picked from commit 5d52e50f6f)

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
2021-01-26 13:48:24 +01:00
Grot (@grafanabot)
aadbb1ebf4 Footer: Fixes layout issue in footer (#30443) (#30494)
* Footer: Fixes missing icon issue causing footer layout issue

* Another fix

(cherry picked from commit 5c8d662bfc)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-01-26 13:47:45 +01:00
Grot (@grafanabot)
3875ae2319 Variables: Fixes so queries work for numbers values too (#30602) (#30624)
* Variables: Fixes so queries work for numbers values too

* Chore: refactor after PR comments

(cherry picked from commit fad81e1696)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-01-26 09:06:14 +01:00
Grot (@grafanabot)
5052887efb Admin: Fixes so form values are filled in from backend (#30544) (#30623)
* Admin: Fixes so form values are filled in from backend

* Chore: tidy up the imports

(cherry picked from commit a8056e2c9d)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-01-26 08:09:20 +01:00
Grot (@grafanabot)
3e02e2c12c Docs: Update 7.4 What's New to use more correct description of alerting notification template feature (#30502) (#30614)
* use more correct description of feature

* reference variable templating

* add word

(cherry picked from commit ad7d75c14d)

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
2021-01-25 11:41:05 -08:00
Grot (@grafanabot)
c6df872d4a NodeGraph: Add docs (#30504) (#30613)
* Add draft docs

* Update node-graph.md

* Update whats-new-in-v7-4.md

* Update images and add x-ray link

* Update docs/sources/panels/visualizations/node-graph.md

* Update docs/sources/panels/visualizations/node-graph.md

* Update node-graph.md

* Add definition of node and edge

* Update docs/sources/panels/visualizations/node-graph.md

* Update docs/sources/panels/visualizations/node-graph.md

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
(cherry picked from commit abf2410d16)

Co-authored-by: Andrej Ocenas <mr.ocenas@gmail.com>
2021-01-25 11:19:02 -08:00
Grot (@grafanabot)
e1f512181f Cloud Monitoring: Fix legend naming with display name override (#30440) (#30503)
* Cloud Monitoring: Fix legend naming with display name override

* include MQL queries

* cover all bases

* refactor

(cherry picked from commit 7562c6749d)

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
2021-01-25 20:17:16 +01:00
Grot (@grafanabot)
fcfb12d0b3 Expressions: Add option to disable feature (#30541) (#30558)
* Expressions: Add option to disable feature

* Apply suggestions from code review

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
(cherry picked from commit 9ada4b6052)

Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>
2021-01-25 15:58:52 +02:00
Grot (@grafanabot)
7592031b36 OldGraph: Fix height issue in Firefox (#30565) (#30582)
(cherry picked from commit 15683319e0)

Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
2021-01-25 08:40:28 +01:00
Grot (@grafanabot)
77e924295b XY Chart: fix editor error with empty frame (no fields) (#30573) (#30577)
(cherry picked from commit 08312897c8)

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2021-01-24 08:59:39 -08:00
Grot (@grafanabot)
5a07677422 XY Chart: share legend config with timeseries (#30559) (#30566)
(cherry picked from commit 8c1a79f24b)

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2021-01-22 15:20:12 -08:00
Grot (@grafanabot)
b6a9ef0919 DataFrame: cache frame/field index in field state (#30529) (#30560)
(cherry picked from commit f2327baf66)

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2021-01-22 10:46:41 -08:00
Grot (@grafanabot)
b31aed4283 Prometheus: Fix show query instead of Value if no __name__ and metric (#30511) (#30556)
Fixes #29466

(cherry picked from commit 38c1d45035)

Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
2021-01-22 18:31:06 +01:00
Grot (@grafanabot)
045f4f4f4a Decimals: Big Improvements to auto decimals and fixes to auto decimals bug found in 7.4-beta1 (#30519) (#30550)
* Decimals: Nukes scaledDecimals from the earth it was an abomination

* Moved move tests

* Fixed test

* Updated tests

* Updated test

(cherry picked from commit 6bdc9fac45)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-01-22 17:16:23 +01:00
Jack Westbrook
14d44553c5 chore: update packages dependent on dot-prop to fix security vulnerability (#30432) (#30487)
(cherry picked from commit e4d8cdfcdf)
2021-01-22 10:18:59 +01:00
Grot (@grafanabot)
f02dd1c6aa GraphNG: uPlot 1.6.3 (fix bands not filling below 0). close #30523. (#30527) (#30528)
(cherry picked from commit 92a0ad7273)

Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
2021-01-21 20:40:58 -08:00
Grot (@grafanabot)
13f4755ac2 GraphNG: uPlot 1.6.2 (#30521) (#30522)
(cherry picked from commit 87ef5598e6)

Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
2021-01-21 18:21:26 -06:00
Grot (@grafanabot)
18bcbc4903 Chore: Upgrade grabpl version (#30486) (#30513)
(cherry picked from commit bb1f84dbc7)

Co-authored-by: Tania B <yalyna.ts@gmail.com>
2021-01-21 19:28:03 +02:00
Grot (@grafanabot)
db9ec5ccae grafana/ui: Fix internal import from grafana/data (#30439) (#30507)
(cherry picked from commit c7e6d14d34)

Co-authored-by: Andrej Ocenas <mr.ocenas@gmail.com>
2021-01-21 17:58:43 +01:00
Grot (@grafanabot)
6b8e230f45 prevent field config from being overwritten (#30437) (#30442)
(cherry picked from commit d9d27340b5)

Co-authored-by: Erik Sundell <erik.sundell@grafana.com>
2021-01-21 15:50:50 +01:00
Grot (@grafanabot)
5abe8852c1 Chore: upgrade NPM security vulnerabilities (#30397) (#30495)
* chore: bump serialize-javascript dependents to use 3.1.0+

* chore: manually bump is-my-json-valid to 2.20.5

* chore: resolve kind-of@6 to 6.0.3

* chore: bump webpack-dev-server to solve faye-websocket vulnerability

(cherry picked from commit 930c19eb09)

Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
2021-01-21 15:29:43 +01:00
Grot (@grafanabot)
8b9cb9d034 TimeSeriesPanel: Fixed default value for gradientMode (#30484) (#30492)
(cherry picked from commit 59ef36812e)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-01-21 14:24:38 +01:00
Grot (@grafanabot)
804c3a9be0 Admin: Fixes so whole org drop down is visible when adding users to org (#30481) (#30497)
* Modal: Admin: Fixes so whole org drop down is visible

* Tests: fixes failing tests

* Chore: cleans up the return type

* Chore: changes after PR comments

* Chore: changes after PR comments

(cherry picked from commit ffd39933d4)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-01-21 14:19:56 +01:00
Grot (@grafanabot)
648efa9391 Chore: adds wait to e2e test (#30488) (#30490)
(cherry picked from commit de511b0f48)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-01-21 12:55:52 +01:00
Grot (@grafanabot)
83f0acfc03 Graph: Fixes so only users with correct permissions can add annotations (#30419) (#30466)
* Graph: Fixes so only users with edit permissions can add annotations

* Tests: corrects test message text

* Chore: changes after PR comments

(cherry picked from commit e1243e07ca)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-01-21 08:25:39 +01:00
Grot (@grafanabot)
88c70cd762 Alerting: Hides threshold handle for percentual thresholds (#30431) (#30467)
(cherry picked from commit 98406d6c42)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-01-21 08:03:42 +01:00
Grot (@grafanabot)
fed65b983a Timeseries: only migrage point size when configured (#30461) (#30470)
(cherry picked from commit 2ec4784190)

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2021-01-21 07:49:26 +01:00
Grot (@grafanabot)
39c5f1705e Expressions: Fix button icon (#30444) (#30450)
(cherry picked from commit b9fd4dba36)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-01-21 06:06:22 +01:00
Grot (@grafanabot)
45f71a94f8 PanelModel: Make sure the angular options are passed to react panel type changed handler (#30441) (#30451)
(cherry picked from commit 05e37e9253)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-01-21 06:05:58 +01:00
Grot (@grafanabot)
18f5bb15b7 Docs: Fix img link for alert notification template (#30436) (#30447)
* fix img link

* update image name

(cherry picked from commit 0c67ceadb8)

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
2021-01-21 05:59:10 +01:00
Grot (@grafanabot)
594733024a Chore: Upgrade build pipeline tool (#30456) (#30457)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
(cherry picked from commit bd71eb23df)

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
2021-01-20 22:04:00 +01:00
Grot (@grafanabot)
f666d108b4 PanelOptions: Refactoring applying panel and field options out of PanelModel and add property clean up for properties not in field config registry (#30389) (#30438)
* PanelOptions: Refactoring on applying panel and field options from PanelModel

* Progress

* Filtering out props

* downgraded prettier

* Fixes

* Initial simple remember and restore for custom and overrides

* clearing custom options and overrides and restoring works

* actually use the function

* Added type for options cache

* minor fix

* Updated with new prettier

* Added old field config to panel type change handler

* Update public/app/features/dashboard/state/getPanelOptionsWithDefaults.test.ts

Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>

Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
(cherry picked from commit 15033d0011)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
2021-01-20 18:27:19 +01:00
Grot (@grafanabot)
228d804962 "Release: Updated versions in package to 7.4.0-beta.1" (#30427) 2021-01-20 11:09:55 +00:00
Giordano Ricci
e9242cf546 Chore: Update what's new URL (#30423) 2021-01-20 10:51:35 +00:00
5507 changed files with 162818 additions and 415685 deletions

14
.babelrc Normal file
View File

@@ -0,0 +1,14 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"browsers": "last 3 versions"
},
"useBuiltIns": "entry",
"modules": "false",
}
]
]
}

12
.bingo/.gitignore vendored
View File

@@ -1,12 +0,0 @@
# Ignore everything
*
# But not these files:
!.gitignore
!*.mod
!README.md
!Variables.mk
!variables.env
*tmp.mod

View File

@@ -1,14 +0,0 @@
# Project Development Dependencies.
This is directory which stores Go modules with pinned buildable package that is used within this repository, managed by https://github.com/bwplotka/bingo.
- Run `bingo get` to install all tools having each own module file in this directory.
- Run `bingo get <tool>` to install <tool> that have own module file in this directory.
- For Makefile: Make sure to put `include .bingo/Variables.mk` in your Makefile, then use $(<upper case tool name>) variable where <tool> is the .bingo/<tool>.mod.
- For shell: Run `source .bingo/variables.env` to source all environment variable for each tool.
- For go: Import `.bingo/variables.go` to for variable names.
- See https://github.com/bwplotka/bingo or -h on how to add, remove or change binaries dependencies.
## Requirements
- Go 1.14+

View File

@@ -1,25 +0,0 @@
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.4.3. DO NOT EDIT.
# All tools are designed to be build inside $GOBIN.
BINGO_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
GOPATH ?= $(shell go env GOPATH)
GOBIN ?= $(firstword $(subst :, ,${GOPATH}))/bin
GO ?= $(shell which go)
# Below generated variables ensure that every time a tool under each variable is invoked, the correct version
# will be used; reinstalling only if needed.
# For example for wire variable:
#
# In your main Makefile (for non array binaries):
#
#include .bingo/Variables.mk # Assuming -dir was set to .bingo .
#
#command: $(WIRE)
# @echo "Running wire"
# @$(WIRE) <flags/args..>
#
WIRE := $(GOBIN)/wire-v0.5.0
$(WIRE): $(BINGO_DIR)/wire.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/wire-v0.5.0"
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=wire.mod -o=$(GOBIN)/wire-v0.5.0 "github.com/google/wire/cmd/wire"

View File

@@ -1 +0,0 @@
module _ // Fake go.mod auto-created by 'bingo' for go -moddir compatibility with non-Go projects. Commit this file, together with other .mod files.

View File

@@ -1,12 +0,0 @@
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.4.3. DO NOT EDIT.
# All tools are designed to be build inside $GOBIN.
# Those variables will work only until 'bingo get' was invoked, or if tools were installed via Makefile's Variables.mk.
GOBIN=${GOBIN:=$(go env GOBIN)}
if [ -z "$GOBIN" ]; then
GOBIN="$(go env GOPATH)/bin"
fi
WIRE="${GOBIN}/wire-v0.5.0"

View File

@@ -1,5 +0,0 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
go 1.16
require github.com/google/wire v0.5.0 // cmd/wire

View File

@@ -1,6 +1,5 @@
[run]
init_cmds = [
["make", "gen-go"],
["go", "run", "build.go", "-dev", "build-cli"],
["go", "run", "build.go", "-dev", "build-server"],
["./bin/grafana-server", "-packaging=dev", "cfg:app_mode=development"]

View File

@@ -1,15 +1,4 @@
[dev]
last 1 chrome versions
last 1 firefox versions
last 1 safari versions
[production]
last 2 Firefox versions
last 2 Chrome versions
last 2 Safari versions
last 2 Edge versions
last 1 ios_saf versions
last 1 and_chr versions
last 1 samsung versions
>1%,
Chrome > 20
last 4 versions,
Firefox ESR

View File

@@ -1,11 +1,60 @@
version: 2.1
jobs:
build:
docker:
- image: alpine:3.7
steps:
- run:
name: The First Step
command: |
echo 'Fake step!'
aliases:
# Workflow filters
- &filter-only-master
branches:
only: master
jobs:
scan-docker-image:
description: "Scans a docker image for vulnerabilities using trivy"
parameters:
image:
type: string
tag:
type: string
docker:
- image: circleci/buildpack-deps:stretch
steps:
- setup_remote_docker
- restore_cache:
key: vulnerability-db
- run:
name: Install trivy
command: |
VERSION=$(
curl --silent "https://api.github.com/repos/aquasecurity/trivy/releases/latest" | \
grep '"tag_name":' | \
sed -E 's/.*"v([^"]+)".*/\1/'
)
wget https://github.com/aquasecurity/trivy/releases/download/v${VERSION}/trivy_${VERSION}_Linux-64bit.tar.gz
tar zxvf trivy_${VERSION}_Linux-64bit.tar.gz
sudo mv trivy /usr/local/bin
- run:
name: Clear trivy cache
command: trivy --clear-cache
- run:
name: Scan Docker image for unkown/low/medium vulnerabilities
command: trivy --exit-code 0 --severity UNKNOWN,LOW,MEDIUM << parameters.image >>:<< parameters.tag >>
- run:
name: Scan Docker image for high/critical vulnerabilities
command: trivy --exit-code 1 --severity HIGH,CRITICAL << parameters.image >>:<< parameters.tag >>
- save_cache:
key: vulnerability-db
paths:
- $HOME/.cache/trivy
workflows:
nightly:
triggers:
- schedule:
cron: "0 0 * * *"
filters: *filter-only-master
jobs:
- scan-docker-image:
matrix:
parameters:
image: [grafana/grafana, grafana/grafana-enterprise]
tag: [latest, master, latest-ubuntu, master-ubuntu]

View File

@@ -1,17 +1,9 @@
# To generate the .drone.yml file:
# 1. Modify the *.star definitions
# 2. Login to drone and export the env variables (token and server) shown here: https://drone.grafana.net/account
# 3. Run `make drone`
# More information about this process here: https://github.com/grafana/deployment_tools/blob/master/docs/infrastructure/drone/signing.md
load('scripts/drone/pipelines/pr.star', 'pr_pipelines')
load('scripts/drone/pipelines/main.star', 'main_pipelines')
load('scripts/drone/pipelines/release.star', 'release_pipelines', 'test_release_pipelines')
load('scripts/drone/version.star', 'version_branch_pipelines')
load('scripts/drone/pipelines/cron.star', 'cronjobs')
load('scripts/drone/vault.star', 'secrets')
load('scripts/pr.star', 'pr_pipelines')
load('scripts/master.star', 'master_pipelines')
load('scripts/release.star', 'release_pipelines', 'test_release_pipelines')
load('scripts/version.star', 'version_branch_pipelines')
def main(ctx):
edition = 'oss'
return pr_pipelines(edition=edition) + main_pipelines(edition=edition) + release_pipelines() + \
test_release_pipelines() + version_branch_pipelines() + cronjobs(edition=edition) + secrets()
return pr_pipelines(edition=edition) + master_pipelines(edition=edition) + release_pipelines() + \
test_release_pipelines() + version_branch_pipelines()

1285
.drone.yml

File diff suppressed because it is too large Load Diff

View File

@@ -1,28 +1,24 @@
{
"extends": ["@grafana/eslint-config"],
"root": true,
"plugins": ["no-only-tests", "@emotion", "lodash"],
"plugins": [
"no-only-tests"
],
"rules": {
"no-only-tests/no-only-tests": "error",
"react/prop-types": "off",
"@emotion/jsx-import": "error",
"lodash/import-scope": [2, "member"]
"react/prop-types": "off"
},
"overrides": [
{
"files": ["packages/grafana-ui/src/components/uPlot/**/*.{ts,tsx}"],
"files": [
"packages/grafana-ui/**/*/!(*.story).{ts,tsx}",
"packages/jaeger-ui-components/**/*.{ts,tsx,js}",
"public/app/**/*.{ts,tsx}"
],
"rules": {
"react-hooks/rules-of-hooks": "off",
"react-hooks/exhaustive-deps": "off"
}
},
{
"files": ["packages/grafana-ui/src/components/ThemeDemos/**/*.{ts,tsx}"],
"rules": {
"@emotion/jsx-import": "off",
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off"
}
}
]
}

46
.github/CODEOWNERS vendored
View File

@@ -11,47 +11,19 @@
# In each subsection folders are ordered first by depth, then alphabetically.
# This should make it easy to add new rules without breaking existing ones.
# Documentation owner: Jita Chatterjee
/docs/ @grafana/docs-squad @pkolyvas
/contribute/ @marcusolsson @grafana/docs-squad @pkolyvas
/docs/sources/developers/plugins/ @marcusolsson @grafana/docs-squad
/docs/sources/enterprise/ @osg-grafana @grafana/docs-squad
# Documentation owner: Diana Payton
/docs/ @grafana/docs-squad
/contribute/ @marcusolsson @grafana/docs-squad
/docs/sources/developers/plugins/ @marcusolsson
/docs/sources/enterprise/ @osg-grafana
# Backend code
*.go @grafana/backend-platform
go.mod @grafana/backend-platform
go.sum @grafana/backend-platform
# Continuous Integration
.drone.yml @malcolmholmes @dsotirakis @zserge
/scripts/drone/ @malcolmholmes @dsotirakis @zserge
# Cloud Datasources backend code
/pkg/tsdb/cloudwatch @grafana/cloud-datasources @grafana/observability-squad
/pkg/tsdb/azuremonitor @grafana/cloud-datasources
/pkg/tsdb/cloudmonitoring @grafana/cloud-datasources
# Observability backend code
/pkg/tsdb/influxdb @grafana/observability-squad
/pkg/tsdb/elasticsearch @grafana/observability-squad
/pkg/tsdb/graphite @grafana/observability-squad
/pkg/tsdb/jaeger @grafana/observability-squad
/pkg/tsdb/loki @grafana/observability-squad
/pkg/tsdb/zipkin @grafana/observability-squad
/pkg/tsdb/tempo @grafana/observability-squad
# Unified Alerting
/pkg/services/ngalert @grafana/alerting-squad
/pkg/services/sqlstore/migrations/ualert @grafana/alerting-squad
# Database migrations
/pkg/services/sqlstore/migrations @grafana/backend-platform @grafana/hosted-grafana-team
*_mig.go @grafana/backend-platform @grafana/hosted-grafana-team
# Backend code docs
/contribute/style-guides/backend.md @grafana/backend-platform
/contribute/architecture/backend @grafana/backend-platform
/contribute/engineering/backend @grafana/backend-platform
/e2e @grafana/grafana-frontend-platform
/packages @grafana/grafana-frontend-platform
@@ -76,9 +48,9 @@ lerna.json @grafana/grafana-frontend-platform
/packages/jaeger-ui-components/ @grafana/observability-squad
# Core datasources
/public/app/plugins/datasource/cloudwatch @grafana/cloud-datasources @grafana/observability-squad
/public/app/plugins/datasource/cloudwatch @grafana/backend-platform @grafana/observability-squad
/public/app/plugins/datasource/elasticsearch @grafana/observability-squad
/public/app/plugins/datasource/grafana-azure-monitor-datasource @grafana/cloud-datasources
/public/app/plugins/datasource/grafana-azure-monitor-datasource @grafana/backend-platform
/public/app/plugins/datasource/graphite @grafana/observability-squad
/public/app/plugins/datasource/influxdb @grafana/observability-squad
/public/app/plugins/datasource/jaeger @grafana/observability-squad
@@ -88,10 +60,8 @@ lerna.json @grafana/grafana-frontend-platform
/public/app/plugins/datasource/opentsdb @grafana/backend-platform
/public/app/plugins/datasource/postgres @grafana/backend-platform
/public/app/plugins/datasource/prometheus @grafana/observability-squad
/public/app/plugins/datasource/cloud-monitoring @grafana/cloud-datasources
/public/app/plugins/datasource/cloud-monitoring @grafana/backend-platform
/public/app/plugins/datasource/zipkin @grafana/observability-squad
/public/app/plugins/datasource/tempo @grafana/observability-squad
/public/app/plugins/datasource/alertmanager @grafana/alerting-squad
# Cloud middleware
/grafana-mixin/ @grafana/cloud-middleware

View File

@@ -0,0 +1,11 @@
---
name: Enhancement request
about: Suggest an enhancement or new feature for the Grafana project
labels: 'type: feature request'
---
<!-- Please only use this template for submitting feature requests -->
**What would you like to be added**:
**Why is this needed**:

View File

@@ -1,39 +0,0 @@
---
name: '@grafana/ui component request'
about: Suggest a component for the @grafana/ui package
labels: 'area/grafana/ui'
---
<!--
By using this template you will make it easier for us to make sure that documentation and implementation stays up to date for every component in @grafana/ui
Thank you!
-->
**Why is this component needed**:
<!-- Explain your use case -->
___
- [ ] Is/could it be used in more than one place in Grafana?
**Where is/could it be used?**:
___
- [ ] Post screenshots possible.
- [ ] It has a single use case.
- [ ] It is/could be used in multiple places.
**Implementation** (Checklist meant for the person implementing the component)
- [ ] Component has a story in Storybook.
- [ ] Props and naming follows [our style guide](https://github.com/grafana/grafana/blob/main/contribute/style-guides/frontend.md).
- [ ] It is extendable (rest props are spread, styles with className work, and so on).
- [ ] Uses [theme for spacing, colors, and so on](https://github.com/grafana/grafana/blob/main/contribute/style-guides/themes.md).
- [ ] Works with both light and dark theme.
**Documentation**
- [ ] Properties are documented.
- [ ] Use cases are described.
- [ ] Code examples for the different use cases.
- [ ] Dos and don'ts.
- [ ] Styling guidelines, specific color usage (if applicable).

View File

@@ -0,0 +1,39 @@
---
name: '@grafana/ui component request'
about: Suggest a component for the @grafana/ui package
labels: 'area/grafana/ui'
---
<!--
By using this template you will make it easier for us to make sure that documentation and implementation stays up to date for every component in @grafana/ui
Thank you!
-->
**Why is this component needed**:
<!-- Explain your use case -->
___
- [ ] Is/could it be used in more than one place in Grafana?
**Where is/could it be used?**:
___
- [ ] Post screenshots possible.
- [ ] It has a single use case.
- [ ] It is/could be used in multiple places.
**Implementation** (Checklist meant for the person implementing the component)
- [ ] Component has a story in Storybook.
- [ ] Props and naming follows [our style guide](https://github.com/grafana/grafana/blob/master/contribute/style-guides/frontend.md).
- [ ] It is extendable (rest props are spread, styles with className work, and so on).
- [ ] Uses [theme for spacing, colors, and so on](https://github.com/grafana/grafana/blob/master/contribute/style-guides/themes.md).
- [ ] Works with both light and dark theme.
**Documentation**
- [ ] Properties are documented.
- [ ] Use cases are described.
- [ ] Code examples for the different use cases.
- [ ] Dos and don'ts.
- [ ] Styling guidelines, specific color usage (if applicable).

View File

@@ -1,8 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Feature Request
url: https://github.com/grafana/grafana/discussions/new
about: Discuss ideas for new features of changes
- name: Questions & Help
url: https://community.grafana.com
about: Please ask and answer questions here.

View File

@@ -2,7 +2,7 @@
Thank you for sending a pull request! Here are some tips:
1. If this is your first time, please read our contribution guide at https://github.com/grafana/grafana/blob/main/CONTRIBUTING.md
1. If this is your first time, please read our contribution guide at https://github.com/grafana/grafana/blob/master/CONTRIBUTING.md
2. Ensure you include and run the appropriate tests as part of your Pull Request.
@@ -10,7 +10,7 @@ Thank you for sending a pull request! Here are some tips:
4. If the Pull Request is a work in progress, make use of GitHub's "Draft PR" feature and mark it as such.
5. If you can not merge your Pull Request due to a merge conflict, Rebase it. This gets it in sync with the main branch.
5. If you can not merge your Pull Request due to a merge conflict, Rebase it. This gets it in sync with the master branch.
6. Name your PR as "<FeatureArea>: Describe your change", e.g. Alerting: Prevent race condition. If it's a fix or feature relevant for the changelog describe the user impact in the title. The PR title is used to auto-generate the changelog for issues marked with the "add to changelog" label.

4
.github/bot.md vendored
View File

@@ -1,6 +1,6 @@
# GitHub & grafanabot automation
The bot is configured via [commands.json](https://github.com/grafana/grafana/blob/main/.github/commands.json) and some other GitHub workflows [workflows](https://github.com/grafana/grafana/tree/main/.github/workflows).
The bot is configured via [commands.json](https://github.com/grafana/grafana/blob/master/.github/commands.json) and some other GitHub workflows [workflows](https://github.com/grafana/grafana/tree/master/.github/workflows).
Comment commands:
@@ -17,7 +17,7 @@ Label commands:
## Metrics
Metrics are configured in [metrics-collector.json](https://github.com/grafana/grafana/blob/main/.github/metrics-collector.json) and are also defined in the
Metrics are configured in [metrics-collector.json](https://github.com/grafana/grafana/blob/master/.github/metrics-collector.json) and are also defined in the
[metrics-collector](https://github.com/grafana/grafana-github-actions/blob/main/metrics-collector/index.ts) GitHub action.
## Backport PR

View File

@@ -5,7 +5,7 @@
"addLabel": "type/question",
"removeLabel": "bot/question",
"action": "close",
"comment": "Please ask your question on [community.grafana.com/](https://community.grafana.com/). To avoid having your issue closed in the future, please read our [CONTRIBUTING](https://github.com/grafana/grafana/blob/main/CONTRIBUTING.md) guidelines.\n\nHappy graphing!"
"comment": "Please ask your question on [community.grafana.com/](https://community.grafana.com/). To avoid having your issue closed in the future, please read our [CONTRIBUTING](https://github.com/grafana/grafana/blob/master/CONTRIBUTING.md) guidelines.\n\nHappy graphing!"
},
{
"type": "comment",
@@ -20,7 +20,7 @@
"addLabel": "type/duplicate",
"removeLabel": "bot/duplicate",
"action": "close",
"comment": "Thanks for creating this issue! It looks like this has already been reported by another user. Weve closed this in favor of the existing one. Please consider adding any details you think is missing to that issue.\n\nTo avoid having your issue closed in the future, please read our [CONTRIBUTING](https://github.com/grafana/grafana/blob/main/CONTRIBUTING.md) guidelines.\n\nHappy graphing!"
"comment": "Thanks for creating this issue! It looks like this has already been reported by another user. Weve closed this in favor of the existing one. Please consider adding any details you think is missing to that issue.\n\nTo avoid having your issue closed in the future, please read our [CONTRIBUTING](https://github.com/grafana/grafana/blob/master/CONTRIBUTING.md) guidelines.\n\nHappy graphing!"
},
{
"type": "comment",
@@ -35,13 +35,13 @@
"action": "updateLabels",
"addLabel": "needs more info",
"removeLabel": "bot/needs more info",
"comment": "Thanks for creating this issue! We think it's missing some basic information. \r\n\r\nFollow the issue template and add additional information that will help us replicate the problem. \r\nFor data visualization issues: \r\n- Query results from the inspect drawer (data tab & query inspector)\r\n- Panel settings can be extracted in the panel inspect drawer JSON tab\r\n\r\nFor dashboard related issues: \r\n- Dashboard JSON can be found in the dashboard settings JSON model view\r\n\r\nFor authentication, provisioning and alerting issues, Grafana server logs are useful. \r\n\r\nHappy graphing!"
"comment": "Thanks for creating this issue! We think it's missing some basic information. \r\n\r\nFollow the issue template and add additional information that will help us replicate the problem. \r\nFor data visualization issues: \r\n- Query results from the inspect drawer (data tab & query inspector)\r\n- Panel settings can be extracted in the panel inspect drawer JSON tab\r\n\r\nFor dashboard related issues: \r\n- Dashboard JSON can be found in the dashboard settings JSON model view\r\n\r\nFor authentication and alerting issues, Grafana server logs are useful. \r\n\r\nHappy graphing!"
},
{
"type": "label",
"name": "bot/no new info",
"action": "close",
"comment": "We've closed this issue since it needs more information and hasn't had any activity recently. We can re-open it after you you add more information. To avoid having your issue closed in the future, please read our [CONTRIBUTING](https://github.com/grafana/grafana/blob/main/CONTRIBUTING.md) guidelines.\n\nHappy graphing!"
"comment": "We've closed this issue since it needs more information and hasn't had any activity recently. We can re-open it after you you add more information. To avoid having your issue closed in the future, please read our [CONTRIBUTING](https://github.com/grafana/grafana/blob/master/CONTRIBUTING.md) guidelines.\n\nHappy graphing!"
},
{
"type": "label",

View File

@@ -1,189 +0,0 @@
[
{
"type": "changedfiles",
"matches": [
"docs/**/*",
"contribute/**/*"
],
"action": "updateLabel",
"addLabel": "type/docs"
},
{
"type": "changedfiles",
"matches": [
"public/**/*",
"packages/**/*",
"e2e/**/*",
"plugins-bundled/**/*",
"scripts/build/release-packages.sh",
"scripts/circle-release-next-packages.sh",
"scripts/ci-frontend-metrics.sh",
"scripts/grunt/**/*",
"scripts/webpack/**/*",
"package.json",
"tsconfig.json",
"lerna.json",
".babelrc",
".prettierrc.js",
".eslintrc",
"**/*.mdx"
],
"action": "updateLabel",
"addLabel": "area/frontend"
},
{
"type": "changedfiles",
"matches": [
"**/*.go",
"go.mod",
"go.sum",
"contribute/style-guides/backend.md",
"contribute/architecture/backend/**/*",
"scripts/go/**/*"
],
"action": "updateLabel",
"addLabel": "area/backend"
},
{
"type": "changedfiles",
"matches": [
"pkg/services/sqlstore/migrations/**/*",
"**/*_mig.go"
],
"action": "updateLabel",
"addLabel": "area/backend/db/migration"
},
{
"type": "changedfiles",
"matches": [ "public/app/features/explore/**/*"],
"action": "updateLabel",
"addLabel": "area/explore"
},
{
"type": "changedfiles",
"matches": [
".circleci/**/*",
"packaging/**/*",
"scripts/build/**/*",
"scripts/*.sh",
"Makefile",
"Dockerfile",
"Dockerfile.ubuntu"
],
"action": "updateLabel",
"addLabel": "type/build-packaging"
},
{
"type": "changedfiles",
"matches": [
"scripts/*.star",
".drone.star",
".drone.yml"
],
"action": "updateLabel",
"addLabel": "type/ci"
},
{
"type": "changedfiles",
"matches": [ "public/app/plugins/datasource/grafana-azure-monitor-datasource/**/*", "pkg/tsdb/azuremonitor/**/*"],
"action": "updateLabel",
"addLabel": "datasource/Azure"
},
{
"type": "changedfiles",
"matches": [ "public/app/plugins/datasource/cloud-monitoring/**/*", "pkg/tsdb/cloudmonitoring/**/*"],
"action": "updateLabel",
"addLabel": "datasource/GoogleCloudMonitoring"
},
{
"type": "changedfiles",
"matches": [ "public/app/plugins/datasource/cloudwatch/**/*", "pkg/tsdb/cloudwatch/**/*"],
"action": "updateLabel",
"addLabel": "datasource/CloudWatch"
},
{
"type": "changedfiles",
"matches": [ "public/app/plugins/datasource/elasticsearch/**/*", "pkg/tsdb/elasticsearch/**/*"],
"action": "updateLabel",
"addLabel": "datasource/Elasticsearch"
},
{
"type": "changedfiles",
"matches": [ "public/app/plugins/datasource/graphite/**/*", "pkg/tsdb/graphite/**/*"],
"action": "updateLabel",
"addLabel": "datasource/Graphite"
},
{
"type": "changedfiles",
"matches": [ "public/app/plugins/datasource/influxdb/**/*", "pkg/tsdb/influx/**/*"],
"action": "updateLabel",
"addLabel": "datasource/InfluxDB"
},
{
"type": "changedfiles",
"matches": [ "public/app/plugins/datasource/jaeger"],
"action": "updateLabel",
"addLabel": "datasource/Jaeger"
},
{
"type": "changedfiles",
"matches": [ "public/app/plugins/datasource/loki/**/*", "pkg/tsdb/loki/**/*"],
"action": "updateLabel",
"addLabel": "datasource/Loki"
},
{
"type": "changedfiles",
"matches": [ "public/app/plugins/datasource/mssql/**/*", "pkg/tsdb/mssql/**/*"],
"action": "updateLabel",
"addLabel": "datasource/MSSQL"
},
{
"type": "changedfiles",
"matches": [ "public/app/plugins/datasource/mysql/**/*", "pkg/tsdb/mysql/**/*"],
"action": "updateLabel",
"addLabel": "datasource/MySQL"
},
{
"type": "changedfiles",
"matches": [ "public/app/plugins/datasource/opentsdb/**/*", "pkg/tsdb/opentsdb/**/*"],
"action": "updateLabel",
"addLabel": "datasource/OpenTSDB"
},
{
"type": "changedfiles",
"matches": [ "public/app/plugins/datasource/postgres/**/*", "pkg/tsdb/postgres/**/*"],
"action": "updateLabel",
"addLabel": "datasource/Postgres"
},
{
"type": "changedfiles",
"matches": [ "public/app/plugins/datasource/prometheus/**/*", "pkg/tsdb/prometheus/**/*"],
"action": "updateLabel",
"addLabel": "datasource/Prometheus"
},
{
"type": "changedfiles",
"matches": [ "public/app/plugins/datasource/tempo/**/*", "pkg/tsdb/tempo/**/*"],
"action": "updateLabel",
"addLabel": "datasource/Tempo"
},
{
"type": "changedfiles",
"matches": [ "public/app/plugins/datasource/zipkin/**/*"],
"action": "updateLabel",
"addLabel": "datasource/Zipkin"
},
{
"type": "changedfiles",
"matches": ["public/app/features/variables/**/*", "public/app/features/templating/**/*"],
"action": "updateLabel",
"addLabel": "area/dashboard/templating"
},
{
"type": "author",
"name": "pr/external",
"notMemberOf": { "org": "grafana" },
"action": "updateLabel",
"addLabel": "pr/external"
}
]

View File

@@ -9,51 +9,13 @@ jobs:
main:
runs-on: ubuntu-latest
steps:
# This is a basic workflow to help you get started with Actions
- uses: actions-ecosystem/action-regex-match@v2
id: regex-match
with:
text: ${{ github.event.inputs.version }}
regex: '^(\d+.\d+).\d+(?:-beta.\d+)?$'
- name: Validate input version
if: ${{ steps.regex-match.outputs.match == '' }}
run: |
echo "The input version format is not correct, please respect:\
major.minor.patch or major.minor.patch-beta.number format. \
example: 7.4.3 or 7.4.3-beta.1"
exit 1
- uses: actions/checkout@v2
- name: Set intermedia variables
id: intermedia
run: |
echo "::set-output name=short_ref::${GITHUB_REF#refs/*/}"
echo "::set-output name=check_passed::false"
echo "::set-output name=branch_name::v${{steps.regex-match.outputs.group1}}"
echo "::set-output name=branch_exist::$(git ls-remote --heads https://github.com/grafana/grafana.git v${{ steps.regex-match.outputs.group1 }}.x | wc -l)"
- name: Check input version is aligned with branch(not main)
if: steps.intermedia.outputs.branch_exist != '0' && !contains(steps.intermedia.outputs.short_ref, steps.intermedia.outputs.branch_name)
run: |
echo " You need to run the workflow on branch v${{steps.regex-match.outputs.group1}}.x
exit 1
- name: Check input version is aligned with branch(main)
if: steps.intermedia.outputs.branch_exist == '0' && !contains(steps.intermedia.outputs.short_ref, 'main')
run: |
echo "When you want to deliver a new new minor version, you might want to create a new branch first \
with naming convention v[major].[minor].x, and just run the workflow on that branch. \
Run the workflow on main only when needed"
exit 1
- name: Checkout Actions
uses: actions/checkout@v2
with:
repository: "grafana/grafana-github-actions"
path: ./actions
ref: main
- uses: actions/setup-node@v2.1.5
- uses: actions/setup-node@v2.1.4
with:
node-version: '14'
- name: Install Actions

View File

@@ -7,10 +7,10 @@ name: "CodeQL"
on:
push:
branches: [main, v1.8.x, v2.0.x, v2.1.x, v2.6.x, v3.0.x, v3.1.x, v4.0.x, v4.1.x, v4.2.x, v4.3.x, v4.4.x, v4.5.x, v4.6.x, v4.7.x, v5.0.x, v5.1.x, v5.2.x, v5.3.x, v5.4.x, v6.0.x, v6.1.x, v6.2.x, v6.3.x, v6.4.x, v6.5.x, v6.6.x, v6.7.x, v7.0.x, v7.1.x, v7.2.x]
branches: [master, v1.8.x, v2.0.x, v2.1.x, v2.6.x, v3.0.x, v3.1.x, v4.0.x, v4.1.x, v4.2.x, v4.3.x, v4.4.x, v4.5.x, v4.6.x, v4.7.x, v5.0.x, v5.1.x, v5.2.x, v5.3.x, v5.4.x, v6.0.x, v6.1.x, v6.2.x, v6.3.x, v6.4.x, v6.5.x, v6.6.x, v6.7.x, v7.0.x, v7.1.x, v7.2.x]
pull_request:
# The branches below must be a subset of the branches above
branches: [main]
branches: [master]
schedule:
- cron: '0 4 * * 6'
@@ -36,13 +36,18 @@ jobs:
# a pull request then we can checkout the head.
fetch-depth: 2
# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

View File

@@ -1,25 +0,0 @@
name: PR automation
on:
pull_request_target:
types:
- opened
- synchronize
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Checkout Actions
uses: actions/checkout@v2
with:
repository: "grafana/grafana-github-actions"
path: ./actions
ref: main
- name: Install Actions
run: npm install --production --prefix ./actions
- name: Run Commands
uses: ./actions/commands
with:
metricsWriteAPIKey: ${{secrets.GRAFANA_MISC_STATS_API_KEY}}
token: ${{secrets.GH_BOT_ACCESS_TOKEN}}
configPath: pr-commands

View File

@@ -3,7 +3,7 @@ name: publish_docs
on:
push:
branches:
- main
- master
paths:
- 'docs/sources/**'
- 'packages/grafana-*/**'
@@ -16,12 +16,12 @@ jobs:
steps:
- uses: actions/checkout@v1
- run: git clone --single-branch --no-tags --depth 1 -b master https://grafanabot:${{ secrets.GH_BOT_ACCESS_TOKEN }}@github.com/grafana/website-sync ./.github/actions/website-sync
- uses: actions/cache@v2.1.6
- uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: generate-packages-docs
uses: actions/setup-node@v2.1.5
uses: actions/setup-node@v2.1.4
id: generate-docs
with:
node-version: '14'
@@ -36,7 +36,7 @@ jobs:
host: github.com
github_pat: '${{ secrets.GH_BOT_ACCESS_TOKEN }}'
source_folder: docs/sources
target_folder: content/docs/grafana/next
target_folder: content/docs/grafana/latest
allow_no_changes: 'true'
- shell: bash
run: |

11
.gitignore vendored
View File

@@ -15,8 +15,6 @@ awsconfig
.yarnrc
.yarn/
vendor/
/docs/menu.yaml
/requests
# Enterprise emails
/emails/templates/enterprise_*
@@ -50,7 +48,6 @@ public/css/*.min.css
*.tmp
.DS_Store
.vscode/
!.vscode/launch.json
.vs/
.eslintcache
@@ -75,7 +72,6 @@ profile.cov
/pkg/cmd/grafana-server/grafana-server
/pkg/cmd/grafana-server/debug
/pkg/extensions/*
/pkg/server/wireexts_enterprise.go
!/pkg/extensions/main.go
/public/app/extensions
debug.test
@@ -123,15 +119,8 @@ compilation-stats.json
!/e2e/**/screenshots/expected/*
/e2e/**/videos/*
# a11y tests
/pa11y-ci-results.json
/pa11y-ci-report
# report dumping the whole system env
/report.*.json
# auto generated frontend docs
/docs/sources/packages_api
# auto generated Go files
*_gen.go

View File

@@ -1,96 +0,0 @@
var config = {
defaults: {
concurrency: 1,
runners: ['axe'],
chromeLaunchConfig: {
args: ['--no-sandbox'],
},
},
urls: [
{
url: '${HOST}/login',
actions: [
"set field input[name='user'] to admin",
"set field input[name='password'] to admin",
"click element button[aria-label='Login button']",
"wait for element [aria-label='Skip change password button'] to be visible",
],
threshold: 3,
},
{
url: '${HOST}/?orgId=1',
threshold: 7,
},
{
url: '${HOST}/d/O6f11TZWk/panel-tests-bar-gauge',
hideElements: '.sidemenu',
threshold: 2,
},
{
url: '${HOST}/d/O6f11TZWk/panel-tests-bar-gauge?orgId=1&editview=settings',
rootElement: '.dashboard-settings',
threshold: 10,
},
{
url: '${HOST}/?orgId=1&search=open',
rootElement: '.main-view',
threshold: 15,
},
{
url: '${HOST}/alerting/list',
rootElement: '.main-view',
threshold: 7,
},
{
url: '${HOST}/datasources',
rootElement: '.main-view',
threshold: 36,
},
{
url: '${HOST}/org/users',
rootElement: '.main-view',
threshold: 4,
},
{
url: '${HOST}/org/teams',
rootElement: '.main-view',
threshold: 1,
},
{
url: '${HOST}/plugins',
rootElement: '.main-view',
threshold: 41,
},
{
url: '${HOST}/org',
rootElement: '.main-view',
threshold: 2,
},
{
url: '${HOST}/org/apikeys',
rootElement: '.main-view',
threshold: 5,
},
{
url: '${HOST}/dashboards',
rootElement: '.main-view',
threshold: 8,
},
],
};
function myPa11yCiConfiguration(urls, defaults) {
const HOST_SERVER = process.env.HOST || 'localhost';
const PORT_SERVER = process.env.PORT || '3000';
for (var idx = 0; idx < urls.length; idx++) {
urls[idx] = { ...urls[idx], url: urls[idx].url.replace('${HOST}', `${HOST_SERVER}:${PORT_SERVER}`) };
}
return {
defaults: defaults,
urls: urls,
};
}
module.exports = myPa11yCiConfiguration(config.urls, config.defaults);

View File

@@ -1,83 +0,0 @@
var config = {
defaults: {
concurrency: 1,
runners: ['axe'],
chromeLaunchConfig: {
args: ['--no-sandbox'],
},
},
urls: [
{
url: '${HOST}/login',
actions: [
"set field input[name='user'] to admin",
"set field input[name='password'] to admin",
"click element button[aria-label='Login button']",
"wait for element [aria-label='Skip change password button'] to be visible",
],
},
{
url: '${HOST}/?orgId=1',
},
{
url: '${HOST}/d/O6f11TZWk/panel-tests-bar-gauge',
hideElements: '.sidemenu',
},
{
url: '${HOST}/d/O6f11TZWk/panel-tests-bar-gauge?orgId=1&editview=settings',
rootElement: '.dashboard-settings',
},
{
url: '${HOST}/?orgId=1&search=open',
rootElement: '.main-view',
},
{
url: '${HOST}/alerting/list',
rootElement: '.main-view',
},
{
url: '${HOST}/datasources',
rootElement: '.main-view',
},
{
url: '${HOST}/org/users',
rootElement: '.main-view',
},
{
url: '${HOST}/org/teams',
rootElement: '.main-view',
},
{
url: '${HOST}/plugins',
rootElement: '.main-view',
},
{
url: '${HOST}/org',
rootElement: '.main-view',
},
{
url: '${HOST}/org/apikeys',
rootElement: '.main-view',
},
{
url: '${HOST}/dashboards',
rootElement: '.main-view',
},
],
};
function myPa11yCiConfiguration(urls, defaults) {
const HOST_SERVER = process.env.HOST || 'localhost';
const PORT_SERVER = process.env.PORT || '3000';
for (var idx = 0; idx < urls.length; idx++) {
urls[idx] = { ...urls[idx], url: urls[idx].url.replace('${HOST}', `${HOST_SERVER}:${PORT_SERVER}`) };
}
return {
defaults: defaults,
urls: urls,
};
}
module.exports = myPa11yCiConfiguration(config.urls, config.defaults);

View File

@@ -5,9 +5,5 @@ pkg/
node_modules
public/vendor/
vendor/
/data/
data/
e2e/tmp
public/build/
public/sass/*.generated.scss
devenv/
public/lib/monaco

14
.vscode/launch.json vendored
View File

@@ -1,14 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Server",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/pkg/cmd/grafana-server/",
"env": {},
"args": ["--homepath", "${workspaceFolder}", "--packaging", "dev"]
}
]
}

File diff suppressed because it is too large Load Diff

View File

@@ -26,12 +26,10 @@ Report a bug by submitting a [bug report](https://github.com/grafana/grafana/iss
Follow the issue template and add additional information that will help us replicate the problem.
For data visualization issues:
- Query results from the inspect drawer (data tab & query inspector)
- Panel settings can be extracted in the panel inspect drawer JSON tab
For a dashboard related issues:
- Dashboard JSON can be found in the dashboard settings JSON model view
For authentication and alerting Grafana server logs are useful.
@@ -42,7 +40,7 @@ If you believe you've found a security vulnerability, please read our [security
### Suggest enhancements
If you have an idea of how to improve Grafana, submit an [enhancement request](https://github.com/grafana/grafana/discussions/new).
If you have an idea of how to improve Grafana, submit an [enhancement request](https://github.com/grafana/grafana/issues/new?labels=type%3A+feature+request&template=2-feature_request.md).
We want to make Grafana accessible to even more people. Submit an [accessibility issue](https://github.com/grafana/grafana/issues/new?labels=type%3A+accessibility&template=3-accessibility.md) to help us understand what we can improve.
@@ -78,4 +76,4 @@ Before we can accept your pull request, you need to [sign our CLA](https://grafa
- Set up your [development environment](contribute/developer-guide.md).
- Learn how to [contribute documentation](contribute/documentation.md).
- Get started [developing plugins](https://grafana.com/docs/grafana/latest/developers/plugins/) for Grafana.
- Look through the resources in the [contribute](https://github.com/grafana/grafana/tree/main/contribute) folder.
- Look through the resources in the [contribute](https://github.com/grafana/grafana/tree/master/contribute) folder.

View File

@@ -1,11 +1,10 @@
FROM node:16-alpine3.14 as js-builder
FROM node:14.15.1-alpine3.12 as js-builder
WORKDIR /usr/src/app/
COPY package.json yarn.lock ./
COPY packages packages
RUN apk --no-cache add git
RUN yarn install --pure-lockfile --no-progress
COPY tsconfig.json .eslintrc .editorconfig .browserslistrc .prettierrc.js ./
@@ -17,25 +16,23 @@ COPY emails emails
ENV NODE_ENV production
RUN yarn build
FROM golang:1.17.0-alpine3.14 as go-builder
FROM golang:1.15.1-alpine3.12 as go-builder
RUN apk add --no-cache gcc g++
WORKDIR $GOPATH/src/github.com/grafana/grafana
COPY go.mod go.sum embed.go ./
COPY cue cue
COPY cue.mod cue.mod
COPY packages/grafana-schema packages/grafana-schema
COPY public/app/plugins public/app/plugins
COPY go.mod go.sum ./
RUN go mod verify
COPY pkg pkg
COPY build.go package.json ./
RUN go mod verify
RUN go run build.go build
# Final stage
FROM alpine:3.14.2
FROM alpine:3.12
LABEL maintainer="Grafana team <hello@grafana.com>"
@@ -68,7 +65,6 @@ RUN export GF_GID_NAME=$(getent group $GF_GID | cut -d':' -f1) && \
"$GF_PATHS_PROVISIONING/dashboards" \
"$GF_PATHS_PROVISIONING/notifiers" \
"$GF_PATHS_PROVISIONING/plugins" \
"$GF_PATHS_PROVISIONING/access-control" \
"$GF_PATHS_LOGS" \
"$GF_PATHS_PLUGINS" \
"$GF_PATHS_DATA" && \
@@ -77,7 +73,7 @@ RUN export GF_GID_NAME=$(getent group $GF_GID | cut -d':' -f1) && \
chown -R "grafana:$GF_GID_NAME" "$GF_PATHS_DATA" "$GF_PATHS_HOME/.aws" "$GF_PATHS_LOGS" "$GF_PATHS_PLUGINS" "$GF_PATHS_PROVISIONING" && \
chmod -R 777 "$GF_PATHS_DATA" "$GF_PATHS_HOME/.aws" "$GF_PATHS_LOGS" "$GF_PATHS_PLUGINS" "$GF_PATHS_PROVISIONING"
COPY --from=go-builder /go/src/github.com/grafana/grafana/bin/*/grafana-server /go/src/github.com/grafana/grafana/bin/*/grafana-cli ./bin/
COPY --from=go-builder /go/src/github.com/grafana/grafana/bin/linux-amd64/grafana-server /go/src/github.com/grafana/grafana/bin/linux-amd64/grafana-cli ./bin/
COPY --from=js-builder /usr/src/app/public ./public
COPY --from=js-builder /usr/src/app/tools ./tools

View File

@@ -5,7 +5,6 @@ WORKDIR /usr/src/app/
COPY package.json yarn.lock ./
COPY packages packages
RUN apt-get update && apt-get install -yq git
RUN yarn install --pure-lockfile
COPY tsconfig.json .eslintrc .editorconfig .browserslistrc .prettierrc.js ./
@@ -17,19 +16,17 @@ COPY emails emails
ENV NODE_ENV production
RUN yarn build
FROM golang:1.17.0 AS go-builder
FROM golang:1.15.1 AS go-builder
WORKDIR /src/grafana
COPY go.mod go.sum embed.go ./
COPY build.go package.json ./
COPY pkg pkg/
COPY cue cue/
COPY cue.mod cue.mod/
COPY packages/grafana-schema packages/grafana-schema/
COPY public/app/plugins public/app/plugins/
COPY go.mod go.sum ./
RUN go mod verify
COPY build.go package.json ./
COPY pkg pkg/
RUN go run build.go build
FROM ubuntu:20.04
@@ -62,7 +59,6 @@ RUN mkdir -p "$GF_PATHS_HOME/.aws" && \
"$GF_PATHS_PROVISIONING/dashboards" \
"$GF_PATHS_PROVISIONING/notifiers" \
"$GF_PATHS_PROVISIONING/plugins" \
"$GF_PATHS_PROVISIONING/access-control" \
"$GF_PATHS_LOGS" \
"$GF_PATHS_PLUGINS" \
"$GF_PATHS_DATA" && \
@@ -71,7 +67,7 @@ RUN mkdir -p "$GF_PATHS_HOME/.aws" && \
chown -R grafana:grafana "$GF_PATHS_DATA" "$GF_PATHS_HOME/.aws" "$GF_PATHS_LOGS" "$GF_PATHS_PLUGINS" "$GF_PATHS_PROVISIONING" && \
chmod -R 777 "$GF_PATHS_DATA" "$GF_PATHS_HOME/.aws" "$GF_PATHS_LOGS" "$GF_PATHS_PLUGINS" "$GF_PATHS_PROVISIONING"
COPY --from=go-builder /src/grafana/bin/*/grafana-server /src/grafana/bin/*/grafana-cli bin/
COPY --from=go-builder /src/grafana/bin/linux-amd64/grafana-server /src/grafana/bin/linux-amd64/grafana-cli bin/
COPY --from=js-builder /usr/src/app/public public
COPY --from=js-builder /usr/src/app/tools tools

View File

@@ -78,7 +78,6 @@ The current team members are:
- Diana Sarlinska ([Grafana Labs](https://grafana.com/))
- Dominik Prokop ([Grafana Labs](https://grafana.com/))
- Emil Tullstedt ([Grafana Labs](https://grafana.com/))
- Erik Sundell ([Grafana Labs](https://grafana.com/))
- Fredrik Enestad ([Soundtrack Your Brand](https://www.soundtrackyourbrand.com/))
- Hugo Häggmark ([Grafana Labs](https://grafana.com/))
- Ivana Huckova ([Grafana Labs](https://grafana.com/))
@@ -103,8 +102,6 @@ The current team members are:
- Tobias Skarhed ([Grafana Labs](https://grafana.com/))
- Torkel Ödegaard ([Grafana Labs](https://grafana.com/))
- Utkarsh Bhatnagar ([Tinder](https://www.tinder.com/))
- Will Browne ([Grafana Labs](https://grafana.com/))
- Zoltán Bedi ([Grafana Labs](https://grafana.com/))
### Maintainers
@@ -201,8 +198,8 @@ The ex-member is
If needed, we reserve the right to publicly announce removal.
[coc]: https://github.com/grafana/grafana/blob/main/CODE_OF_CONDUCT.md
[coc]: https://github.com/grafana/grafana/blob/master/CODE_OF_CONDUCT.md
[devs]: https://groups.google.com/forum/#!forum/grafana-developers
[maintainers]: https://github.com/grafana/grafana/blob/main/MAINTAINERS.md
[maintainers]: https://github.com/grafana/grafana/blob/master/MAINTAINERS.md
[rough]: https://tools.ietf.org/html/rfc7282
[team]: https://groups.google.com/forum/#!forum/grafana-team

View File

@@ -301,12 +301,12 @@ Even if you don't have the time or knowledge to investigate an issue we highly r
## Automation
We have some automation that triggers on comments or labels being added to issues. Many of these automated behaviors are defined in [commands.json](https://github.com/grafana/grafana/blob/main/.github/commands.json). Or in other [GitHub Actions](https://github.com/grafana/grafana/tree/main/.github/workflows)
We have some automation that triggers on comments or labels being added to issues. Many of these automated behaviors are defined in [commands.json](https://github.com/grafana/grafana/blob/master/.github/commands.json). Or in other [GitHub Actions](https://github.com/grafana/grafana/tree/master/.github/workflows)
* Add /duplicate `#<issue number>` to have Grafana label & close issue with an appropriate message.
* Add `bot/question` and the bot will close it with an appropriate message.
[Read more on bot actions](https://github.com/grafana/grafana/blob/main/.github/bot.md)
[Read more on bot actions](https://github.com/grafana/grafana/blob/master/.github/bot.md)
## External PRs

863
LICENSE
View File

@@ -1,661 +1,202 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<https://www.gnu.org/licenses/>.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2015 Grafana Labs
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -1,28 +0,0 @@
# Licensing
License names used in this document are as per [SPDX License List](https://spdx.org/licenses/).
The default license for this project is [AGPL-3.0-only](LICENSE).
## Apache-2.0
The following directories and their subdirectories are licensed under Apache-2.0:
```
packages/grafana-data/
packages/grafana-e2e/
packages/grafana-e2e-selectors/
packages/grafana-runtime/
packages/grafana-toolkit/
packages/grafana-ui/
packages/jaeger-ui-components/
packaging/
grafana-mixin/
cue/
```
The following directories and their subdirectories are the original upstream licenses:
```
public/vendor/
```

View File

@@ -2,14 +2,11 @@
##
## For more information, refer to https://suva.sh/posts/well-documented-makefiles/
WIRE_TAGS = "oss"
-include local/Makefile
include .bingo/Variables.mk
.PHONY: all deps-go deps-js deps build-go build-server build-cli build-js build build-docker-dev build-docker-full lint-go golangci-lint test-go test-js test run run-frontend clean devenv devenv-down protobuf drone help
.PHONY: all deps-go deps-js deps build-go build-server build-cli build-js build build-docker-dev build-docker-full lint-go revive golangci-lint tidy-check test-go test-js test run run-frontend clean devenv devenv-down revive-strict protobuf help
GO = go
GO = GO111MODULE=on go
GO_FILES ?= ./pkg/...
SH_FILES ?= $(shell find ./scripts -name *.sh)
@@ -30,11 +27,7 @@ node_modules: package.json yarn.lock ## Install node modules.
##@ Building
gen-go: $(WIRE)
@echo "generate go files"
$(WIRE) gen -tags $(WIRE_TAGS) ./pkg/server
build-go: gen-go ## Build all Go binaries.
build-go: ## Build all Go binaries.
@echo "build go files"
$(GO) run build.go build
@@ -43,7 +36,7 @@ build-server: ## Build Grafana server.
$(GO) run build.go build-server
build-cli: ## Build Grafana CLI application.
@echo "build grafana-cli"
@echo "build in CI environment"
$(GO) run build.go build-cli
build-js: ## Build frontend assets.
@@ -58,7 +51,7 @@ scripts/go/bin/bra: scripts/go/go.mod
$(GO) build -o ./bin/bra github.com/unknwon/bra
run: scripts/go/bin/bra ## Build and run web server on filesystem changes.
@scripts/go/bin/bra run
@GO111MODULE=on scripts/go/bin/bra run
run-frontend: deps-js ## Fetch js dependencies and watch frontend for rebuild
yarn start
@@ -76,6 +69,22 @@ test-js: ## Run tests for frontend.
test: test-go test-js ## Run all tests.
##@ Linting
scripts/go/bin/revive: scripts/go/go.mod
@cd scripts/go; \
$(GO) build -o ./bin/revive github.com/mgechev/revive
revive: scripts/go/bin/revive
@echo "lint via revive"
@scripts/go/bin/revive \
-formatter stylish \
-config ./scripts/go/configs/revive.toml \
$(GO_FILES)
revive-strict: scripts/go/bin/revive
@echo "lint via revive (strict)"
@scripts/revive-strict scripts/go/bin/revive
scripts/go/bin/golangci-lint: scripts/go/go.mod
@cd scripts/go; \
$(GO) build -o ./bin/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint
@@ -86,7 +95,11 @@ golangci-lint: scripts/go/bin/golangci-lint
--config ./scripts/go/configs/.golangci.toml \
$(GO_FILES)
lint-go: golangci-lint # Run all code checks for backend.
tidy-check:
@echo "check whether go.mod and go.sum are consistent"
@scripts/tidy-check.sh
lint-go: golangci-lint revive revive-strict tidy-check # Run all code checks for backend.
# with disabled SC1071 we are ignored some TCL,Expect `/usr/bin/env expect` scripts
shellcheck: $(SH_FILES) ## Run checks for shell scripts.
@@ -98,7 +111,7 @@ shellcheck: $(SH_FILES) ## Run checks for shell scripts.
build-docker-dev: ## Build Docker image for development (fast).
@echo "build development container"
@echo "\033[92mInfo:\033[0m the frontend code is expected to be built already."
$(GO) run build.go -goos linux -pkg-arch amd64 ${OPT} build latest
$(GO) run build.go -goos linux -pkg-arch amd64 ${OPT} build pkg-archive latest
cp dist/grafana-latest.linux-x64.tar.gz packaging/docker
cd packaging/docker && docker build --tag grafana/grafana:dev .
@@ -147,13 +160,5 @@ clean: ## Clean up intermediate build artifacts.
rm -rf node_modules
rm -rf public/build
# This repository's configuration is protected (https://readme.drone.io/signature/).
# Use this make target to regenerate the configuration YAML files when
# you modify starlark files.
drone:
drone starlark
drone lint
drone --server https://drone.grafana.net sign --save grafana/grafana
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

View File

@@ -17,7 +17,7 @@ for built-in plugins and everything internal. External plugins still use systemj
set of Grafana components they can import. Plugins can depend on libs like lodash & moment and internal components
like before using the same import paths. However since everything in Grafana is no longer accessible, a few plugins could encounter issues when importing a Grafana dependency.
[List of exposed components plugins can import/require](https://github.com/grafana/grafana/blob/main/public/app/features/plugins/plugin_loader.ts#L48)
[List of exposed components plugins can import/require](https://github.com/grafana/grafana/blob/master/public/app/features/plugins/plugin_loader.ts#L48)
If you think we missed exposing a crucial lib or Grafana component let us know by opening an issue.

View File

@@ -3,7 +3,7 @@
The open-source platform for monitoring and observability.
[![License](https://img.shields.io/github/license/grafana/grafana)](LICENSE)
[![Drone](https://drone.grafana.net/api/badges/grafana/grafana/status.svg)](https://drone.grafana.net/grafana/grafana)
[![Circle CI](https://img.shields.io/circleci/build/gh/grafana/grafana)](https://circleci.com/gh/grafana/grafana)
[![Go Report Card](https://goreportcard.com/badge/github.com/grafana/grafana)](https://goreportcard.com/report/github.com/grafana/grafana)
Grafana allows you to query, visualize, alert on and understand your metrics no matter where they are stored. Create, explore, and share dashboards with your team and foster a data driven culture:
@@ -33,7 +33,6 @@ If you're interested in contributing to the Grafana project:
- Start by reading the [Contributing guide](/CONTRIBUTING.md).
- Learn how to set up your local environment, in our [Developer guide](/contribute/developer-guide.md).
- Explore our [beginner-friendly issues](https://github.com/grafana/grafana/issues?q=is%3Aopen+is%3Aissue+label%3A%22beginner+friendly%22).
- Look through our [style guide and Storybook](https://developers.grafana.com/ui/latest/index.html).
## Get involved
@@ -44,4 +43,4 @@ If you're interested in contributing to the Grafana project:
## License
Grafana is distributed under [AGPL-3.0-only](LICENSE). For Apache-2.0 exceptions, see [LICENSING.md](LICENSING.md).
Grafana is distributed under the [Apache 2.0 License](https://github.com/grafana/grafana/blob/master/LICENSE).

View File

@@ -4,14 +4,14 @@ Upgrading Go or Node.js requires making changes in many different files. See bel
## Go
- Drone
- CircleCi
- `grafana/build-container`
- Appveyor
- Dockerfile
## Node.js
- Drone
- CircleCI
- `grafana/build-container`
- Appveyor
- Dockerfile
@@ -20,29 +20,28 @@ Upgrading Go or Node.js requires making changes in many different files. See bel
The Grafana project uses [Go modules](https://golang.org/cmd/go/#hdr-Modules__module_versions__and_more) to manage dependencies on external packages. This requires a working Go environment with version 1.11 or greater installed.
> **Note:** Since most developers of Grafana still use the `GOPATH` we need to specify `GO111MODULE=on` to make `go mod` and `got get` work as intended. If you have setup Grafana outside of the `GOPATH` on your machine you can skip `GO111MODULE=on` when running the commands below.
To add or update a new dependency, use the `go get` command:
```bash
go get example.com/some/module/pkg
# The GO111MODULE variable can be omitted when the code isn't located in GOPATH.
# Pick the latest tagged release.
GO111MODULE=on go get example.com/some/module/pkg
# Pick a specific version.
go get example.com/some/module/pkg@vX.Y.Z
GO111MODULE=on go get example.com/some/module/pkg@vX.Y.Z
```
Tidy up the `go.mod` and `go.sum` files:
```bash
go mod tidy
# The GO111MODULE variable can be omitted when the code isn't located in GOPATH.
GO111MODULE=on go mod tidy
```
You have to commit the changes to `go.mod` and `go.sum` before submitting the pull request.
To understand what the actual dependencies of `grafana-server` are, one could run it with `-vv` flag. This might produce an output, different from `go.mod` contents and `-vv` option is the source of truth here. It lists the modules _compiled_ into the executable, while `go.mod` lists also test and weak transitive dependencies (modules, used in some package, which is not in use by itself). If you are interested in reporting a vulnerability in a dependency module - please consult `-vv` output, maybe the "dependency" is not a dependency as such.
### Upgrading dependencies
If you need to upgrade a direct or indirect dependency, you can do it like so, $MODULE being the dependency in question: `go get -u $MODULE`. The corresponding entry in go.mod should then have the version you specified; if it's an indirect dependency, the entry should have the `// indirect` comment. Follow this by executing `go mod tidy`, to ensure that go.mod and go.sum are up to date. If the indirect dependency turns out to not be used (transitively) by any of our packages, `go mod tidy` will actually strip it from go.mod. In that case, you can just ignore it since it isn't used in the end.
## Node.js dependencies
Updated using `yarn`.
@@ -51,9 +50,9 @@ Updated using `yarn`.
## Where to make changes
### Drone
### CircleCI
Our CI builds run on Drone.
Our builds run on CircleCI through our build script.
#### Files
@@ -67,9 +66,9 @@ Our CI builds run on Drone.
### grafana/build-container
The main build steps (in Drone) happen using a custom Docker image that comes pre-baked with some of the necessary dependencies.
The main build step (in CircleCI) is built using a custom build container that comes pre-baked with some of the necessary dependencies.
Link: [grafana/build-container](https://github.com/grafana/grafana/tree/main/scripts/build/ci-build)
Link: [grafana/build-container](https://github.com/grafana/grafana/tree/master/scripts/build/ci-build)
#### Dependencies
@@ -80,7 +79,7 @@ Link: [grafana/build-container](https://github.com/grafana/grafana/tree/main/scr
### Appveyor
Main and release builds trigger test runs on Appveyors build environment so that tests will run on Windows.
Master and release builds trigger test runs on Appveyors build environment so that tests will run on Windows.
#### Files:

View File

@@ -12,7 +12,7 @@ Team members and their access to repositories is maintained through [GitHub team
## Proposing changes
Examples of proposed changes are overarching architecture, component design, and specific code or graphical elements. Proposed changes SHOULD cover the big picture and intention, but individual parts SHOULD be split into the smallest possible changes. Changes SHOULD be based on and target the main branch. Depending on size of the proposed change, each change SHOULD be discussed, in increasing order of change size and complexity:
Examples of proposed changes are overarching architecture, component design, and specific code or graphical elements. Proposed changes SHOULD cover the big picture and intention, but individual parts SHOULD be split into the smallest possible changes. Changes SHOULD be based on and target the master branch. Depending on size of the proposed change, each change SHOULD be discussed, in increasing order of change size and complexity:
- Directly in a RR (Pull Request) - this MAY be done, but SHOULD not be the common case.
- Issue
- Developer mailing list
@@ -23,7 +23,7 @@ Significant changes MUST be discussed and agreed upon with the relevant subsyste
## Merging PRs (Pull Requests)
Depending on the size and complexity of a PR, different requirements MUST be applied. Any team member contributing substantially to a PR MUST NOT count against review requirements.
Commits MUST be merged into main using PRs. They MUST NOT be merged into main directly.
Commits MUST be merged into master using PRs. They MUST NOT be merged into master directly.
- Every merge MUST be approved by at least one team member.
- Non-trivial changes MUST be approved by at least
- two team members, or
@@ -40,7 +40,7 @@ Once a PR is approved as per above, any team member MAY merge the PR.
## Backporting a PR
PRs intended for inclusion in the next PATCH release they must be backported to the release branch. The bot can do this automatically. [Read more on backport PRs](https://github.com/grafana/grafana/blob/main/.github/bot.md). Both the source PR and the backport PR should be assigned to the patch release milestone, unless you are backporting to many releases then it can differ.
PRs intended for inclusion in the next PATCH release they must be backported to the release branch. The bot can do this automatically. [Read more on backport PRs](https://github.com/grafana/grafana/blob/master/.github/bot.md). Both the source PR and the backport PR should be assigned to the patch release milestone, unless you are backporting to many releases then it can differ.
Backport PRs are also needed during the beta period to get fixes into the stable release.
@@ -51,7 +51,7 @@ Backport PRs are also needed during the beta period to get fixes into the stable
Grafana uses trunk-based development.
In particular, we found that the following principles match how we work:
- Main and release branches MUST always build without failure.
- Master and release branches MUST always build without failure.
- Branches SHOULD be merged often. Larger changes SHOULD be activated with feature flags until they are ready. Long-lived development branches SHOULD be avoided.
- Changes MAY be enabled by default once they are in a complete state
- Changes which span multiple PRs MUST be described in an overarching issue or Google Doc.
@@ -61,8 +61,8 @@ In particular, we found that the following principles match how we work:
Releases MUST follow [Semantic Versioning](https://semver.org/) in naming and SHOULD follow Semantic Versioning as closely as reasonably possible for non-library software.
Release branches MUST be split from the following branches.
- MAJOR release branches MUST be based on main.
- MINOR release branches MUST be based on main.
- MAJOR release branches MUST be based on master.
- MINOR release branches MUST be based on master.
- PATCH release branches MUST be split from the relevant MINOR release branchs most current PATCH
Security releases follow the same process but MUST be prepared in secret. Security releases MUST NOT include changes which are not related to the security fix. Normal release processes MUST accommodate the security release process. SECURITY.md MUST be followed.

470
build.go
View File

@@ -3,14 +3,480 @@
package main
import (
"bytes"
"crypto/md5"
"crypto/sha256"
"encoding/json"
"flag"
"fmt"
"go/build"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
"path"
"path/filepath"
"runtime"
"strconv"
"strings"
"time"
)
"github.com/grafana/grafana/pkg/build"
const (
windows = "windows"
linux = "linux"
)
var (
//versionRe = regexp.MustCompile(`-[0-9]{1,3}-g[0-9a-f]{5,10}`)
goarch string
goos string
gocc string
cgo bool
libc string
pkgArch string
version string = "v1"
buildTags []string
// deb & rpm does not support semver so have to handle their version a little differently
linuxPackageVersion string = "v1"
linuxPackageIteration string = ""
race bool
workingDir string
includeBuildId bool = true
buildId string = "0"
serverBinary string = "grafana-server"
cliBinary string = "grafana-cli"
binaries []string = []string{serverBinary, cliBinary}
isDev bool = false
enterprise bool = false
skipRpmGen bool = false
skipDebGen bool = false
printGenVersion bool = false
)
func main() {
log.SetOutput(os.Stdout)
log.SetFlags(0)
os.Exit(build.RunCmd())
var buildIdRaw string
var buildTagsRaw string
flag.StringVar(&goarch, "goarch", runtime.GOARCH, "GOARCH")
flag.StringVar(&goos, "goos", runtime.GOOS, "GOOS")
flag.StringVar(&gocc, "cc", "", "CC")
flag.StringVar(&libc, "libc", "", "LIBC")
flag.StringVar(&buildTagsRaw, "build-tags", "", "Sets custom build tags")
flag.BoolVar(&cgo, "cgo-enabled", cgo, "Enable cgo")
flag.StringVar(&pkgArch, "pkg-arch", "", "PKG ARCH")
flag.BoolVar(&race, "race", race, "Use race detector")
flag.BoolVar(&includeBuildId, "includeBuildId", includeBuildId, "IncludeBuildId in package name")
flag.BoolVar(&enterprise, "enterprise", enterprise, "Build enterprise version of Grafana")
flag.StringVar(&buildIdRaw, "buildId", "0", "Build ID from CI system")
flag.BoolVar(&isDev, "dev", isDev, "optimal for development, skips certain steps")
flag.BoolVar(&skipRpmGen, "skipRpm", skipRpmGen, "skip rpm package generation (default: false)")
flag.BoolVar(&skipDebGen, "skipDeb", skipDebGen, "skip deb package generation (default: false)")
flag.BoolVar(&printGenVersion, "gen-version", printGenVersion, "generate Grafana version and output (default: false)")
flag.Parse()
buildId = shortenBuildId(buildIdRaw)
readVersionFromPackageJson()
if pkgArch == "" {
pkgArch = goarch
}
if printGenVersion {
printGeneratedVersion()
return
}
if len(buildTagsRaw) > 0 {
buildTags = strings.Split(buildTagsRaw, ",")
}
log.Printf("Version: %s, Linux Version: %s, Package Iteration: %s\n", version, linuxPackageVersion, linuxPackageIteration)
if flag.NArg() == 0 {
log.Println("Usage: go run build.go build")
return
}
workingDir, _ = os.Getwd()
for _, cmd := range flag.Args() {
switch cmd {
case "setup":
setup()
case "build-srv", "build-server":
clean()
doBuild("grafana-server", "./pkg/cmd/grafana-server", buildTags)
case "build-cli":
clean()
doBuild("grafana-cli", "./pkg/cmd/grafana-cli", buildTags)
case "build":
//clean()
for _, binary := range binaries {
doBuild(binary, "./pkg/cmd/"+binary, buildTags)
}
case "build-frontend":
yarn("build")
case "sha-dist":
shaFilesInDist()
case "latest":
makeLatestDistCopies()
case "clean":
clean()
default:
log.Fatalf("Unknown command %q", cmd)
}
}
}
func makeLatestDistCopies() {
files, err := ioutil.ReadDir("dist")
if err != nil {
log.Fatalf("failed to create latest copies. Cannot read from /dist")
}
latestMapping := map[string]string{
"_amd64.deb": "dist/grafana_latest_amd64.deb",
".x86_64.rpm": "dist/grafana-latest-1.x86_64.rpm",
".linux-amd64.tar.gz": "dist/grafana-latest.linux-x64.tar.gz",
".linux-amd64-musl.tar.gz": "dist/grafana-latest.linux-x64-musl.tar.gz",
".linux-armv7.tar.gz": "dist/grafana-latest.linux-armv7.tar.gz",
".linux-armv7-musl.tar.gz": "dist/grafana-latest.linux-armv7-musl.tar.gz",
".linux-armv6.tar.gz": "dist/grafana-latest.linux-armv6.tar.gz",
".linux-arm64.tar.gz": "dist/grafana-latest.linux-arm64.tar.gz",
".linux-arm64-musl.tar.gz": "dist/grafana-latest.linux-arm64-musl.tar.gz",
}
for _, file := range files {
for extension, fullName := range latestMapping {
if strings.HasSuffix(file.Name(), extension) {
runError("cp", path.Join("dist", file.Name()), fullName)
}
}
}
}
func readVersionFromPackageJson() {
reader, err := os.Open("package.json")
if err != nil {
log.Fatal("Failed to open package.json")
return
}
defer reader.Close()
jsonObj := map[string]interface{}{}
jsonParser := json.NewDecoder(reader)
if err := jsonParser.Decode(&jsonObj); err != nil {
log.Fatal("Failed to decode package.json")
}
version = jsonObj["version"].(string)
linuxPackageVersion = version
linuxPackageIteration = ""
// handle pre version stuff (deb / rpm does not support semver)
parts := strings.Split(version, "-")
if len(parts) > 1 {
linuxPackageVersion = parts[0]
linuxPackageIteration = parts[1]
}
// add timestamp to iteration
if includeBuildId {
if buildId != "0" {
linuxPackageIteration = fmt.Sprintf("%s%s", buildId, linuxPackageIteration)
} else {
linuxPackageIteration = fmt.Sprintf("%d%s", time.Now().Unix(), linuxPackageIteration)
}
}
}
func yarn(params ...string) {
runPrint(`yarn run`, params...)
}
func genPackageVersion() string {
if includeBuildId {
return fmt.Sprintf("%v-%v", linuxPackageVersion, linuxPackageIteration)
} else {
return version
}
}
func setup() {
args := []string{"install", "-v"}
if goos == windows {
args = append(args, "-buildmode=exe")
}
args = append(args, "./pkg/cmd/grafana-server")
runPrint("go", args...)
}
func printGeneratedVersion() {
fmt.Print(genPackageVersion())
}
func test(pkg string) {
setBuildEnv()
args := []string{"test", "-short", "-timeout", "60s"}
if goos == windows {
args = append(args, "-buildmode=exe")
}
args = append(args, pkg)
runPrint("go", args...)
}
func doBuild(binaryName, pkg string, tags []string) {
libcPart := ""
if libc != "" {
libcPart = fmt.Sprintf("-%s", libc)
}
binary := fmt.Sprintf("./bin/%s-%s%s/%s", goos, goarch, libcPart, binaryName)
if isDev {
//don't include os/arch/libc in output path in dev environment
binary = fmt.Sprintf("./bin/%s", binaryName)
}
if goos == windows {
binary += ".exe"
}
if !isDev {
rmr(binary, binary+".md5")
}
args := []string{"build", "-ldflags", ldflags()}
if goos == windows {
// Work around a linking error on Windows: "export ordinal too large"
args = append(args, "-buildmode=exe")
}
if len(tags) > 0 {
args = append(args, "-tags", strings.Join(tags, ","))
}
if race {
args = append(args, "-race")
}
args = append(args, "-o", binary)
args = append(args, pkg)
if !isDev {
setBuildEnv()
runPrint("go", "version")
libcPart := ""
if libc != "" {
libcPart = fmt.Sprintf("/%s", libc)
}
fmt.Printf("Targeting %s/%s%s\n", goos, goarch, libcPart)
}
runPrint("go", args...)
if !isDev {
// Create an md5 checksum of the binary, to be included in the archive for
// automatic upgrades.
err := md5File(binary)
if err != nil {
log.Fatal(err)
}
}
}
func ldflags() string {
var b bytes.Buffer
b.WriteString("-w")
b.WriteString(fmt.Sprintf(" -X main.version=%s", version))
b.WriteString(fmt.Sprintf(" -X main.commit=%s", getGitSha()))
b.WriteString(fmt.Sprintf(" -X main.buildstamp=%d", buildStamp()))
b.WriteString(fmt.Sprintf(" -X main.buildBranch=%s", getGitBranch()))
if v := os.Getenv("LDFLAGS"); v != "" {
b.WriteString(fmt.Sprintf(" -extldflags \"%s\"", v))
}
return b.String()
}
func rmr(paths ...string) {
for _, path := range paths {
log.Println("rm -r", path)
os.RemoveAll(path)
}
}
func clean() {
if isDev {
return
}
rmr("dist")
rmr("tmp")
rmr(filepath.Join(build.Default.GOPATH, fmt.Sprintf("pkg/%s_%s/github.com/grafana", goos, goarch)))
}
func setBuildEnv() {
os.Setenv("GOOS", goos)
if goos == windows {
// require windows >=7
os.Setenv("CGO_CFLAGS", "-D_WIN32_WINNT=0x0601")
}
if goarch != "amd64" || goos != linux {
// needed for all other archs
cgo = true
}
if strings.HasPrefix(goarch, "armv") {
os.Setenv("GOARCH", "arm")
os.Setenv("GOARM", goarch[4:])
} else {
os.Setenv("GOARCH", goarch)
}
if goarch == "386" {
os.Setenv("GO386", "387")
}
if cgo {
os.Setenv("CGO_ENABLED", "1")
}
if gocc != "" {
os.Setenv("CC", gocc)
}
}
func getGitBranch() string {
v, err := runError("git", "rev-parse", "--abbrev-ref", "HEAD")
if err != nil {
return "master"
}
return string(v)
}
func getGitSha() string {
v, err := runError("git", "rev-parse", "--short", "HEAD")
if err != nil {
return "unknown-dev"
}
return string(v)
}
func buildStamp() int64 {
// use SOURCE_DATE_EPOCH if set.
if s, _ := strconv.ParseInt(os.Getenv("SOURCE_DATE_EPOCH"), 10, 64); s > 0 {
return s
}
bs, err := runError("git", "show", "-s", "--format=%ct")
if err != nil {
return time.Now().Unix()
}
s, _ := strconv.ParseInt(string(bs), 10, 64)
return s
}
func runError(cmd string, args ...string) ([]byte, error) {
ecmd := exec.Command(cmd, args...)
bs, err := ecmd.CombinedOutput()
if err != nil {
return nil, err
}
return bytes.TrimSpace(bs), nil
}
func runPrint(cmd string, args ...string) {
log.Println(cmd, strings.Join(args, " "))
ecmd := exec.Command(cmd, args...)
ecmd.Env = append(os.Environ(), "GO111MODULE=on")
ecmd.Stdout = os.Stdout
ecmd.Stderr = os.Stderr
err := ecmd.Run()
if err != nil {
log.Fatal(err)
}
}
func md5File(file string) error {
fd, err := os.Open(file)
if err != nil {
return err
}
defer fd.Close()
h := md5.New()
_, err = io.Copy(h, fd)
if err != nil {
return err
}
out, err := os.Create(file + ".md5")
if err != nil {
return err
}
_, err = fmt.Fprintf(out, "%x\n", h.Sum(nil))
if err != nil {
return err
}
return out.Close()
}
func shaFilesInDist() {
filepath.Walk("./dist", func(path string, f os.FileInfo, err error) error {
if path == "./dist" {
return nil
}
if !strings.Contains(path, ".sha256") {
err := shaFile(path)
if err != nil {
log.Printf("Failed to create sha file. error: %v\n", err)
}
}
return nil
})
}
func shaFile(file string) error {
fd, err := os.Open(file)
if err != nil {
return err
}
defer fd.Close()
h := sha256.New()
_, err = io.Copy(h, fd)
if err != nil {
return err
}
out, err := os.Create(file + ".sha256")
if err != nil {
return err
}
_, err = fmt.Fprintf(out, "%x\n", h.Sum(nil))
if err != nil {
return err
}
return out.Close()
}
func shortenBuildId(buildId string) string {
buildId = strings.Replace(buildId, "-", "", -1)
if len(buildId) < 9 {
return buildId
}
return buildId[0:8]
}

View File

@@ -69,10 +69,6 @@ socket = /tmp/grafana.sock
# CDN Url
cdn_url =
# Sets the maximum time in minutes before timing out read of an incoming request and closing idle connections.
# `0` means there is no timeout for reading the request.
read_timeout = 0
#################################### Database ############################
[database]
# You can configure the database connection by specifying type, host, name, user and password
@@ -105,12 +101,6 @@ log_queries =
# For "mysql", use either "true", "false", or "skip-verify".
ssl_mode = disable
# Database drivers may support different transaction isolation levels.
# Currently, only "mysql" driver supports isolation levels.
# If the value is empty - driver's default isolation level is applied.
# For "mysql" use "READ-UNCOMMITTED", "READ-COMMITTED", "REPEATABLE-READ" or "SERIALIZABLE".
isolation_level =
ca_cert_path =
client_key_path =
client_cert_path =
@@ -139,13 +129,10 @@ connstr =
# This enables data proxy logging, default is false
logging = false
# How long the data proxy waits to read the headers of the response before timing out, default is 30 seconds.
# How long the data proxy waits before timing out, default is 30 seconds.
# This setting also applies to core backend HTTP data sources where query requests use an HTTP client with timeout set.
timeout = 30
# How long the data proxy waits to establish a TCP connection before timing out, default is 10 seconds.
dialTimeout = 10
# How many seconds the data proxy waits before sending a keepalive request.
keep_alive_seconds = 30
@@ -158,11 +145,6 @@ tls_handshake_timeout_seconds = 10
# waiting for the server to approve.
expect_continue_timeout_seconds = 1
# Optionally limits the total number of connections per host, including connections in the dialing,
# active, and idle states. On limit violation, dials will block.
# A value of zero (0) means no limit.
max_conns_per_host = 0
# The maximum number of idle connections that Grafana will keep alive.
max_idle_connections = 100
@@ -172,12 +154,6 @@ idle_conn_timeout_seconds = 90
# If enabled and user is not anonymous, data proxy will add X-Grafana-User header with username into the request.
send_user_header = false
# Limit the amount of bytes that will be read/accepted from responses of outgoing HTTP requests.
response_limit = 0
# Limits the number of rows that Grafana will process from SQL data sources.
row_limit = 1000000
#################################### Analytics ###########################
[analytics]
# Server reporting, sends usage counters to stats.grafana.org every 24 hours.
@@ -202,18 +178,6 @@ google_analytics_ua_id =
# Google Tag Manager ID, only enabled if you specify an id here
google_tag_manager_id =
# Rudderstack write key, enabled only if rudderstack_data_plane_url is also set
rudderstack_write_key =
# Rudderstack data plane url, enabled only if rudderstack_write_key is also set
rudderstack_data_plane_url =
# Application Insights connection string. Specify an URL string to enable this feature.
application_insights_connection_string =
# Optional. Specifies an Application Insights endpoint URL where the endpoint string is wrapped in backticks ``.
application_insights_endpoint_url =
#################################### Security ############################
[security]
# disable creation of admin user on first start of grafana
@@ -275,8 +239,7 @@ content_security_policy = false
# Set Content Security Policy template used when adding the Content-Security-Policy header to your requests.
# $NONCE in the template includes a random nonce.
# $ROOT_PATH is server.root_url without the protocol.
content_security_policy_template = """script-src 'self' 'unsafe-eval' 'unsafe-inline' 'strict-dynamic' $NONCE;object-src 'none';font-src 'self';style-src 'self' 'unsafe-inline' blob:;img-src * data:;base-uri 'self';connect-src 'self' grafana.com ws://$ROOT_PATH wss://$ROOT_PATH;manifest-src 'self';media-src 'none';form-action 'self';"""
content_security_policy_template = """script-src 'unsafe-eval' 'strict-dynamic' $NONCE;object-src 'none';font-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data:;base-uri 'self';connect-src 'self' grafana.com;manifest-src 'self';media-src 'none';form-action 'self';"""
#################################### Snapshots ###########################
[snapshots]
@@ -337,9 +300,6 @@ password_hint = password
# Default UI theme ("dark" or "light")
default_theme = dark
# Path to a custom home page. Users are only redirected to this if the default home dashboard is used. It should match a frontend route and contain a leading slash.
home_page =
# External user management
external_manage_link_url =
external_manage_link_name =
@@ -373,7 +333,7 @@ token_rotation_interval_minutes = 10
# Set to true to disable (hide) the login form, useful if you use OAuth
disable_login_form = false
# Set to true to disable the sign out link in the side menu. Useful if you use auth.proxy or auth.jwt.
# Set to true to disable the signout link in the side menu. useful if you use auth.proxy
disable_signout_menu = false
# URL to redirect the user to after sign out
@@ -491,7 +451,6 @@ api_url = https://<tenant-id>.okta.com/oauth2/v1/userinfo
allowed_domains =
allowed_groups =
role_attribute_path =
role_attribute_strict = false
#################################### Generic OAuth #######################
[auth.generic_oauth]
@@ -501,20 +460,15 @@ allow_sign_up = true
client_id = some_id
client_secret =
scopes = user:email
empty_scopes = false
email_attribute_name = email:primary
email_attribute_path =
login_attribute_path =
name_attribute_path =
role_attribute_path =
role_attribute_strict = false
groups_attribute_path =
id_token_attribute_name =
team_ids_attribute_path =
auth_url =
token_url =
api_url =
teams_url =
allowed_domains =
team_ids =
allowed_organizations =
@@ -540,18 +494,6 @@ whitelist =
headers =
enable_login_token = false
#################################### Auth JWT ##########################
[auth.jwt]
enabled = false
header_name =
email_claim =
username_claim =
jwk_set_url =
jwk_set_file =
cache_ttl = 60m
expected_claims = {}
key_file =
#################################### Auth LDAP ###########################
[auth.ldap]
enabled = false
@@ -563,35 +505,6 @@ allow_sign_up = true
sync_cron = "0 0 1 * * *"
active_sync_enabled = true
#################################### AWS ###########################
[aws]
# Enter a comma-separated list of allowed AWS authentication providers.
# Options are: default (AWS SDK Default), keys (Access && secret key), credentials (Credentials field), ec2_iam_role (EC2 IAM Role)
allowed_auth_providers = default,keys,credentials
# Allow AWS users to assume a role using temporary security credentials.
# If true, assume role will be enabled for all AWS authentication providers that are specified in aws_auth_providers
assume_role_enabled = true
# Specify max no of pages to be returned by the ListMetricPages API
list_metrics_page_limit = 500
#################################### Azure ###############################
[azure]
# Azure cloud environment where Grafana is hosted
# Possible values are AzureCloud, AzureChinaCloud, AzureUSGovernment and AzureGermanCloud
# Default value is AzureCloud (i.e. public cloud)
cloud = AzureCloud
# Specifies whether Grafana hosted in Azure service with Managed Identity configured (e.g. Azure Virtual Machines instance)
# If enabled, the managed identity can be used for authentication of Grafana in Azure services
# Disabled by default, needs to be explicitly enabled
managed_identity_enabled = false
# Client ID to use for user-assigned managed identity
# Should be set for user-assigned identity and should be empty for system-assigned identity
managed_identity_client_id =
#################################### SMTP / Emailing #####################
[smtp]
enabled = false
@@ -609,8 +522,7 @@ startTLS_policy =
[emails]
welcome_email_on_sign_up = false
templates_pattern = emails/*.html, emails/*.txt
content_types = text/html
templates_pattern = emails/*.html
#################################### Logging ##########################
[log]
@@ -705,9 +617,6 @@ org_data_source = 10
# limit number of api_keys per Org.
org_api_key = 10
# limit number of alerts per Org.
org_alert_rule = 100
# limit number of orgs a user can create.
user_org = 10
@@ -726,70 +635,11 @@ global_api_key = -1
# global limit on number of logged in users.
global_session = -1
# global limit of alerts
global_alert_rule = -1
#################################### Unified Alerting ####################
[unified_alerting]
# Enable the Unified Alerting sub-system and interface. When enabled we'll migrate all of your alert rules and notification channels to the new system. New alert rules will be created and your notification channels will be converted into an Alertmanager configuration. Previous data is preserved to enable backwards compatibility but new data is removed.
enabled = false
# Comma-separated list of organization IDs for which to disable unified alerting. Only supported if unified alerting is enabled.
disabled_orgs =
# Specify the frequency of polling for admin config changes.
# The interval string is a possibly signed sequence of decimal numbers, followed by a unit suffix (ms, s, m, h, d), e.g. 30s or 1m.
admin_config_poll_interval = 60s
# Specify the frequency of polling for Alertmanager config changes.
# The interval string is a possibly signed sequence of decimal numbers, followed by a unit suffix (ms, s, m, h, d), e.g. 30s or 1m.
alertmanager_config_poll_interval = 60s
# Listen address/hostname and port to receive unified alerting messages for other Grafana instances. The port is used for both TCP and UDP. It is assumed other Grafana instances are also running on the same port.
ha_listen_address = "0.0.0.0:9094"
# Explicit address/hostname and port to advertise other Grafana instances. The port is used for both TCP and UDP.
ha_advertise_address = ""
# Comma-separated list of initial instances (in a format of host:port) that will form the HA cluster. Configuring this setting will enable High Availability mode for alerting.
ha_peers = ""
# Time to wait for an instance to send a notification via the Alertmanager. In HA, each Grafana instance will
# be assigned a position (e.g. 0, 1). We then multiply this position with the timeout to indicate how long should
# each instance wait before sending the notification to take into account replication lag.
# The interval string is a possibly signed sequence of decimal numbers, followed by a unit suffix (ms, s, m, h, d), e.g. 30s or 1m.
ha_peer_timeout = 15s
# The interval between sending gossip messages. By lowering this value (more frequent) gossip messages are propagated
# across cluster more quickly at the expense of increased bandwidth usage.
# The interval string is a possibly signed sequence of decimal numbers, followed by a unit suffix (ms, s, m, h, d), e.g. 30s or 1m.
ha_gossip_interval = 200ms
# The interval between gossip full state syncs. Setting this interval lower (more frequent) will increase convergence speeds
# across larger clusters at the expense of increased bandwidth usage.
# The interval string is a possibly signed sequence of decimal numbers, followed by a unit suffix (ms, s, m, h, d), e.g. 30s or 1m.
ha_push_pull_interval = 60s
# Enable or disable alerting rule execution. The alerting UI remains visible. This option has a legacy version in the `[alerting]` section that takes precedence.
execute_alerts = true
# Alert evaluation timeout when fetching data from the datasource. This option has a legacy version in the `[alerting]` section that takes precedence.
# The timeout string is a possibly signed sequence of decimal numbers, followed by a unit suffix (ms, s, m, h, d), e.g. 30s or 1m.
evaluation_timeout = 30s
# Number of times we'll attempt to evaluate an alert rule before giving up on that evaluation. This option has a legacy version in the `[alerting]` section that takes precedence.
max_attempts = 3
# Minimum interval to enforce between rule evaluations. Rules will be adjusted if they are less than this value or if they are not multiple of the scheduler interval (10s). Higher values can help with resource management as we'll schedule fewer evaluations over time. This option has a legacy version in the `[alerting]` section that takes precedence.
# The interval string is a possibly signed sequence of decimal numbers, followed by a unit suffix (ms, s, m, h, d), e.g. 30s or 1m.
min_interval = 10s
#################################### Alerting ############################
[alerting]
# Disable legacy alerting engine & UI features
# Disable alerting engine & UI features
enabled = true
# Makes it possible to turn off alert execution but alerting UI is visible
# Makes it possible to turn off alert rule execution but alerting UI is visible
execute_alerts = true
# Default setting for new alert rules. Defaults to categorize error and timeouts as alerting. (alerting, keep_state)
@@ -822,9 +672,6 @@ max_annotation_age =
max_annotations_to_keep =
#################################### Annotations #########################
[annotations]
# Configures the batch size for the annotation clean-up job. This setting is used for dashboard, API, and alert annotations.
cleanupjob_batchsize = 100
[annotations.dashboard]
# Dashboard annotations means that annotations are associated with the dashboard they are created on.
@@ -962,34 +809,9 @@ disable_sanitize_html = false
[plugins]
enable_alpha = false
app_tls_skip_verify_insecure = false
# Enter a comma-separated list of plugin identifiers to identify plugins to load even if they are unsigned. Plugins with modified signatures are never loaded.
# Enter a comma-separated list of plugin identifiers to identify plugins that are allowed to be loaded even if they lack a valid signature.
allow_loading_unsigned_plugins =
# Enable or disable installing plugins directly from within Grafana.
plugin_admin_enabled = true
plugin_admin_external_manage_enabled = false
plugin_catalog_url = https://grafana.com/grafana/plugins/
#################################### Grafana Live ##########################################
[live]
# max_connections to Grafana Live WebSocket endpoint per Grafana server instance. See Grafana Live docs
# if you are planning to make it higher than default 100 since this can require some OS and infrastructure
# tuning. 0 disables Live, -1 means unlimited connections.
max_connections = 100
# allowed_origins is a comma-separated list of origins that can establish connection with Grafana Live.
# If not set then origin will be matched over root_url. Supports wildcard symbol "*".
allowed_origins =
# engine defines an HA (high availability) engine to use for Grafana Live. By default no engine used - in
# this case Live features work only on a single Grafana server.
# Available options: "redis".
# Setting ha_engine is an EXPERIMENTAL feature.
ha_engine =
# ha_engine_address sets a connection address for Live HA engine. Depending on engine type address format can differ.
# For now we only support Redis connection address in "host:port" format.
# This option is EXPERIMENTAL.
ha_engine_address = "127.0.0.1:6379"
marketplace_url = https://grafana.com/grafana/plugins/
#################################### Grafana Image Renderer Plugin ##########################
[plugin.grafana-image-renderer]
@@ -1081,10 +903,3 @@ default_timezone = browser
[expressions]
# Enable or disable the expressions functionality.
enabled = true
[geomap]
# Set the JSON configuration for the default basemap
default_baselayer_config =
# Enable or disable loading other base map layers
enable_custom_baselayers = true

View File

@@ -1,76 +0,0 @@
# # config file version
# apiVersion: 1
# # list of default built-in role assignments that should be removed
# removeDefaultAssignments:
# # <string>, must be one of the Organization roles (`Viewer`, `Editor`, `Admin`) or `Grafana Admin`
# - builtInRole: "Grafana Admin"
# # <string>, must be one of the existing fixed roles
# fixedRole: "fixed:permissions:admin"
# # list of default built-in role assignments that should be added back
# addDefaultAssignments:
# # <string>, must be one of the Organization roles (`Viewer`, `Editor`, `Admin`) or `Grafana Admin`
# - builtInRole: "Admin"
# # <string>, must be one of the existing fixed roles
# fixedRole: "fixed:reporting:admin:read"
# # list of roles that should be deleted
# deleteRoles:
# # <string> name of the role you want to create. Required if no uid is set
# - name: "custom:reports:editor"
# # <string> uid of the role. Required if no name
# uid: "customreportseditor1"
# # <int> org id. will default to Grafana's default if not specified
# orgId: 1
# # <bool> force deletion revoking all grants of the role
# force: true
# - name: "custom:global:reports:reader"
# uid: "customglobalreportsreader1"
# # <bool> overwrite org id and removes a global role
# global: true
# force: true
# # list of roles to insert/update depending on what is available in the database
# roles:
# # <string, required> name of the role you want to create. Required
# - name: "custom:users:editor"
# # <string> uid of the role. Has to be unique for all orgs.
# uid: customuserseditor1
# # <string> description of the role, informative purpose only.
# description: "Role for our custom user editors"
# # <int> version of the role, Grafana will update the role when increased
# version: 2
# # <int> org id. will default to Grafana's default if not specified
# orgId: 1
# # <list> list of the permissions granted by this role
# permissions:
# # <string, required> action allowed
# - action: "users:read"
# #<string> scope it applies to
# scope: "users:*"
# - action: "users:write"
# scope: "users:*"
# - action: "users:create"
# scope: "users:*"
# # <list> list of builtIn roles the role should be assigned to
# builtInRoles:
# # <string, required> name of the builtin role you want to assign the role to
# - name: "Editor"
# # <int> org id. will default to the role org id
# orgId: 1
# - name: "custom:global:users:reader"
# uid: "customglobalusersreader1"
# description: "Global Role for custom user readers"
# version: 1
# # <bool> overwrite org id and creates a global role
# global: true
# permissions:
# - action: "users:read"
# scope: "users:*"
# builtInRoles:
# - name: "Viewer"
# orgId: 1
# - name: "Editor"
# # <bool> overwrite org id and assign role globally
# global: true

View File

@@ -70,10 +70,6 @@
# CDN Url
;cdn_url =
# Sets the maximum time using a duration format (5s/5m/5ms) before timing out read of an incoming request and closing idle connections.
# `0` means there is no timeout for reading the request.
;read_timeout = 0
#################################### Database ####################################
[database]
# You can configure the database connection by specifying type, host, name, user and password
@@ -94,12 +90,6 @@
# For "postgres" only, either "disable", "require" or "verify-full"
;ssl_mode = disable
# Database drivers may support different transaction isolation levels.
# Currently, only "mysql" driver supports isolation levels.
# If the value is empty - driver's default isolation level is applied.
# For "mysql" use "READ-UNCOMMITTED", "READ-COMMITTED", "REPEATABLE-READ" or "SERIALIZABLE".
;isolation_level =
;ca_cert_path =
;client_key_path =
;client_cert_path =
@@ -145,13 +135,10 @@
# This enables data proxy logging, default is false
;logging = false
# How long the data proxy waits to read the headers of the response before timing out, default is 30 seconds.
# How long the data proxy waits before timing out, default is 30 seconds.
# This setting also applies to core backend HTTP data sources where query requests use an HTTP client with timeout set.
;timeout = 30
# How long the data proxy waits to establish a TCP connection before timing out, default is 10 seconds.
;dialTimeout = 10
# How many seconds the data proxy waits before sending a keepalive probe request.
;keep_alive_seconds = 30
@@ -164,11 +151,6 @@
# waiting for the server to approve.
;expect_continue_timeout_seconds = 1
# Optionally limits the total number of connections per host, including connections in the dialing,
# active, and idle states. On limit violation, dials will block.
# A value of zero (0) means no limit.
;max_conns_per_host = 0
# The maximum number of idle connections that Grafana will keep alive.
;max_idle_connections = 100
@@ -178,12 +160,6 @@
# If enabled and user is not anonymous, data proxy will add X-Grafana-User header with username into the request, default is false.
;send_user_header = false
# Limit the amount of bytes that will be read/accepted from responses of outgoing HTTP requests.
;response_limit = 0
# Limits the number of rows that Grafana will process from SQL data sources.
;row_limit = 1000000
#################################### Analytics ####################################
[analytics]
# Server reporting, sends usage counters to stats.grafana.org every 24 hours.
@@ -269,8 +245,7 @@
# Set Content Security Policy template used when adding the Content-Security-Policy header to your requests.
# $NONCE in the template includes a random nonce.
# $ROOT_PATH is server.root_url without the protocol.
;content_security_policy_template = """script-src 'self' 'unsafe-eval' 'unsafe-inline' 'strict-dynamic' $NONCE;object-src 'none';font-src 'self';style-src 'self' 'unsafe-inline' blob:;img-src * data:;base-uri 'self';connect-src 'self' grafana.com ws://$ROOT_PATH wss://$ROOT_PATH;manifest-src 'self';media-src 'none';form-action 'self';"""
;content_security_policy_template = """script-src 'unsafe-eval' 'strict-dynamic' $NONCE;object-src 'none';font-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data:;base-uri 'self';connect-src 'self' grafana.com;manifest-src 'self';media-src 'none';form-action 'self';"""
#################################### Snapshots ###########################
[snapshots]
@@ -325,9 +300,6 @@
# Default UI theme ("dark" or "light")
;default_theme = dark
# Path to a custom home page. Users are only redirected to this if the default home dashboard is used. It should match a frontend route and contain a leading slash.
; home_page =
# External user management, these options affect the organization users view
;external_manage_link_url =
;external_manage_link_name =
@@ -361,7 +333,7 @@
# Set to true to disable (hide) the login form, useful if you use OAuth, defaults to false
;disable_login_form = false
# Set to true to disable the sign out link in the side menu. Useful if you use auth.proxy or auth.jwt, defaults to false
# Set to true to disable the signout link in the side menu. useful if you use auth.proxy, defaults to false
;disable_signout_menu = false
# URL to redirect the user to after sign out
@@ -470,7 +442,6 @@
;allowed_domains =
;allowed_groups =
;role_attribute_path =
;role_attribute_strict = false
#################################### Generic OAuth ##########################
[auth.generic_oauth]
@@ -480,7 +451,6 @@
;client_id = some_id
;client_secret = some_secret
;scopes = user:email,read:org
;empty_scopes = false
;email_attribute_name = email:primary
;email_attribute_path =
;login_attribute_path =
@@ -489,14 +459,10 @@
;auth_url = https://foo.bar/login/oauth/authorize
;token_url = https://foo.bar/login/oauth/access_token
;api_url = https://foo.bar/user
;teams_url =
;allowed_domains =
;team_ids =
;allowed_organizations =
;role_attribute_path =
;role_attribute_strict = false
;groups_attribute_path =
;team_ids_attribute_path =
;tls_skip_verify_insecure = false
;tls_client_cert =
;tls_client_key =
@@ -518,18 +484,6 @@
# Read the auth proxy docs for details on what the setting below enables
;enable_login_token = false
#################################### Auth JWT ##########################
[auth.jwt]
;enabled = true
;header_name = X-JWT-Assertion
;email_claim = sub
;username_claim = sub
;jwk_set_url = https://foo.bar/.well-known/jwks.json
;jwk_set_file = /path/to/jwks.json
;cache_ttl = 60m
;expected_claims = {"aud": ["foo", "bar"]}
;key_file = /path/to/key/file
#################################### Auth LDAP ##########################
[auth.ldap]
;enabled = false
@@ -541,32 +495,6 @@
;sync_cron = "0 0 1 * * *"
;active_sync_enabled = true
#################################### AWS ###########################
[aws]
# Enter a comma-separated list of allowed AWS authentication providers.
# Options are: default (AWS SDK Default), keys (Access && secret key), credentials (Credentials field), ec2_iam_role (EC2 IAM Role)
; allowed_auth_providers = default,keys,credentials
# Allow AWS users to assume a role using temporary security credentials.
# If true, assume role will be enabled for all AWS authentication providers that are specified in aws_auth_providers
; assume_role_enabled = true
#################################### Azure ###############################
[azure]
# Azure cloud environment where Grafana is hosted
# Possible values are AzureCloud, AzureChinaCloud, AzureUSGovernment and AzureGermanCloud
# Default value is AzureCloud (i.e. public cloud)
;cloud = AzureCloud
# Specifies whether Grafana hosted in Azure service with Managed Identity configured (e.g. Azure Virtual Machines instance)
# If enabled, the managed identity can be used for authentication of Grafana in Azure services
# Disabled by default, needs to be explicitly enabled
;managed_identity_enabled = false
# Client ID to use for user-assigned managed identity
# Should be set for user-assigned identity and should be empty for system-assigned identity
;managed_identity_client_id =
#################################### SMTP / Emailing ##########################
[smtp]
;enabled = false
@@ -586,8 +514,7 @@
[emails]
;welcome_email_on_sign_up = false
;templates_pattern = emails/*.html, emails/*.txt
;content_types = text/html
;templates_pattern = emails/*.html
#################################### Logging ##########################
[log]
@@ -682,9 +609,6 @@
# limit number of api_keys per Org.
; org_api_key = 10
# limit number of alerts per Org.
;org_alert_rule = 100
# limit number of orgs a user can create.
; user_org = 10
@@ -703,70 +627,11 @@
# global limit on number of logged in users.
; global_session = -1
# global limit of alerts
;global_alert_rule = -1
#################################### Unified Alerting ####################
[unified_alerting]
#Enable the Unified Alerting sub-system and interface. When enabled we'll migrate all of your alert rules and notification channels to the new system. New alert rules will be created and your notification channels will be converted into an Alertmanager configuration. Previous data is preserved to enable backwards compatibility but new data is removed.```
;enabled = false
# Comma-separated list of organization IDs for which to disable unified alerting. Only supported if unified alerting is enabled.
;disabled_orgs =
# Specify the frequency of polling for admin config changes.
# The interval string is a possibly signed sequence of decimal numbers, followed by a unit suffix (ms, s, m, h, d), e.g. 30s or 1m.
;admin_config_poll_interval = 60s
# Specify the frequency of polling for Alertmanager config changes.
# The interval string is a possibly signed sequence of decimal numbers, followed by a unit suffix (ms, s, m, h, d), e.g. 30s or 1m.
;alertmanager_config_poll_interval = 60s
# Listen address/hostname and port to receive unified alerting messages for other Grafana instances. The port is used for both TCP and UDP. It is assumed other Grafana instances are also running on the same port. The default value is `0.0.0.0:9094`.
;ha_listen_address = "0.0.0.0:9094"
# Listen address/hostname and port to receive unified alerting messages for other Grafana instances. The port is used for both TCP and UDP. It is assumed other Grafana instances are also running on the same port. The default value is `0.0.0.0:9094`.
;ha_advertise_address = ""
# Comma-separated list of initial instances (in a format of host:port) that will form the HA cluster. Configuring this setting will enable High Availability mode for alerting.
;ha_peers = ""
# Time to wait for an instance to send a notification via the Alertmanager. In HA, each Grafana instance will
# be assigned a position (e.g. 0, 1). We then multiply this position with the timeout to indicate how long should
# each instance wait before sending the notification to take into account replication lag.
# The interval string is a possibly signed sequence of decimal numbers, followed by a unit suffix (ms, s, m, h, d), e.g. 30s or 1m.
;ha_peer_timeout = "15s"
# The interval between sending gossip messages. By lowering this value (more frequent) gossip messages are propagated
# across cluster more quickly at the expense of increased bandwidth usage.
# The interval string is a possibly signed sequence of decimal numbers, followed by a unit suffix (ms, s, m, h, d), e.g. 30s or 1m.
;ha_gossip_interval = "200ms"
# The interval between gossip full state syncs. Setting this interval lower (more frequent) will increase convergence speeds
# across larger clusters at the expense of increased bandwidth usage.
# The interval string is a possibly signed sequence of decimal numbers, followed by a unit suffix (ms, s, m, h, d), e.g. 30s or 1m.
;ha_push_pull_interval = "60s"
# Enable or disable alerting rule execution. The alerting UI remains visible. This option has a legacy version in the `[alerting]` section that takes precedence.
;execute_alerts = true
# Alert evaluation timeout when fetching data from the datasource. This option has a legacy version in the `[alerting]` section that takes precedence.
# The timeout string is a possibly signed sequence of decimal numbers, followed by a unit suffix (ms, s, m, h, d), e.g. 30s or 1m.
;evaluation_timeout = 30s
# Number of times we'll attempt to evaluate an alert rule before giving up on that evaluation. This option has a legacy version in the `[alerting]` section that takes precedence.
;max_attempts = 3
# Minimum interval to enforce between rule evaluations. Rules will be adjusted if they are less than this value or if they are not multiple of the scheduler interval (10s). Higher values can help with resource management as we'll schedule fewer evaluations over time. This option has a legacy version in the `[alerting]` section that takes precedence.
# The interval string is a possibly signed sequence of decimal numbers, followed by a unit suffix (ms, s, m, h, d), e.g. 30s or 1m.
;min_interval = 10s
#################################### Alerting ############################
[alerting]
# Disable legacy alerting engine & UI features
# Disable alerting engine & UI features
;enabled = true
# Makes it possible to turn off alert execution but alerting UI is visible
# Makes it possible to turn off alert rule execution but alerting UI is visible
;execute_alerts = true
# Default setting for new alert rules. Defaults to categorize error and timeouts as alerting. (alerting, keep_state)
@@ -779,6 +644,7 @@
# This limit will protect the server from render overloading and make sure notifications are sent out quickly
;concurrent_render_limit = 5
# Default setting for alert calculation timeout. Default value is 30
;evaluation_timeout_seconds = 30
@@ -799,9 +665,6 @@
;max_annotations_to_keep =
#################################### Annotations #########################
[annotations]
# Configures the batch size for the annotation clean-up job. This setting is used for dashboard, API, and alert annotations.
;cleanupjob_batchsize = 100
[annotations.dashboard]
# Dashboard annotations means that annotations are associated with the dashboard they are created on.
@@ -935,33 +798,9 @@
[plugins]
;enable_alpha = false
;app_tls_skip_verify_insecure = false
# Enter a comma-separated list of plugin identifiers to identify plugins to load even if they are unsigned. Plugins with modified signatures are never loaded.
# Enter a comma-separated list of plugin identifiers to identify plugins that are allowed to be loaded even if they lack a valid signature.
;allow_loading_unsigned_plugins =
# Enable or disable installing plugins directly from within Grafana.
;plugin_admin_enabled = false
;plugin_admin_external_manage_enabled = false
;plugin_catalog_url = https://grafana.com/grafana/plugins/
#################################### Grafana Live ##########################################
[live]
# max_connections to Grafana Live WebSocket endpoint per Grafana server instance. See Grafana Live docs
# if you are planning to make it higher than default 100 since this can require some OS and infrastructure
# tuning. 0 disables Live, -1 means unlimited connections.
;max_connections = 100
# allowed_origins is a comma-separated list of origins that can establish connection with Grafana Live.
# If not set then origin will be matched over root_url. Supports wildcard symbol "*".
;allowed_origins =
# engine defines an HA (high availability) engine to use for Grafana Live. By default no engine used - in
# this case Live features work only on a single Grafana server. Available options: "redis".
# Setting ha_engine is an EXPERIMENTAL feature.
;ha_engine =
# ha_engine_address sets a connection address for Live HA engine. Depending on engine type address format can differ.
# For now we only support Redis connection address in "host:port" format.
# This option is EXPERIMENTAL.
;ha_engine_address = "127.0.0.1:6379"
;marketplace_url = https://grafana.com/grafana/plugins/
#################################### Grafana Image Renderer Plugin ##########################
[plugin.grafana-image-renderer]
@@ -1054,16 +893,3 @@
[expressions]
# Enable or disable the expressions functionality.
;enabled = true
[geomap]
# Set the JSON configuration for the default basemap
;default_baselayer_config = `{
; "type": "xyz",
; "config": {
; "attribution": "Open street map",
; "url": "https://tile.openstreetmap.org/{z}/{x}/{y}.png"
; }
;}`
# Enable or disable loading other base map layers
;enable_custom_baselayers = true

View File

@@ -6,7 +6,6 @@ This directory contains guides for contributors to the Grafana project.
- [Contributing documentation](documentation.md)
- [Developer guide](developer-guide.md)
- [Triage issues](triage-issues.md)
- [Merge a pull request](merge-pull-request.md)
The `style-guides` directory contains style guides for the Grafana software project and documentation.

View File

@@ -4,9 +4,9 @@ Are you looking to take on contributions with bigger impact? These guides help y
Learn more about the backend architecture:
- Part 1: [Services](backend/services.md)
- Part 2: [Communication](backend/communication.md)
- Part 3: [Database](backend/database.md)
- Part 1: [Services](services.md)
- Part 2: [Communication](communication.md)
- Part 3: [Database](database.md)
Learn more about the frontend architecture:
- Part 1: [Data requests](frontend-data-requests.md)

View File

@@ -1,133 +0,0 @@
# Communication
Grafana uses a _bus_ to pass messages between different parts of the application. All communication over the bus happens synchronously.
There are three types of messages: _events_, _commands_, and _queries_.
## Events
An event is something that happened in the past. Since an event has already happened, you can't change it. Instead, you can react to events by triggering additional application logic to be run, whenever they occur.
> Because they happened in the past, event names are written in past tense, such as `UserCreated`, and `OrgUpdated`.
### Subscribe to an event
In order to react to an event, you first need to _subscribe_ to it.
To subscribe to an event, register an _event listener_ in the service's `Init` method:
```go
func (s *MyService) Init() error {
s.bus.AddEventListener(s.UserCreated)
return nil
}
func (s *MyService) UserCreated(event *events.UserCreated) error {
// ...
}
```
**Tip:** Browse the available events in the `events` package.
### Publish an event
If you want to let other parts of the application react to changes in a service, you can publish your own events:
```go
event := &events.StickersSentEvent {
UserID: "taylor",
Count: 1,
}
if err := s.bus.Publish(event); err != nil {
return err
}
```
## Commands
A command is a request for an action to be taken. Unlike an event's fire-and-forget approach, a command can fail as it is handled. The handler will then return an error.
> Because we request an operation to be performed, command are written in imperative mood, such as `CreateFolderCommand`, and `DeletePlaylistCommand`.
### Dispatch a command
To dispatch a command, pass the `context.Context` and object to the `DispatchCtx` method:
```go
// context.Context from caller
ctx := req.Request.Context()
cmd := &models.SendStickersCommand {
UserID: "taylor",
Count: 1,
}
if err := s.bus.DispatchCtx(ctx, cmd); err != nil {
if err == bus.ErrHandlerNotFound {
return nil
}
return err
}
```
> **Note:** `DispatchCtx` will return an error if no handler is registered for that command.
> **Note:** `Dispatch` currently exists and requires no `context.Context` to be provided, but it's strongly suggested to not use this since there's an ongoing refactoring to remove usage of non-context-aware functions/methods and use context.Context everywhere.
**Tip:** Browse the available commands in the `models` package.
### Handle commands
Let other parts of the application dispatch commands to a service, by registering a _command handler_:
To handle a command, register a command handler in the `Init` function.
```go
func (s *MyService) Init() error {
s.bus.AddHandlerCtx(s.SendStickers)
return nil
}
func (s *MyService) SendStickers(ctx context.Context, cmd *models.SendStickersCommand) error {
// ...
}
```
> **Note:** The handler method may return an error if unable to complete the command.
> **Note:** `AddHandler` currently exists and requires no `context.Context` to be provided, but it's strongly suggested to not use this since there's an ongoing refactoring to remove usage of non-context-aware functions/methods and use context.Context everywhere.
## Queries
A command handler can optionally populate the command sent to it. This pattern is commonly used to implement _queries_.
### Making a query
To make a query, dispatch the query instance just like you would a command. When the `DispatchCtx` method returns, the `Results` field contains the result of the query.
```go
// context.Context from caller
ctx := req.Request.Context()
query := &models.FindDashboardQuery{
ID: "foo",
}
if err := bus.DispatchCtx(ctx, query); err != nil {
return err
}
// The query now contains a result.
for _, item := range query.Results {
// ...
}
```
> **Note:** `Dispatch` currently exists and requires no `context.Context` to be provided, but it's strongly suggested to not use this since there's an ongoing refactoring to remove usage of non-context-aware functions/methods and use context.Context everywhere.
### Return query results
To return results for a query, set any of the fields on the query argument before returning:
```go
func (s *MyService) FindDashboard(ctx context.Context, query *models.FindDashboardQuery) error {
// ...
query.Result = dashboard
return nil
}
```

View File

@@ -1,16 +0,0 @@
# Package hierarchy
The Go package hierarchy in Grafana should be organized logically (Ben Johnson's
[article](https://medium.com/@benbjohnson/standard-package-layout-7cdbc8391fc1) served as inspiration), according to the
following principles:
* Domain types and interfaces should be in "root" packages (not necessarily at the very top, of the hierarchy, but
logical roots)
* Sub-packages should depend on roots - sub-packages here typically contain implementations, for example of services
## Practical example
The `pkg/plugins` package contains plugin domain types, for example `DataPlugin`, and also interfaces
such as `RequestHandler`. Then you have the `pkg/plugins/managers` subpackage, which contains concrete implementations
such as the service `PluginManager`. The subpackage `pkg/plugins/backendplugin/coreplugin` contains `plugins.DataPlugin`
implementations.

View File

@@ -1,138 +0,0 @@
# Services
A Grafana _service_ encapsulates and exposes application logic to the rest of the application, through a set of related operations.
Grafana uses [Wire](https://github.com/google/wire), which is a code generation tool that automates connecting components using [dependency injection](https://en.wikipedia.org/wiki/Dependency_injection). Dependencies between components are represented in Wire as function parameters, encouraging explicit initialization instead of global variables.
Even though the services in Grafana do different things, they share a number of patterns. To better understand how a service works, let's build one from scratch!
Before a service can start communicating with the rest of Grafana, it needs to be registered with Wire, see `ProvideService` factory function/method in the service example below and how it's being referenced in the wire.go example below.
When Wire is run it will inspect the parameters of `ProvideService` and make sure that all it's dependencies has been wired up and initialized properly.
**Service example:**
```go
package example
// Service service is the service responsible for X, Y and Z.
type Service struct {
logger log.Logger
cfg *setting.Cfg
sqlStore *sqlstore.SQLStore
}
// ProvideService provides Service as dependency for other services.
func ProvideService(cfg *setting.Cfg, sqlStore *sqlstore.SQLStore) (*Service, error) {
s := &Service{
logger: log.New("service"),
cfg: cfg,
sqlStore: sqlStore,
}
if s.IsDisabled() {
// skip certain initialization logic
return s, nil
}
if err := s.init(); err != nil {
return nil, err
}
return s, nil
}
func (s *Service) init() error {
// additional initialization logic...
return nil
}
// IsDisabled returns true if the service is disabled.
//
// Satisfies the registry.CanBeDisabled interface which will guarantee
// that Run() is not called if the service is disabled.
func (s *Service) IsDisabled() bool {
return !s.cfg.IsServiceEnabled()
}
// Run runs the service in the background.
//
// Satisfies the registry.BackgroundService interface which will
// guarantee that the service can be registered as a background service.
func (s *Service) Run(ctx context.Context) error {
// background service logic...
<-ctx.Done()
return ctx.Err()
}
```
[wire.go](/pkg/server/wire.go)
```go
// +build wireinject
package server
import (
"github.com/google/wire"
"github.com/grafana/grafana/pkg/example"
"github.com/grafana/grafana/pkg/services/sqlstore"
)
var wireBasicSet = wire.NewSet(
example.ProvideService,
)
var wireSet = wire.NewSet(
wireBasicSet,
sqlstore.ProvideService,
)
var wireTestSet = wire.NewSet(
wireBasicSet,
)
func Initialize(cla setting.CommandLineArgs, opts Options, apiOpts api.ServerOptions) (*Server, error) {
wire.Build(wireExtsSet)
return &Server{}, nil
}
func InitializeForTest(cla setting.CommandLineArgs, opts Options, apiOpts api.ServerOptions, sqlStore *sqlstore.SQLStore) (*Server, error) {
wire.Build(wireExtsTestSet)
return &Server{}, nil
}
```
## Background services
A background service is a service that runs in the background of the lifecycle between Grafana starts up and shutdown. If you want a service to be run in the background your Service should satisfy the `registry.BackgroundService` interface and add it as argument to the [ProvideBackgroundServiceRegistry](/pkg/server/backgroundsvcs/background_services.go) function and add it as argument to `NewBackgroundServiceRegistry` to register it as a background service.
You can see an example implementation above of the Run method.
## Disabled services
If you want to guarantee that a background service is not run by Grafana when certain criteria is met/service is disabled your service should satisfy the `registry.CanBeDisabled` interface. When the service.IsDisabled method return false Grafana would not call the service.Run method.
If you want to run certain initialization code if service is disabled or not, you need to handle this in the service factory method.
You can see an example implementation above of the IsDisabled method and custom initialization code when service is disabled.
## Run Wire / generate code
When running `make run` it will call `make gen-go` on the first run. `gen-go` in turn will call the wire binary and generate the code in [wire_gen.go](/pkg/server/wire_gen.go). The wire binary is installed using [bingo](https://github.com/bwplotka/bingo) which will make sure to download and install all the tools needed, including the Wire binary at using a specific version.
## OSS vs Enterprise
Grafana OSS and Grafana Enterprise shares code and dependencies. Grafana Enterprise might need to override/extend certain OSS services.
There's a [wireexts_oss.go](/pkg/server/wireexts_oss.go) that has the `wireinject` and `oss` build tags as requirements. Here services that might have other implementations, e.g. Grafana Enterprise, can be registered.
Similarly, there's a wireexts_enterprise.go file in the Enterprise source code repository where other service implementations can be overridden/be registered.
To extend oss background service create a specific background interface for that type and inject that type to [ProvideBackgroundServiceRegistry](/pkg/server/backgroundsvcs/background_services.go) instead of the concrete type. Then add a wire binding for that interface in [wireexts_oss.go](/pkg/server/wireexts_oss.go) and in the enterprise wireexts file.
## Methods
Any public method of a service should take `context.Context` as its first argument. If the method calls the bus, other services or the database the context should be propagated, if possible.

View File

@@ -0,0 +1,123 @@
# Communication
Grafana uses a _bus_ to pass messages between different parts of the application. All communication over the bus happens synchronously.
There are three types of messages: _events_, _commands_, and _queries_.
## Events
An event is something that happened in the past. Since an event has already happened, you can't change it. Instead, you can react to events by triggering additional application logic to be run, whenever they occur.
> Because they happened in the past, event names are written in past tense, such as `UserCreated`, and `OrgUpdated`.
### Subscribe to an event
In order to react to an event, you first need to _subscribe_ to it.
To subscribe to an event, register an _event listener_ in the service's `Init` method:
```go
func (s *MyService) Init() error {
s.bus.AddEventListener(s.UserCreated)
return nil
}
func (s *MyService) UserCreated(event *events.UserCreated) error {
// ...
}
```
**Tip:** Browse the available events in the `events` package.
### Publish an event
If you want to let other parts of the application react to changes in a service, you can publish your own events:
```go
event := &events.StickersSentEvent {
UserID: "taylor",
Count: 1,
}
if err := s.bus.Publish(event); err != nil {
return err
}
```
## Commands
A command is a request for an action to be taken. Unlike an event's fire-and-forget approach, a command can fail as it is handled. The handler will then return an error.
> Because we request an operation to be performed, command are written in imperative mood, such as `CreateFolderCommand`, and `DeletePlaylistCommand`.
### Dispatch a command
To dispatch a command, pass the object to the `Dispatch` method:
```go
cmd := &models.SendStickersCommand {
UserID: "taylor",
Count: 1,
}
if err := s.bus.Dispatch(cmd); err != nil {
if err == bus.ErrHandlerNotFound {
return nil
}
return err
}
```
> **Note:** `Dispatch` will return an error if no handler is registered for that command.
**Tip:** Browse the available commands in the `models` package.
### Handle commands
Let other parts of the application dispatch commands to a service, by registering a _command handler_:
To handle a command, register a command handler in the `Init` function.
```go
func (s *MyService) Init() error {
s.bus.AddHandler(s.SendStickers)
return nil
}
func (s *MyService) SendStickers(cmd *models.SendStickersCommand) error {
// ...
}
```
> **Note:** The handler method may return an error if unable to complete the command.
## Queries
A command handler can optionally populate the command sent to it. This pattern is commonly used to implement _queries_.
### Making a query
To make a query, dispatch the query instance just like you would a command. When the `Dispatch` method returns, the `Results` field contains the result of the query.
```go
query := &models.FindDashboardQuery{
ID: "foo",
}
if err := bus.Dispatch(query); err != nil {
return err
}
// The query now contains a result.
for _, item := range query.Results {
// ...
}
```
### Return query results
To return results for a query, set any of the fields on the query argument before returning:
```go
func (s *MyService) FindDashboard(query *models.FindDashboardQuery) error {
// ...
query.Result = dashboard
return nil
}
```

View File

@@ -33,18 +33,18 @@ To register a handler:
```go
func init() {
bus.AddHandlerCtx("sql", DeleteDashboard)
bus.AddHandler("sql", DeleteDashboard)
}
func DeleteDashboard(ctx context.Context, cmd *models.DeleteDashboardCommand) error {
return inTransactionCtx(ctx, func(sess *DBSession) error {
func DeleteDashboard(cmd *models.DeleteDashboardCommand) error {
return inTransaction(func(sess *DBSession) error {
_, err := sess.Exec("DELETE FROM dashboards WHERE dashboard_id=?", cmd.DashboardID)
return err
})
}
```
Here, `inTransactionCtx` is a helper function in the `sqlstore` package that provides a session, that lets you execute SQL statements.
Here, `inTransaction` is a helper function in the `sqlstore` package that provides a session, that lets you execute SQL statements.
## `SQLStore`
@@ -61,7 +61,7 @@ type MyService struct {
You can now make SQL queries in any of your [command handlers](communication.md#handle-commands) or [event listeners](communication.md#subscribe-to-an-event):
```go
func (s *MyService) DeleteDashboard(ctx context.Context, cmd *models.DeleteDashboardCommand) error {
func (s *MyService) DeleteDashboard(cmd *models.DeleteDashboardCommand) error {
if err := s.SQLStore.WithDbSession(ctx, func(sess *sqlstore.DBSession) error {
_, err := sess.Exec("DELETE FROM dashboards WHERE dashboard_id=?", cmd.DashboardID)
return err
@@ -79,7 +79,7 @@ To see all the types of migrations you can add, refer to [migrations.go](/pkg/se
Before you add a migration, make sure that you:
- Never change a migration that has been committed and pushed to main.
- Never change a migration that has been committed and pushed to master.
- Always add new migrations, to change or undo previous migrations.
Add a migration using one of the following methods:

View File

@@ -12,7 +12,7 @@ If we wait for canceled requests to complete, it might create unnecessary load o
Grafana uses a concept called _request cancelation_ to cancel any ongoing request that Grafana doesn't need.
#### Before Grafana 7.2
Before Grafana can cancel any data request, it has to identify that request. Grafana identifies a request using the property `requestId` [passed as options](https://github.com/grafana/grafana/blob/main/docs/sources/packages_api/runtime/backendsrvrequest.md) when you use [BackendSrv](https://grafana.com/docs/grafana/latest/packages_api/runtime/backendsrv).
Before Grafana can cancel any data request, it has to identify that request. Grafana identifies a request using the property `requestId` [passed as options](https://github.com/grafana/grafana/blob/master/docs/sources/packages_api/runtime/backendsrvrequest.md) when you use [BackendSrv](https://grafana.com/docs/grafana/latest/packages_api/runtime/backendsrv).
The cancellation logic is as follows:
- When an ongoing request discovers that an additional request with the same `requestId` has started, then Grafana will cancel the ongoing request.

View File

@@ -0,0 +1,69 @@
# Services
A Grafana _service_ encapsulates and exposes application logic to the rest of the application, through a set of related operations.
Before a service can start communicating with the rest of Grafana, it needs to be registered in the _service registry_.
The service registry keeps track of all available services during runtime. On start-up, Grafana uses the registry to build a dependency graph of services, a _service graph_.
Even though the services in Grafana do different things, they share a number of patterns. To better understand how a service works, let's build one from scratch!
## Create a service
To start building a service:
- Create a new Go package `mysvc` in the [pkg/services](/pkg/services) directory.
- Create a `service.go` file inside your new directory.
All services need to implement the [Service](https://godoc.org/github.com/grafana/grafana/pkg/registry#Service) interface:
```go
type MyService struct {
}
func (s *MyService) Init() error {
return nil
}
```
The `Init` method is used to initialize and configure the service to make it ready to use. Services that return an error halt Grafana's startup process and cause the error to be logged as it exits.
## Register a service
Every service needs to be registered with the application for it to be included in the service graph.
To register a service, call the `registry.RegisterService` function in an `init` function within your package.
```go
func init() {
registry.RegisterService(&MyService{})
}
```
`init` functions are only run whenever a package is imported, so we also need to import the package in the application. In the `server.go` file under `pkg/server`, import the package we just created:
```go
import _ "github.com/grafana/grafana/pkg/services/mysvc"
```
## Dependencies
Grafana uses the [inject](https://github.com/facebookgo/inject) package to inject dependencies during runtime.
For example, to access the [bus](communication.md), add it to the `MyService` struct:
```go
type MyService struct {
Bus bus.Bus `inject:""`
}
```
You can also inject other services in the same way:
```go
type MyService struct {
Service other.Service `inject:""`
}
```
> **Note:** Any injected dependency needs to be an exported field. Any unexported fields result in a runtime error.

View File

@@ -16,10 +16,10 @@ If this is your first time contributing to an open-source project on GitHub, mak
To increase the chance of having your pull request accepted, make sure your pull request follows these guidelines:
- Title and description matches the implementation.
- Commits within the pull request follow the [Formatting guidelines](#Formatting-guidelines).
- Commits within the pull request follow the [Formatting guidelines](#Formatting-guidelines).
- The pull request closes one related issue.
- The pull request contains necessary tests that verify the intended behavior.
- If your pull request has conflicts, rebase your branch onto the main branch.
- If your pull request has conflicts, rebase your branch onto the master branch.
If the pull request fixes a bug:
@@ -43,33 +43,6 @@ Pull requests for Redux contributions must:
- Not contain code that mutates state in reducers or thunks.
- Not contain code that accesses the reducers state slice directly. Instead, the code should use state selectors to access state.
Pull requests that add or modify unit tests that are written in Jest must adhere to these guidelines:
- Don't add snapshots tests. We are incrementally removing existing snapshot tests, we don't want more.
- If an existing unit test is written in Enzyme, migrate it to RTL (React Testing Library), unless youre fixing a bug. Bug fixes usually shouldn't include any bigger refactoring, so its ok to skip migrating the test to RTL.
Pull requests that create new UI components or modify existing ones must adhere to the following accessibility guidelines:
- Use semantic HTML.
- Use ARIA roles, labels and other accessibility attributes correctly. Accessibility attributes should only be used when semantic HTML doesn't satisfy your use case.
- Use the [Grafana theme palette](/contribute/style-guides/themes.md) for styling. It contains colors with good contrast which aids accessibility.
- Use [RTL](https://testing-library.com/docs/dom-testing-library/api-accessibility/) for writing unit tests. It helps to create accessible components.
Pull requests that introduce accessibility(a11y) errors:
We use [pa11y-ci](https://github.com/pa11y/pa11y-ci) to collect accessibility errors on [some URLs on the project](https://github.com/grafana/grafana/issues/36555), threshold errors are specified per URL.
If the contribution introduces new a11y errors, our continuous integration will fail, preventing you to merge on the main branch. In those cases there are two alternatives for moving forward:
- Check the error log on the pipeline step `test-a11y-frontend-pr`, identify what was the error, and fix it.
- Locally run the command `yarn test:accessibility-report` that generates an HTML accessibility report, then go to the URL that contains your change, identify the error, and fix it. Keep in mind, a local Grafana instance needs to be running on `http://localhost:3000`.
You can also prevent introducing a11y errors by installing an a11y plugin in your browser, for example, axe DevTools, Accessibility Insights for Web among others.
### Backend-specific guidelines
Please refer to the [backend style guidelines](/contribute/style-guides/backend.md).
## Code review
Once you've created a pull request, the next step is to have someone review your change. A review is a learning opportunity for both the reviewer and the author of the pull request.
@@ -113,8 +86,6 @@ For changes to panels, the area should be the name of the panel, suffixed with P
- `GraphPanel: Fix legend sorting issues`
- `Docs: Changed url to URL in all documentation files`
If you're unsure, please have a look at the existing [changelog](https://github.com/grafana/grafana/blob/main/CHANGELOG.md) for inspiration/guidance.
### Pull request titles
The Grafana team _squashes_ all commits into one when we accept a pull request. The title of the pull request becomes the subject line of the squashed commit message. We still encourage contributors to write informative commit messages, as they becomes a part of the Git commit body.
@@ -122,11 +93,3 @@ The Grafana team _squashes_ all commits into one when we accept a pull request.
We use the pull request title when we generate change logs for releases. As such, we strive to make the title as informative as possible.
Make sure that the title for your pull request uses the same format as the subject line in the commit message.
## Configuration changes
If your PR includes configuration changes, all of the following files must be changed correspondingly:
- conf/defaults.ini
- conf/sample.ini
- docs/sources/administration/configuration.md

View File

@@ -10,14 +10,8 @@ Make sure you have the following dependencies installed before setting up your d
- [Git](https://git-scm.com/)
- [Go](https://golang.org/dl/) (see [go.mod](../go.mod#L3) for minimum required version)
Additionally you'll need:
- [Node.js](https://nodejs.org) (see `volta.node` property in [package.json](../package.json) for the correct version).
- [Yarn](https://yarnpkg.com) (see `volta.yarn` property in [package.json](../package.json) for the correct version).
We recommend using [Volta](https://github.com/volta-cli/volta) to manage your JS toolchain.
Refer to the [Volta Getting Started Guide](https://docs.volta.sh/guide/getting-started) for setup instructions for your operating system.
- [Node.js (Long Term Support)](https://nodejs.org)
- [Yarn](https://yarnpkg.com)
### macOS
@@ -26,12 +20,11 @@ We recommend using [Homebrew](https://brew.sh/) for installing any missing depen
```
brew install git
brew install go
brew install node@14
npm install -g yarn
```
### Windows
If you are running Grafana on Windows 10, we recommend installing the Windows Subsystem for Linux (WSL). For installation instructions, refer to our [Grafana setup guide for Windows environment](https://grafana.com/blog/2021/03/03/how-to-set-up-a-grafana-development-environment-on-a-windows-pc-using-wsl/).
## Download Grafana
We recommend using the Git command-line interface to download the source code for the Grafana project:
@@ -86,7 +79,7 @@ When you log in for the first time, Grafana asks you to change your password.
The Grafana backend includes SQLite which requires GCC to compile. So in order to compile Grafana on Windows you need to install GCC. We recommend [TDM-GCC](http://tdm-gcc.tdragon.net/download). Eventually, if you use [Scoop](https://scoop.sh), you can install GCC through that.
You can simply build the back-end as follows: `go run build.go build`. The Grafana binaries will be in bin\\windows-amd64.
Alternately, if you wish to use the `make` command, install [Make for Windows](http://gnuwin32.sourceforge.net/packages/make.htm) and use it in a Unix shell (f.ex. Git Bash).
Alternately, if you wish to use the `make` command, install [Make for Windows](http://gnuwin32.sourceforge.net/packages/make.htm) and use it in a Unix shell (f.ex. Git Bash).
## Test Grafana
@@ -109,7 +102,6 @@ go test -v ./pkg/...
```
#### On Windows
Running the backend tests on Windows currently needs some tweaking, so use the build.go script:
```
@@ -180,7 +172,7 @@ make devenv sources=influxdb,loki
The script generates a Docker Compose file with the databases you specify as `sources`, and runs them in the background.
See the repository for all the [available data sources](/devenv/docker/blocks). Note that some data sources have specific Docker images for macOS, e.g. `nginx_proxy_mac`.
See the repository for all the [available data sources](/devenv/docker/blocks). Note that some data sources have specific Docker images for macOS, e.g. `prometheus_mac`.
## Build a Docker image

View File

@@ -1,22 +0,0 @@
# Upgrading dependencies
Notes on upgrading various backend dependencies.
# Protobuf
When upgrading the [protobuf](http://github.com/golang/protobuf) library in Grafana and the plugin SDK,
you typically also want to upgrade your protobuf compiler toolchain and re-compile protobuf files:
```
cd $GRAFANA
make protobuf
cd $GRAFANA_PLUGIN_SDK_GO
mage protobuf
```
After upgrading the protobuf dependency in Grafana and the plugin SDK, it might be wise to test that things still work,
before making corresponding PRs:
* Test a plugin built with upgraded SDK on upgraded Grafana
* Test a plugin built with non-upgraded SDK on upgraded Grafana
* Test a plugin built with upgraded SDK on non-upgraded Grafana

View File

@@ -1,17 +0,0 @@
# Grafana technical terminology
<!-- Keep terms in alphabetical order: -->
This document defines technical terms used in Grafana.
## TLS/SSL
The acronyms [TLS](https://en.wikipedia.org/wiki/Transport_Layer_Security) (Transport Layer Security and
[SSL](https://en.wikipedia.org/wiki/SSL) (Secure Socket Layer) are both used to describe the HTTPS security layer,
and are in practice synonymous. However, TLS is considered the current name for the technology, and SSL is considered
[deprecated](https://tools.ietf.org/html/rfc7568).
As such, while both terms are in use (also in our codebase) and are indeed interchangeable, TLS is the preferred term.
That said however, we have at Grafana Labs decided to use both acronyms in combination when referring to this type of
technology, i.e. _TLS/SSL_. This is in order to not confuse those who may not be aware of them being synonymous,
and SSL still being so prevalent in common discourse.

View File

@@ -1,118 +0,0 @@
# Merge a pull request
When a pull request has been reviewed and approved by at least one person and all checks have passed it's time to merge the pull request.
## Who is expected to merge a pull request?
Maintainers are responsible for merging all pull requests. If a maintainer has opened a pull request the general rule is that the same maintainer merges the pull request. If a non-maintainer has opened a pull request it's suggested that one of the maintainers reviewing the pull request merges the pull request.
## Checklist/summary
The following checklist/summary should give you a quick overview of what to ask/consider before merging a pull request.
- Reviewed and approved?
- All checks passed?
- Proper pull request title?
- Milestone assigned?
- Add to changelog/release notes?
- Needs backporting?
## Before merge
Before actually merging a pull request there's a couple of things to take into consideration.
### Format the pull request title
Make sure that the pull request title is properly formatted according to `<Area>: <Summary>` and try to make the summary short and understandable for the community as a whole.
All commits in a pull request are squashed when merged and the pull request title will be the default subject line of the squashed commit message. It's also used for [changelog/release notes](#include-in-changelog-and-release-notes).
See [formatting guidelines](create-pull-request.md#formatting-guidelines) for more information.
### Assign a milestone
It's recommended to add a milestone to every pull request. This makes it easier to track what changes did go into a certain release. Without this you're basically left with going through git commits which could be a lot harder.
There's also various tooling built that in some cases requires a pull request to be assigned a milestone, for example [generating changelog/release notes](#include-in-changelog-and-release-notes).
### Include in changelog and release notes?
At Grafana we generate the [changelog](https://github.com/grafana/grafana/blob/main/CHANGELOG.md) and [release notes](https://grafana.com/docs/grafana/latest/release-notes/) based on merged pull requests. Including changes in the changelog/release notes is very important to provide a somewhat complete picture of what changes a Grafana release actually includes.
Exactly what changes should be added to the changelog is hard to answer but some general guidance would be any change that you think would be interesting for the community as a whole. Use your best judgement and/or ask other maintainers for advice.
There's a GitHub action available in the repository named [Update changelog](https://github.com/grafana/grafana/blob/main/.github/workflows/update-changelog.yml) that can manually be triggered to re-generate the changelog and release notes for any release.
To include a pull request in the changelog/release notes the general rule of thumb is that a milestone should be assigned and labeled with `add to changelog`.
The changelog/release notes are divided into sections and here's a description of how you make a pull request show up in a certain section.
**Features and enhancements:**
Milestone assigned and labeled with `add to changelog` and any of the other section rules don't apply.
**Bug fixes:**
Milestone assigned and labeled with `add to changelog` and either labeled with `type/bug` or the pull request title contains `fix` or `fixes`.
**Plugin development fixes & changes:**
Milestone assigned and labeled with `area/grafana/toolkit`, `area/grafana/ui` or `area/grafana/runtime`.
**Deprecations:**
In case the pull request introduces a deprecation you should document this. Label the pull request with `add to changelog` and use the following template at the end of the pull request description describing the deprecation change.
```md
# Deprecation notice
<Deprecation description>
```
**Breaking changes:**
In case the pull request introduces a breaking change you should document this. Label the pull request with `add to changelog` and `breaking change` and use the following template at the end of the pull request description describing the breaking change.
```md
# Release notice breaking change
<Breaking change description>
```
### Should the pull request be backported?
If your pull request has changes that need to go into one or several existing release branches you need to backport the changes. Please refer to [Backport PR](.github/bot.md#backport-pr) for detailed instructions.
Some examples when backport is required:
- The change needs to be released in the next upcoming patch release, e.g. v8.1.3, so you have to backport it, e.g. into the v8.1.x release branch.
- You have a change to be released in the next major/minor release, e.g. v8.0.0, and there's already a release branch, e.g. v8.0.x, you have to backport it, e.g. into the v8.0.x release branch.
- The change includes documentation changes that needs to be updated for one or multiple older versions, then you have to backport it to each release branch.
Some examples when backport is not required:
- The change is supposed to be released in the next major/minor release, e.g. v8.0.0, but the release branch, e.g. v8.0.x, has not yet been created.
> **Note:** You can still backport a pull request after it's been merged.
## Doing the actual merge
Time to actually merge the pull request changes. All commits in a pull request are squashed, hence the GitHub `Squash and merge` button is used to initialize the merge.
This will present you with options allowing you to optionally change the commit message before merging. Please remember that developers might use the commit information when reviewing changes of files, doing git blame and resolving merge conflicts etc., trying to quickly figure out what the actual change was. But there's not really any best practices around this, the following is an attempt to bring some guidance.
Do:
- Make sure the pull request title is formatted properly before merging, this will automatically give you a good and short summary of the commit/change.
- Leave `Co-authored-by:` lines as is so that co-authors will be accounted for the contribution.
- Remove any commit information that doesn't bring any context to the change.
Consider:
- Add any references to issues that the pull request fixes/closes/references to ease giving quick context to things. Doing this allows cross-reference between the commit and referenced issue(s).
Finalize the merge by clicking on the `Confirm squash and merge` button.
## After the merge
Make sure to close any referenced/related issues. It's recommended to assign the same milestone on the issues that the pull request fixes/closes, but not required.

View File

@@ -20,7 +20,7 @@ We use the standard following linters:
In addition to the standard linters, we also use:
- [revive](https://revive.run/) with a [custom config](https://github.com/grafana/grafana/blob/main/conf/revive.toml)
- [revive](https://revive.run/) with a [custom config](https://github.com/grafana/grafana/blob/master/conf/revive.toml)
- [GolangCI-Lint](https://github.com/golangci/golangci-lint)
- [gosec](https://github.com/securego/gosec)

View File

@@ -2,77 +2,70 @@
This style guide applies to all documentation created for Grafana products.
For information about how to write technical documentation, refer to the following resources:
For information about how to write technical documentation, we suggest reviewing the content of the [Google Technical Writing courses](https://developers.google.com/tech-writing).
- [Google Technical Writing courses](https://developers.google.com/tech-writing)
- [Divio documentation system](https://documentation.divio.com/)
- [Vue writing principles](https://v3.vuejs.org/guide/contributing/writing-guide.html#principles)
The [Divio documentation system](https://documentation.divio.com/) site and the [Vue writing principles](https://v3.vuejs.org/guide/contributing/writing-guide.html#principles) are also good resources.
## Contributing
The _Documentation style guide_ is a living document. Add to it whenever a style decision is made or a question is answered regarding style, grammar, or word choice.
The *Documentation style guide* is a living document. Add to it whenever a style decision is made or a question is answered regarding style, grammar, or word choice.
## Published guides
For all items that are not covered in this guide, refer to the [Google developer documentation style guide](https://developers.google.com/style) and the [Microsoft style guide](https://docs.microsoft.com/en-us/style-guide/welcome/), in that order.
For all items not covered in this guide, refer to the [Microsoft Style Guide](https://docs.microsoft.com/en-us/style-guide/welcome/) and the [Chicago Manual of Style](https://www.chicagomanualofstyle.org/home.html).
## Spelling
To catch common misspellings, the [codespell](https://github.com/codespell-project/codespell) tool is run for every change.
The [codespell](https://github.com/codespell-project/codespell) tool is run for every change to catch common misspellings.
## Inclusive language
Avoid using charged language.
This section provides guidelines on how to avoid using charged language in documentation.
### Allowing and blocking
When referring to _allowing_ or _blocking_ content or traffic, use a form of _allow_ or _block_:
Don't use "whitelist" or "blacklist" when referring to allowing or blocking content or traffic.
- (noun) _allowlist_ or _blocklist_
- (verb) _allow_ or _block_
- When used as a noun, use "allowlist" or "blocklist".
- When used as a verb, use "allow" or "block"
Example: _To **allow** outgoing traffic, add the IP to the **allowlist**._
Avoid _whitelist_ or _blacklist_.
### Leader and follower
### Primary and secondary
Don't use "master" or "slave" to describe relationships between nodes or processes.
To describe relationships between nodes or processes, there are several options:
- Use "leader", "main" or "primary," instead of "master."
- Use "follower" or "secondary," instead of "slave."
- Use _primary_, _main_, or _parent_, instead of _master_.
- Use _secondary_, _replica_, or _child_, instead of _slave_.
### Exceptions
Avoid _master_ or _slave_.
When referring to a configuration or settings used by third-party libraries och technologies outside the Grafana project, prefer the original name to avoid confusion.
For example, use "master" when referring to the default Git branch.
## Grafana-specific style
The following guidelines are specific to Grafana documentation. For the most part, these are _guidelines_ are not rigid rules. If you have questions, then please ask in the #docs channel of Grafana Slack.
The following sections provide general guidelines on topics specific to Grafana documentation. Note that for the most part, these are *guidelines*, not rigid rules. If you have questions, ask in the #docs channel of Grafana Slack.
### General
Per the [Voice and tone](https://developers.google.com/style/tone) section of the Google developer documentation style guide:
> In your documents, aim for a voice and tone that's conversational, friendly, and respectful without being overly colloquial or frivolous; a voice that's casual and natural and approachable, not pedantic or pushy. Try to sound like a knowledgeable friend who understands what the developer wants to do.
- Use active voice:
- Active: Grafana displays the heatmap visualization.
- Passive: The heatmap visualization is displayed.
- Write directly to the reader:
- Use active voice. Avoid passive voice.
- Use active: Grafana displays the heatmap visualization.
- Avoid passive: The heatmap visualization is displayed.
- Write directly to the reader.
- Use: "After you create a dashboard, you can add a panel to it."
- Avoid: "After you create a dashboard, it is possible to add a panel to it."
- Write in the imperative second person:
- "Click the panel."
- "Close the window."
- Write in present tense:
- Use: "The panel opens."
- Avoid: "The panel will open."
- Do not use an ampersand (&) as an abbreviation for _and_.
- Write in the imperative second person. Examples: You can write a query. Click the panel. Close the window.
- Write in present tense.
- Use: The panel opens. Grafana opens the panel.
- Not: The panel will open.
- Do not use an ampersand (&) as an abbreviation for "and."
- **Exceptions:** If an ampersand is used in the Grafana UI, then match the UI.
- Avoid using internal jargon or slang.
- Do not use two spaces after a period; use one space after a sentence.
- Remove any extra space characters at the end of a paragraph.
- Aim for your sentences to be fewer than 25 words. Instead, use smaller complete phrases or change the format, such as using a list.
- Aim for paragraphs to be three sentences or fewer. Make the text more concise, use more headings, or both.
- Avoid using internal slang and jargon in technical documentation.
- Do not use two spaces after a period. Only add one space after each sentence. Do not add a space at the end of the paragraph.
- Sentence length should be 25 words or less. If your thought is longer than 25 words, consider breaking up the sentence or changing the format to a list.
- Paragraphs should be three sentences or fewer. Break up long paragraphs.
### File naming conventions
@@ -108,7 +101,6 @@ However, sometimes we need to use headings as numbered steps. This is mostly in
If that is the case, then use the following format for headings:
##### Step 1. Install the software
##### Step 2. Run the software
### Images
@@ -119,17 +111,10 @@ If that is the case, then use the following format for headings:
- Assume all graphics will be exclusively viewed on the web.
- Maximum image size is 3840px X 2160px.
- Screenshots should be readable, but not too large.
- _Do not_ use image shortcodes. Follow the guidance in the [Grafana markdown guide](https://github.com/grafana/grafana/blob/main/contribute/style-guides/documentation-markdown-guide.md#images).
- _Do not_ use image shortcodes. Follow the guidance in the [Grafana markdown guide](https://github.com/grafana/grafana/blob/master/contribute/style-guides/documentation-markdown-guide.md#images).
- Markdown image links are preferred. Only use the HTML image links if you need to style the image in ways unsupported in Markdown.
- When you name a file, follow the [file naming conventions](#file-naming-conventions). Example: image-name-7-3.png
### Unordered lists
Here are a few general rules about unordered lists. For more guidance, refer to [Lists](https://developers.google.com/style/lists) in the [Google developer style guide](https://developers.google.com/style/).
- List items should begin with a capital letter unless there is a strong reason not to. For example, you are listing case-sensitive parameters.
- List items should end with periods if they are complete sentences. If one item in a list ends with a period, then apply periods to all of them.
### Capitalization
- Grafana, Loki, and Prometheus are always capitalized unless part of a code block.
@@ -154,24 +139,11 @@ In general, "integration" is not capitalized. Only capitalize it if it is capita
The first letter of the name of an integration is always capitalized, even if the original named source is lowercase.
**Examples:**
- MySQL Integration
- CockroachDB Integration
- Etcd Integration
- I installed an integration on my local Grafana.
#### Kubernetes objects
Capitalize Kubernetes objects such as Job, Pod, and StatefulSet when it is clear you are specifically talking about them and not generic jobs, pods, or whatever.
Introduce the object as "Kubernetes XX" on the first usage, then just the object in subsequent uses.
**Example:**
Create the Kubernetes Job and check the logs to retrieve the generated token:
The Job requires the token be submitted as …
### Links and references
When referencing another document, use "Refer to" rather than alternatives such as "See" or "Check out."
@@ -218,20 +190,16 @@ Warnings tell the user not to do something. For example:
- Do not assume everyone is using Linux. Make sure instructions include enough information for Windows and Mac users to successfully complete procedures.
- Do not add `$` before commands. Make it easy for users to copy and paste commands.
- **Right:** `sudo yum install grafana`
- **Wrong:** `$ sudo yum install grafana`
- Include `sudo` before commands that require `sudo` to work.
For terminal examples and Grafana configuration, use a `bash` code block:
```bash
sudo yum install grafana
```
For HTTP request/response, use an `http` code block:
```http
GET /api/dashboards/id/1/permissions HTTP/1.1
Accept: application/json
@@ -269,7 +237,6 @@ Two words if used as a verb, one word if used as a noun.
Two words, not one.
**Exceptions:**
- "datasource" used as an identifier
- "datasource" in a URL
- Use "data source" instead of "datasource" unless used as an identifier, in code, or as part of a URL.
@@ -278,8 +245,7 @@ Two words, not one.
#### display (verb)
_Display_ is a transitive verb, which means it always needs a direct object.
*Display* is a transitive verb, which means it always needs a direct object.
- Correct, active voice: Grafana displays your list of active alarms.
- Correct, but passive voice: Your list of active alarms is displayed.
- Incorrect: The list of active alarms displays.
@@ -306,15 +272,6 @@ Do not hyphenate when used as an adjective unless the lack of hyphen would cause
Do not hyphenate when it is used as a noun. For example: _Open source is the best way to develop software._
#### plugin, plug in
Two words if used as a verb, one word if used as a noun. Do not use _plug-in_.
**Examples**
- Plug in the appliance.
- Download the plugin.
#### setup, set up
Two words if used as a verb, one word if used as a noun.
@@ -324,22 +281,14 @@ Two words if used as a verb, one word if used as a noun.
- Set up the workspace.
- Initial setup might take five minutes.
#### node_exporter, windows_exporter
### node_exporter, windows_exporter
When referencing the Prometheus data source exporters, always use "node_exporter" and "windows_exporter" when referring to those tools.
**Correct:** node_exporter, windows_exporter
**Incorrect:** Node Exporter, node exporter, Windows Exporter, Windows exporter, windows exporter.
#### web server
Two words, not one.
**Correct:** web server
**Incorrect:** webserver
### MS SQL Server
Always use "MS SQL" when referring to MS SQL Server application.
Incorrect UI spellings will be corrected in a later version of Grafana.

View File

@@ -23,13 +23,20 @@ Inspired by https://martinfowler.com/bliki/PageObject.html
Let's start with a simple [JSX](https://reactjs.org/docs/introducing-jsx.html) example containing a single input field that we want to populate during our E2E test:
```jsx
<input className="gf-form-input login-form-input" type="text" />
<input
className="gf-form-input login-form-input"
type="text"
/>
```
We _could_ target the field with a CSS selector like `.gf-form-input.login-form-input` but that would be brittle as style changes occur frequently. Furthermore there is nothing that signals to future developers that this input is part of an E2E test. At Grafana, we use `aria-label` attributes as our preferred way of defining selectors instead of [`data-*`](https://mdn.io/docs/Web/HTML/Global_attributes/data-*) as they also aid in [accessibility](https://mdn.io/docs/Learn/Accessibility/What_is_accessibility):
```jsx
<input aria-label="Username input field" className="gf-form-input login-form-input" type="text" />
<input
aria-label="Username input field"
className="gf-form-input login-form-input"
type="text"
/>
```
The next step is to create a `Page` representation in our E2E framework to glue the test with the real implementation using the `pageFactory` function. For that function we can supply a `url` and `selectors` like in the example below:
@@ -38,6 +45,7 @@ The next step is to create a `Page` representation in our E2E framework to glue
export const Login = {
// Called via `Login.visit()`
url: '/login',
// Called via `Login.username()`
username: 'Username input field',
};
@@ -59,7 +67,11 @@ Now that we have a `Page` called `Login` in our `Pages` const we can use that to
```jsx
import { selectors } from '@grafana/e2e-selectors';
<input aria-label={selectors.pages.Login.username} className="gf-form-input login-form-input" type="text" />;
<input
aria-label={selectors.pages.Login.username}
className="gf-form-input login-form-input"
type="text"
/>
```
The last step in our example is to use our `Login` page as part of a test.
@@ -74,7 +86,9 @@ describe('Login test', () => {
e2e.pages.Login.visit();
// To prevent flaky tests, always do a `.should` on any selector that you expect to be in the DOM.
// Read more here: https://docs.cypress.io/guides/core-concepts/retry-ability.html#Commands-vs-assertions
e2e.pages.Login.username().should('be.visible').type('admin');
e2e.pages.Login.username()
.should('be.visible')
.type('admin');
});
});
```
@@ -140,52 +154,9 @@ describe('List test', () => {
e2e.pages.DataSources.visit();
// To prevent flaky tests, always do a .should on any selector that you expect to be in the DOM.
// Read more here: https://docs.cypress.io/guides/core-concepts/retry-ability.html#Commands-vs-assertions
e2e.pages.DataSources.dataSources('B').should('be.visible').click();
e2e.pages.DataSources.dataSources('B')
.should('be.visible')
.click();
});
});
```
## Aria-Labels vs data-testid
Our selectors are set up to work with both aria-labels and data-testid attributes. Aria-labels help assistive technologies such as screenreaders identify interactive elements of a page for our users.
A good example of a time to use an aria-label might be if you have a button with an X to close:
```
<button aria-label="close">X<button>
```
It might be clear visually that the X closes the modal, but audibly it would not be clear for example.
```
<button aria-label="close">Close<button>
```
The example might read aloud to a user as "Close, Close" or something similar.
However adding aria-labels to elements that are already clearly labeled or not interactive can be confusing and redundant for users with assistive technologies.
In such cases rather than adding unnecessary aria-labels to components so as to make them selectable for testing, it is preferable to use a data attribute that would not be read aloud with an assistive technology for example:
```
<button data-testid="modal-close-button">Close<button>
```
We have added support for this in our selectors, to use:
Prefix your selector string with "data-testid":
```typescript
export const Components = {
Login: {
openButton: 'open-button', // this would look for an aria-label
closeButton: 'data-testid modal-close-button', // this would look for a data-testid
},
};
```
and in your component, import the selectors and add the data test id:
```
<button data-testid={Selectors.Components.Login.closeButton}>
```

View File

@@ -5,7 +5,6 @@ Generally we follow the Airbnb [React Style Guide](https://github.com/airbnb/jav
## Table of Contents
- [Frontend Style Guide](#frontend-style-guide)
- [Table of Contents](#table-of-contents)
- [Basic rules](#basic-rules)
- [Naming conventions](#naming-conventions)
@@ -29,12 +28,12 @@ Generally we follow the Airbnb [React Style Guide](https://github.com/airbnb/jav
- [Linting](#linting)
- [React](#react)
- [Props](#props)
- [Name callback props and handlers with an "on" prefix.](#name-callback-props-and-handlers-with-an-on-prefix)
- [React Component definitions](#react-component-definitions)
- [React Component constructor](#react-component-constructor)
- [React Component defaultProps](#react-component-defaultprops)
- [Name callback props and handlers with an "on" prefix.](#name-callback-props-and-handlers-with-an-on-prefix)
- [React Component definitions](#react-component-definitions)
- [React Component constructor](#react-component-constructor)
- [React Component defaultProps](#react-component-defaultprops)
- [State management](#state-management)
- [Proposal for removing or replacing Angular dependencies](https://github.com/grafana/grafana/pull/23048)
## Basic rules
@@ -195,12 +194,12 @@ _SASS styles are deprecated. Please migrate to Emotion whenever you need to modi
### Typing
In general, you should let Typescript infer the types so that there's no need to explicitly define type for each variable.
In general, you should let Typescript infer the types so that there's no need to explicitly define type for each variable.
There are some exceptions to this:
```typescript
// Typescript needs to know type of arrays or objects otherwise it would infer it as array of any
// Typescript needs to know type of arrays or objects otherwise it would infer it as array of any
// bad
const stringArray = [];
@@ -209,7 +208,7 @@ const stringArray = [];
const stringArray: string[] = [];
```
Specify function return types explicitly in new code. This improves readability by being able to tell what a function returns just by looking at the signature. It also prevents errors when a function's return type is broader than expected by the author.
Specify function return types explicitly in new code. This improves readability by being able to tell what a function returns just by looking at the signature. It also prevents errors when a function's return type is broader than expected by the author.
> **Note:** We don't have linting for this enabled because of lots of old code that needs to be fixed first.
@@ -217,18 +216,18 @@ Specify function return types explicitly in new code. This improves readability
// bad
function transform(value?: string) {
if (!value) {
return undefined;
return undefined
}
return applyTransform(value);
}
return applyTransform(value)
};
// good
function transform(value?: string): TransformedValue | undefined {
if (!value) {
return undefined;
return undefined
}
return applyTransform(value);
}
return applyTransform(value)
};
```
### File and directory naming conventions
@@ -245,8 +244,6 @@ For files exporting multiple utility functions, use the name that describes the
- Use `reducers.ts` Redux reducers.
- Use `*.test.ts(x)` for test files.
- Use kebab case for directory names: lowercase, words delimited by hyphen ( `-` ). For example, `features/new-important-feature/utils.ts`.
### Code organization
Organize your code in a directory that encloses feature code:

View File

@@ -147,7 +147,7 @@ The [controls addon](https://storybook.js.org/docs/react/essentials/controls) pr
#### Migrating a story from Knobs to Controls
As a test, we migrated the [button story](https://github.com/grafana/grafana/blob/main/packages/grafana-ui/src/components/Button/Button.story.tsx). Here's the guide on how to migrate a story to controls.
As a test, we migrated the [button story](https://github.com/grafana/grafana/blob/master/packages/grafana-ui/src/components/Button/Button.story.tsx). Here's the guide on how to migrate a story to controls.
1. Remove the `@storybook/addon-knobs` dependency.
2. Import the Story type from `@storybook/react`

View File

@@ -10,7 +10,7 @@ For styling components, use [Emotion's `css` function](https://emotion.sh/docs/e
```tsx
import React from 'react';
import { css } from '@emotion/css';
import { css } from 'emotion';
const ComponentA = () => (
<div
@@ -27,57 +27,37 @@ const ComponentA = () => (
To access the theme in your styles, use the `useStyles` hook. It provides basic memoization and access to the theme object.
> Please remember to put `getStyles` function at the end of the file!
```tsx
import React, { FC } from 'react';
import { GrafanaTheme } from '@grafana/data';
import { useStyles } from '@grafana/ui';
import { css } from '@emotion/css';
import { css } from 'emotion';
const Foo: FC<FooProps> = () => {
const styles = useStyles(getStyles);
// Use styles with classNames
return <div className={styles}>...</div>;
};
const getStyles = (theme: GrafanaTheme) => css`
const getComponentStyles = (theme: GrafanaTheme) => css`
padding: ${theme.spacing.md};
`;
const Foo: FC<FooProps> = () => {
const styles = useStyles(getComponentsStyles);
// Use styles with className
};
```
### Styling complex components
In more complex cases, especially when you need to style multiple DOM elements in one component, or when using styles that depend on properties and/or state, you should create a helper function that returns an object of styles. This function should also be wrapped in the `stylesFactory` helper function, which will provide basic memoization.
Let's say you need to style a component that has a different background depending on the `isActive` property :
Let's say you need to style a component that has a different background depending on the theme:
```tsx
import React from 'react';
import { css } from '@emotion/css';
import { css } from 'emotion';
import { GrafanaTheme } from '@grafana/data';
import { selectThemeVariant, stylesFactory, useTheme } from '@grafana/ui';
interface ComponentAProps {
isActive: boolean;
}
const ComponentA: React.FC<ComponentAProps> = ({ isActive }) => {
const theme = useTheme();
const styles = getStyles(theme, isActive);
return (
<div className={styles.wrapper}>
As red as you can get
<i className={styles.icon} />
</div>
);
};
// Mind, that you can pass multiple arguments, theme included
const getStyles = stylesFactory((theme: GrafanaTheme, isActive: boolean) => {
const backgroundColor = isActive ? theme.colors.red : theme.colors.blue;
const getStyles = stylesFactory((theme: GrafanaTheme) => {
const backgroundColor = selectThemeVariant({ light: theme.colors.red, dark: theme.colors.blue }, theme.type);
return {
wrapper: css`
@@ -88,6 +68,18 @@ const getStyles = stylesFactory((theme: GrafanaTheme, isActive: boolean) => {
`,
};
});
const ComponentA = () => {
const theme = useTheme();
const styles = getStyles(theme);
return (
<div className={styles.wrapper}>
As red as you can get
<i className={styles.icon} />
</div>
);
};
```
For more information about themes at Grafana please see the [themes guide](./themes.md).
@@ -98,7 +90,7 @@ For class composition, use [Emotion's `cx` function](https://emotion.sh/docs/emo
```tsx
import React from 'react';
import { css, cx } from '@emotion/css';
import { css, cx } from 'emotion';
interface Props {
className?: string;

View File

@@ -4,8 +4,11 @@
**Themes are implemented in Typescript.** That's because our goal is to share variables between Grafana TypeScript and [Sass](https://sass-lang.com/) code. Theme definitions are located in the following files:
- [packages/grafana-data/src/themes/createTheme.ts](../../packages/grafana-data/src/themes/createTheme.ts)
- [packages/grafana-data/src/themes/createColors.ts](../../packages/grafana-data/src/themes/createColors.ts)
- [packages/grafana-ui/src/themes/dark.ts](../../packages/grafana-ui/src/themes/dark.ts)
- [packages/grafana-ui/src/themes/default.ts](../../packages/grafana-ui/src/themes/default.ts)
- [packages/grafana-ui/src/themes/light.ts](../../packages/grafana-ui/src/themes/light.ts)
The `default.ts` file holds common variables like typography and spacing definitions, while `[light|dark].ts` primarily specify colors used in themes.
## Usage
@@ -15,22 +18,23 @@ This section provides usage guidelines.
Here's how to use Grafana themes in React components.
#### useStyles2 hook
#### useStyles hook
`useStyles2` memoizes the function and provides access to the theme.
`useStyles` memoizes the function and provides access to the theme.
```tsx
import React, { FC } from 'react';
import { GrafanaTheme2 } from '@grafana/data';
import { useStyles2 } from '@grafana/ui';
import { css } from '@emotion/css';
import { GrafanaTheme } from '@grafana/data';
import { useStyles } from '@grafana/ui';
import { css } from 'emotion';
const getComponentStyles = (theme: GrafanaTheme2) => css`
const getComponentStyles = (theme: GrafanaTheme) => css`
padding: ${theme.spacing.md};
`;
const Foo: FC<FooProps> = () => {
const styles = useStyles2(getComponentsStyles);
const styles = useStyles(getComponentsStyles);
// Use styles with className
};
```
@@ -39,95 +43,21 @@ const Foo: FC<FooProps> = () => {
```tsx
import React, { FC } from 'react';
import { useTheme2 } from '@grafana/ui';
import { useTheme } from '@grafana/ui';
const Foo: FC<FooProps> = () => {
const theme = useTheme2();
const theme = useTheme();
// Your component has access to the theme variables now
};
```
## Picking the right variable
### The rich color object and the state colors
The theme.colors object has 6 rich color objects for `primary`, `secondary`, `info`, `success`, `warning` and `error`. These all
have the same sub colors that have different use cases.
| Property | When to use |
| ------------ | ---------------------------------------------------------- |
| main | For backgrounds |
| shade | For hover highlight |
| text | For text color |
| border | For borders, currently always the same as text color |
| contrastText | Text color to use for text placed on top of the main color |
Example use cases:
- Want a `red` background? Use `theme.colors.error.main`
- Want `green` text? Use `theme.colors.success.text`
- Want text to be visible when placed inside a background that uses `theme.colors.error.main` then use `theme.colors.error.contrastText`.
### Text colors
| Property | When to use |
| ----------------------------- | ------------------------------------------------------------------------------ |
| theme.colors.text.primary | The default text color |
| theme.colors.text.secondary | Text color for things that should be a bit less prominent |
| theme.colors.text.disabled | Text color for disabled / faint things |
| theme.colors.text.link | Text link color |
| theme.colors.text.maxContrast | Maximum contrast (absolute white in dark theme, absolute black in white theme) |
### Background colors
| Property | When to use |
| --------------------------------- | ------------------------------------------------------------------------------------------------- |
| theme.colors.background.canvas | Think dashboard background. A background surface for panels and panes that use primary background |
| theme.colors.background.primary | The default content background for content panes and panels |
| theme.colors.background.secondary | For cards and other surfaces that need to stand out when placed on top of the primary background |
### Borders
| Property | When to use |
| -------------------------- | ------------------------------------------------------------ |
| theme.colors.border.weak | Primary border for panels and panes and other subtle borders |
| theme.colors.border.medium | For stronger borders like inputs |
| theme.colors.border.strong | For even stronger border like hover highighted border |
### Actions
| Property | When to use |
| ---------------------------- | ----------------------------------------------------- |
| theme.colors.action.hover | Background color for hover on card, menu or list item |
| theme.colors.action.focus | Background color for focused card, menu or list item |
| theme.colors.action.selected | Background color for selected card, menu or list item |
### Paddings and margins
| Example | Result |
| --------------------------- | ----------------- |
| theme.spacing(1) | 8px |
| theme.spacing(1, 2) | 8px 16px |
| theme.spacing(1, 2, 0.5, 4) | 8px 16px 4px 32px |
### Border radius
| Example | Result |
| --------------------------- | ------ |
| theme.shape.borderRadius(1) | 2px |
| theme.shape.borderRadius(2) | 4px |
### Typography
For font family, font sizes and line heights use the variables under `theme.typography`.
#### Using `ThemeContext` directly
```tsx
import { ThemeContext } from '@grafana/ui';
<ThemeContext.Consumer>{(theme) => <Foo theme={theme} />}</ThemeContext.Consumer>;
<ThemeContext.Consumer>{theme => <Foo theme={theme} />}</ThemeContext.Consumer>;
```
#### Using `withTheme` higher-order component (HOC)
@@ -137,25 +67,40 @@ With this method your component will be automatically wrapped in `ThemeContext.C
```ts
import { ThemeContext, Themeable } from '@grafana/ui';
interface FooProps extends Themeable2 {}
interface FooProps extends Themeable {}
const Foo: React.FunctionComponent<FooProps> = () => ...
export default withTheme2(Foo);
export default withTheme(Foo);
```
### Using theme in tests
### Test components that use `ThemeContext`
If you need to pass a theme object to a function under test just import `createTheme` and call it without
any arguments.
When implementing snapshot tests for components that use the `withTheme` HOC, the snapshot will contain the entire theme object. Any change to the theme renders the snapshot outdated.
To make your snapshot theme independent, use the `mockThemeContext` helper function:
```tsx
import { createTheme } from '@grafana/data';
import { mockThemeContext } from '@grafana/ui';
import { MyComponent } from './MyComponent';
describe('MyComponent', () => {
it('should work', () => {
result = functionThatNeedsTheme(createTheme());
expect(result).toBe(true);
let restoreThemeContext;
beforeAll(() => {
// Create ThemeContext mock before any snapshot test is executed
restoreThemeContext = mockThemeContext({ type: GrafanaThemeType.Dark });
});
afterAll(() => {
// Make sure the theme is restored after snapshot tests are performed
restoreThemeContext();
});
it('renders correctly', () => {
const wrapper = mount(<MyComponent />)
expect(wrapper).toMatchSnapshot();
});
});
```
@@ -172,5 +117,36 @@ This section provides insight into frequently-asked questions.
`[_variables|_variables.dark|_variables.light].generated.scss` files are the ones that are referenced in the main Sass files for Sass variables to be available. **These files are automatically generated and should never be modified by hand!**
If you need to modify the sass variable files be sure to update the files that end with `.tmpl.ts` and
not the `.generated.scss` files.
#### If you need to modify a _Sass variable value_ you need to modify the corresponding Typescript file that is the source of the variables:
- `_variables.generated.scss` - modify `grafana-ui/src/themes/default.ts`
- `_variables.light.generated.scss` - modify `grafana-ui/src/themes/light.ts`
- `_variables.dark.generated.scss` - modify `grafana-ui/src/themes/dark.ts`
#### If you need to _add new variable_ to Sass variables you need to modify corresponding template file:
- `_variables.generated.scss` - modify `grafana-ui/src/themes/_variables.scss.tmpl.ts`
- `_variables.light.generated.scss` - modify `grafana-ui/src/themes/_variables.light.scss.tmpl.ts`
- `_variables.dark.generated.scss` - modify `grafana-ui/src/themes/_variables.dark.scss.tmpl.ts`
## Limitations
This section describes limitations with Grafana's theming system.
### You must ensure `ThemeContext` provider is available in a React tree
By default all react2angular directives have `ThemeContext.Provider` ensured. But, there are cases where we create another React tree via `ReactDOM.render`. This happens in the case of graph legend rendering and the `ReactContainer` directive. In such cases theme consumption will fail. To make sure theme context is available in such cases, you need to wrap your rendered component with ThemeContext.Provider using the `provideTheme` function:
```ts
// graph.ts
import { provideTheme } from 'app/core/utils/ConfigProvider';
// Create component with ThemeContext.Provider first.
// Otherwise React will create new components every time it renders!
const LegendWithThemeProvider = provideTheme(Legend);
const legendReactElem = React.createElement(LegendWithThemeProvider, legendProps);
ReactDOM.render(legendReactElem, this.legendElem, () => this.renderPanel());
```
`provideTheme` makes current theme available via ThemeContext by checking if user has `lightTheme` set in her boot data.

View File

@@ -1 +0,0 @@
module: "github.com/grafana/grafana"

View File

@@ -1,27 +0,0 @@
package scuemata
// Definition of the shape of a panel plugin's schema declarations in its
// schema.cue file.
//
// Note that these keys do not appear directly in any real JSON artifact;
// rather, they are composed into panel structures as they are defined within
// the larger Dashboard schema.
#PanelSchema: {
// Defines plugin specific options for a panel
PanelOptions: {...} @cuetsy(kind="interface")
// Define the custom properties that exist within standard field config
PanelFieldConfig?: {...} @cuetsy(kind="interface")
// Panels may define their own types
...
}
// A lineage of panel schema
#PanelLineage: [#PanelSchema, ...#PanelSchema]
// Panel plugin-specific Family
#PanelFamily: {
lineages: [#PanelLineage, ...#PanelLineage]
migrations: [...#Migration]
}

View File

@@ -1,61 +0,0 @@
package scuemata
// A family is a collection of schemas that specify a single kind of object,
// allowing evolution of the canonical schema for that kind of object over time.
//
// The schemas are organized into a list of Lineages, which are themselves ordered
// lists of schemas where each schema with its predecessor in the lineage.
//
// If it is desired to define a schema with a breaking schema relative to its
// predecessors, a new Lineage must be created, as well as a Migration that defines
// a mapping to the new schema from the latest schema in prior Lineage.
//
// The version number of a schema is not controlled by the schema itself, but by
// its position in the list of lineages - e.g., 0.0 corresponds to the first
// schema in the first lineage.
#Family: {
compose?: {...}
lineages: [#Lineage, ...#Lineage]
migrations: [...#Migration]
let lseq = lineages[len(lineages)-1]
latest: #LastSchema & {_p: lseq}
}
// A Lineage is a non-empty list containing an ordered series of schemas that
// all describe a single kind of object, where each schema is backwards
// compatible with its predecessor.
#Lineage: [{...}, ...{...}]
#LastSchema: {
_p: #Lineage
_p[len(_p)-1]
}
// A Migration defines a relation between two schemas, "_from" and "_to". The
// relation expresses any complex mappings that must be performed to
// transform an input artifact valid with respect to the _from schema, into
// an artifact valid with respect to the _to schema. This is accomplished
// in two stages:
// 1. A Migration is initially defined by passing in schemas for _from and _to,
// and mappings that translate _from to _to are defined in _rel.
// 2. A concrete object may then be unified with _to, resulting in its values
// being mapped onto "result" by way of _rel.
//
// This is the absolute simplest possible definition of a Migration. It's
// incumbent on the implementor to manually ensure the correctness and
// completeness of the mapping. The primary value in defining such a generic
// structure is to allow comparably generic logic for migrating concrete
// artifacts through schema changes.
//
// If _to isn't backwards compatible (accretion-only) with _from, then _rel must
// explicitly enumerate every field in _from and map it to a field in _to, even
// if they're identical. This is laborious for anything outside trivially tiny
// schema. We'll want to eventually add helpers for whitelisting or blacklisting
// of paths in _from, so that migrations of larger schema can focus narrowly on
// the points of actual change.
#Migration: {
from: {...}
to: {...}
rel: {...}
result: to & rel
}

View File

@@ -0,0 +1,68 @@
package main
#Dashboard: {
// Unique numeric identifier for the dashboard. (generated by the db)
id: int
// Unique dashboard identifier that can be generated by anyone. string (8-40)
uid: string
// Title of dashboard.
title?: string
// Description of dashboard.
description?: string
// Tags associated with dashboard.
tags?: [...string]
// Theme of dashboard.
style: *"light" | "dark"
// Timezone of dashboard,
timezone?: *"browser" | "utc"
// Whether a dashboard is editable or not.
editable: bool | *true
// 0 for no shared crosshair or tooltip (default).
// 1 for shared crosshair.
// 2 for shared crosshair AND shared tooltip.
graphTooltip: int >= 0 <= 2 | *0
// Time range for dashboard, e.g. last 6 hours, last 7 days, etc
time?: {
from: string | *"now-6h"
to: string | *"now"
}
// Timepicker metadata.
timepicker?: {
// Whether timepicker is collapsed or not.
collapse: bool | *false
// Whether timepicker is enabled or not.
enable: bool | *true
// Whether timepicker is visible or not.
hidden: bool | *false
// Selectable intervals for auto-refresh.
refresh_intervals: [...string] | *["5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d"]
}
// Templating.
templating?: list: [...{}]
// Annotations.
annotations?: list: [...{
builtIn: int | *0
// Datasource to use for annotation.
datasource: string
// Whether annotation is enabled.
enable?: bool | *true
// Whether to hide annotation.
hide?: bool | *false
// Annotation icon color.
iconColor?: string
// Name of annotation.
name?: string
// Query for annotation data.
rawQuery: string
showIn: int | *0
}] | *[]
// Auto-refresh interval.
refresh: string
// Version of the JSON schema, incremented each time a Grafana update brings
// changes to said schema.
schemaVersion: int | *25
// Version of the dashboard, incremented each time the dashboard is updated.
version: string
// Dashboard panels.
panels?: [...{}]
}

View File

@@ -0,0 +1,86 @@
# Dashboard Schemas
Schema description documents for [Grafana Dashboard
JSON](https://grafana.com/docs/grafana/latest/reference/dashboard/) and core
panels.
> **Note:** This directory is experimental. The schemas are not currently
> implemented or enforced in Grafana.
Schemas are defined in [Cue](https://cuelang.org/). Cue was chosen because it
strongly facilitates our primary use cases - [schema
definition](https://cuelang.org/docs/usecases/datadef/), [data
validation](https://cuelang.org/docs/usecases/validation/), and [code
generation/extraction](https://cuelang.org/docs/usecases/generate/).
## Schema Organization
Each schema describes part of a dashboard. `Dashboard.cue` is the main dashboard
schema object. All other schemas describe nested objects within a dashboard.
They are grouped in the following directories:
* `panels` - schemas for
[panels](https://grafana.com/docs/grafana/latest/panels/panels-overview/).
* `targets` - targets represent
[queries](https://grafana.com/docs/grafana/latest/panels/queries/). Each [data
source](https://grafana.com/docs/grafana/latest/datasources/) type has a
unique target schema.
* `variables` - schemas for
[variables](https://grafana.com/docs/grafana/latest/variables/variable-types/).
* `transformations` - schemas for
[transformations](https://grafana.com/docs/grafana/latest/panels/transformations/types-options/).
The following somewhat conveys how they fit together when constructing a
dashboard:
```
+-----------+ +-----------+
| Dashboard +------> Variables |
+---------+-+ +-----------+
| +--------+ +---------+
+----> Panels +----> Targets |
+------+-+ +---------+
| +-----------------+
+------> Transformations |
+-----------------+
```
## Definitions
All schemas are [Cue
definitions](https://cuelang.org/docs/references/spec/#definitions-and-hidden-fields).
Schemas intended to be exported must begin with a capital letter. For example,
[Gauge](./panels/Gauge.cue). Definitions beginning with a lowercase letter will
not be exported. These are reusable components for constructing the exported
definitions. For example, [`#panel`](./panels/panel.cue) is intended to
be a base schema for panels. `#Gauge` extends `#panel` with the following:
```
#Gauge: panel & {
...
}
```
## Exporting OpenAPI
[OpenAPI](https://www.openapis.org/) schemas can be exported from these CUE
sources.
### Command Line
While you can use `cue export` to output OpenAPI documents, it does not expand
references which makes the output unusable.
```
cue export --out openapi -o - ./...
```
### Using Go
You need to use Go to generate useable OpenAPI schemas. This directory contains
a Go program that will output just the OpenAPI schemas for one or many Cue
packages.
```
go run . <entrypoint> ...
```

View File

@@ -0,0 +1 @@
module: "github.com/grafana/grafana/dashboard-schemas"

5
dashboard-schemas/go.mod Normal file
View File

@@ -0,0 +1,5 @@
module github.com/grafana/grafana/dashboard-schemas
go 1.15
require cuelang.org/go v0.2.2

185
dashboard-schemas/go.sum Normal file
View File

@@ -0,0 +1,185 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cuelang.org/go v0.2.2 h1:i/wFo48WDibGHKQTRZ08nB8PqmGpVpQ2sRflZPj73nQ=
cuelang.org/go v0.2.2/go.mod h1:Dyjk8Y/B3CfFT1jQKJU0g5PpCeMiDe0yMOhk57oXwqo=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/cockroachdb/apd/v2 v2.0.1 h1:y1Rh3tEU89D+7Tgbw+lp52T6p/GJLpDmNvr10UWqLTE=
github.com/cockroachdb/apd/v2 v2.0.1/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/emicklei/proto v1.6.15 h1:XbpwxmuOPrdES97FrSfpyy67SSCV/wBIKXqgJzh6hNw=
github.com/emicklei/proto v1.6.15/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mpvl/unique v0.0.0-20150818121801-cbe035fff7de h1:D5x39vF5KCwKQaw+OC9ZPiLVHXz3UFw2+psEX+gYcto=
github.com/mpvl/unique v0.0.0-20150818121801-cbe035fff7de/go.mod h1:kJun4WP5gFuHZgRjZUWWuH1DTxCtxbHDOIJsudS8jzY=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-internal v1.6.0/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20200513190911-00229845015e/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200612220849-54c614fe050c h1:g6oFfz6Cmw68izP3xsdud3Oxu145IPkeFzyRg58AKHM=
golang.org/x/tools v0.0.0-20200612220849-54c614fe050c/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 h1:Xe2gvTZUJpsvOWUnvmL/tmhVBZUmHSvLbMjRj6NUUKo=
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

58
dashboard-schemas/main.go Normal file
View File

@@ -0,0 +1,58 @@
package main
import (
"fmt"
"log"
"os"
"cuelang.org/go/cue"
"cuelang.org/go/cue/load"
"cuelang.org/go/encoding/openapi"
)
func main() {
b, err := openAPISchemas(os.Args[1:])
if err != nil {
log.Fatal(err)
}
fmt.Println(string(b))
}
// openAPISchemas returns OpenAPI schema JSON of the Cue entrypoints passed to
// it. It is not a valid OpenAPI document - just the schemas.
func openAPISchemas(entrypoints []string) ([]byte, error) {
var r cue.Runtime
cfg := openapi.Config{
ExpandReferences: true,
}
bis := load.Instances(entrypoints, nil)
// collect all schemas
var pairs []openapi.KeyValue
for _, bi := range bis {
if bi.Err != nil {
return nil, bi.Err
}
inst, err := r.Build(bi)
if err != nil {
return nil, err
}
om, err := cfg.Schemas(inst)
if err != nil {
return nil, err
}
pairs = append(pairs, om.Pairs()...)
}
// add all schemas to new ordered map
om := openapi.OrderedMap{}
om.SetAll(pairs)
j, err := om.MarshalJSON()
if err != nil {
return nil, err
}
return j, nil
}

View File

@@ -0,0 +1,47 @@
package main
import (
"encoding/json"
"testing"
)
func TestOpenAPISchemas(t *testing.T) {
tests := map[string]struct {
entrypoints []string
}{
"All packages": {
entrypoints: []string{"./..."},
},
"One package": {
entrypoints: []string{"./panels"},
},
"Many packags": {
entrypoints: []string{
"./panels",
"./targets",
"./transformations",
"./variables",
},
},
}
for testName, test := range tests {
t.Logf("Running test case %s...", testName)
j, err := openAPISchemas(test.entrypoints)
if err != nil {
t.Fatal(err)
}
// We don't want to validate the JSON content since it's expected to change
// often. Only that it is valid JSON by unmarshalling it.
var iface interface{}
err = json.Unmarshal(j, &iface)
if err != nil {
t.Fatal(err)
}
}
}

View File

@@ -0,0 +1,74 @@
package panels
// Gauge is a single value panel that can repeat a gauge for every series,
// column or row.
#Gauge: _panel & {
// Field config.
fieldConfig: {
// Defaults.
defaults: {
// Custom.
custom: {}
// Unit.
unit: string
// Min.
min: int
// Max.
max: int
// Decimals.
decimals: int
// Change the field or series name.
displayName: string
// What to show when there is no value.
noValue: string
// Threshold config.
thresholds: _thresholds
// Mappings.
mappings: [..._mapping]
// Data Links.
links: [..._dataLink]
}
// Overrides.
overrides: [..._override]
}
// Options.
options: {
// Reduce options.
reduceOptions: {
// * `true` - Show a calculated value based on all rows.
// * `false` - Show a separate stat for every row.
values: bool | *false
// If values is false, sets max number of rows to
// display.
limit: int
// Reducer function/calculation.
calcs: [
"allIsZero",
"allIsNull",
"changeCount",
"count",
"delta",
"diff",
"distinctCount",
"first",
"firstNotNull",
"lastNotNull",
"last",
"logmin",
"max",
"min",
"range",
"step",
"sum",
] | *["mean"]
// Fields that should be included in the panel.
fields: string | *""
}
// Render the threshold values around the gauge bar.
showThresholdLabels: bool | *false
// Render the thresholds as an outer bar.
showThresholdMarkers: bool | *true
}
// Panel type.
type: string | *"gauge"
}

View File

@@ -0,0 +1,192 @@
package panels
#Graph: _panel & {
// Display values as a bar chart.
bars: bool | *false
// Dashed line length.
dashLength: int | *10
// Show line with dashes.
dashes: bool | *false
// Dashed line spacing when `dashes` is true.
spaceLength: int | *10
// Controls how many decimals are displayed for legend values and graph hover
// tooltips.
decimals: int
// Field config.
fieldConfig: {
// Defaults.
defaults: custom: {}
// Overrides.
overrides: [..._override]
}
// Amount of color fill for a series. Expects a value between 0 and 1.
fill: number >= 0 <= 1 | *1
// Degree of gradient on the area fill. 0 is no gradient, 10 is a steep
// gradient.
fillGradient: int >= 0 <= 10 | *0
// Hide the series.
hiddenSeries: bool | *false
// Lengend options.
legend: {
// Whether to display legend in table.
alignAsTable: bool | *false
// Average of all values returned from the metric query.
avg: bool | *false
// Last value returned from the metric query.
current: bool | *false
// Maximum of all values returned from the metric query.
max: bool | *false
// Minimum of all values returned from the metric query.
min: bool | *false
// Display legend to the right.
rightSide: bool | *false
// Show or hide the legend.
show: bool | *true
// Available when `rightSide` is true. The minimum width for the legend in
// pixels.
sideWidth?: int
// Sum of all values returned from the metric query.
total: bool | *false
// Values.
values: bool | *true
}
// Display values as a line graph.
lines: bool | *true
// The width of the line for a series.
linewidth: int | *1
// How null values are displayed.
// * 'null' - If there is a gap in the series, meaning a null value, then the
// line in the graph will be broken and show the gap.
// * 'null as zero' - If there is a gap in the series, meaning a null value,
// then it will be displayed as a zero value in the graph panel.
// * 'connected' - If there is a gap in the series, meaning a null value or
// values, then the line will skip the gap and connect to the next non-null
// value.
nullPointMode: string | *"null"
// Options.
options: {
// Data links.
dataLinks: [..._dataLink]
}
// Available when `stack` is true. Each series is drawn as a percentage of the
// total of all series.
percentage: bool | *false
// Controls how large the points are.
pointradius: int
// Display points for values.
points: bool | *true
// Renderer.
renderer: string | *"flot"
// Series overrides allow a series in a graph panel to be rendered
// differently from the others. You can customize display options on a
// per-series bases or by using regex rules. For example, one series can have
// a thicker line width to make it stand out or be moved to the right Y-axis.
seriesOverrides: [...{
// Alias or regex matching the series you'd like to target.
alias?: string
bars?: bool
lines?: bool
fill?: int
fillGradient?: int
linewidth?: int
nullPointMode?: string
fillBelowTo?: string
steppedLine?: bool
dashes?: bool
hiddenSeries?: bool
dashLength?: int
spaceLength?: int
points?: bool
pointradius?: int
stack?: int
color?: string
yaxis?: int
zindex?: int
transform?: string
legend?: bool
hideTooltip?: bool
}]
// Each series is stacked on top of another.
stack: bool | *false
// Draws adjacent points as staircase.
steppedLine: bool | *false
// Threshold config.
thresholds: _thresholds
// Time from.
timeFrom: string
// Time regions.
timeRegions: [...string]
// Time shift
timeShift: string
// Tooltip settings.
tooltip: {
// * true - The hover tooltip shows all series in the graph. Grafana
// highlights the series that you are hovering over in bold in the series
// list in the tooltip.
// * false - The hover tooltip shows only a single series, the one that you
// are hovering over on the graph.
shared: bool | *true
// * 0 (none) - The order of the series in the tooltip is determined by the
// sort order in your query. For example, they could be alphabetically
// sorted by series name.
// * 1 (increasing) - The series in the hover tooltip are sorted by value
// and in increasing order, with the lowest value at the top of the list.
// * 2 (decreasing) - The series in the hover tooltip are sorted by value
// and in decreasing order, with the highest value at the top of the list.
sort: int >= 0 <= 2 | *2
// Value type.
value_type: string | *"individual"
}
// Panel type.
type: string | *"graph"
xaxis: {
// Buckets.
buckets: string
// The display mode completely changes the visualization of the graph
// panel. Its like three panels in one. The main mode is the time series
// mode with time on the X-axis. The other two modes are a basic bar chart
// mode with series on the X-axis instead of time and a histogram mode.
// * 'time' - The X-axis represents time and that the data is grouped by
// time (for example, by hour, or by minute).
// * 'series' - The data is grouped by series and not by time. The Y-axis
// still represents the value.
// * 'histogram' - Converts the graph into a histogram. A histogram is a
// kind of bar chart that groups numbers into ranges, often called buckets
// or bins. Taller bars show that more data falls in that range.
mode: string | *"time"
// Name.
name: string
// Show or hide the axis.
show: bool | *true
// Values
values: [...number]
}
yaxes: [...{
// Defines how many decimals are displayed for Y value.
decimals: int
// The display unit for the Y value.
format: string | *"short"
// The Y axis label.
label: string
// The scale to use for the Y value - linear, or logarithmic.
// * 1 - linear
// * 2 - log (base 2)
// * 10 - log (base 10)
// * 32 - log (base 32)
// * 1024 - log (base 1024)
logBase: int | *1
// The maximum Y value.
max?: int
// The minimum Y value.
min?: int
// Show or hide the axis.
show: bool | *true
}]
yaxis: {
// Align left and right Y-axes by value.
align: bool | *false
// Available when align is true. Value to use for alignment of left and
// right Y-axes, starting from Y=0.
alignLevel: int | *0
}
}

View File

@@ -0,0 +1,24 @@
package panels
// A row is a logical divider within a dashboard. It is used
// to group panels together.
#Row: {
// Whether the row is collapsed or not.
collapsed: bool | *true
// Name of default data source.
datasource?: string
// Grid position.
gridPos?: _gridPos
// Dashboard panels.
panels?: [...{}]
// Name of template variable to repeat for.
repeat?: string
// Whether to display the title.
showTitle: bool | *true
// Title.
title?: string
// Size of title.
titleSize: string | *"h6"
// Panel type.
type: string | *"row"
}

View File

@@ -0,0 +1,12 @@
package panels
_gridPos: {
// Panel height.
h?: int > 0 | *9
// Panel width.
w?: int > 0 <= 24 | *12
// Panel x position.
x?: int >= 0 < 24 | *0
// Panel y position.
y?: int >= 0 | *0
}

View File

@@ -0,0 +1,14 @@
package panels
_link: {
// Link title.
title?: string
// Whether to open link in new browser tab.
targetBlank: bool | *true
// URL of link.
url: string
}
_panelLink: _link
_dataLink: _link

View File

@@ -0,0 +1,11 @@
package panels
_mapping: {
id: int
from: string
operator: string
to: string
text: string
type: int
value: string
}

View File

@@ -0,0 +1,12 @@
package panels
_override: {
matcher: {
id: string
options: string
}
properties: [...{
id: string
value: int
}]
}

View File

@@ -0,0 +1,24 @@
package panels
_panel: {
// Panel title.
title?: string
// Description.
description?: string
// Whether to display the panel without a background.
transparent: bool | *false
// Name of default datasource.
datasource?: string
// Grid position.
gridPos?: _gridPos
// Panel links.
links?: [..._panelLink]
// Name of template variable to repeat for.
repeat?: string
// Direction to repeat in if 'repeat' is set.
// "h" for horizontal, "v" for vertical.
repeatDirection: *"h" | "v"
// Panel targets - datasource and query configurations to use as
// a basis for vizualization.
targets?: [...{}]
}

View File

@@ -0,0 +1,11 @@
package panels
_thresholds: {
// Threshold mode.
mode: string | *"absolute"
// Threshold steps.
steps: [...{
color: string
value: number
}]
}

View File

@@ -0,0 +1,19 @@
package targets
#Prometheus: {
// Query expression.
expr: string
// Controls the name of the time series, using name or pattern.
legendFormat?: string
// Interval.
interval?: int | *1
// Target reference ID.
refId: string
// Perform an “instant” query, to return only the latest value that
// Prometheus has scraped for the requested time series.
instant: bool | *false
// Resolution.
intervalFactor?: int
// Format.
format: *"time_series" | "table" | "heat_map"
}

View File

@@ -0,0 +1,39 @@
package transformations
// Add field from calculation.
#CalculateField: {
// Transformation ID.
id: string | *"calculateField"
// Configuration options.
options: {
// The name of your new field. If you leave this blank, then the field will
// be named to match the calculation.
alias: string
// Binary options.
binary: {
// Field or number for left side of equation.
left: string
// Field or number for right side of equation.
right: string
// Operator.
operator: string | *"+"
// Calculation to use.
reducer: string | *"sum"
}
// 'reduceRow' - apply selected calculation on each row of selected fields
// independently.
// 'binary' - apply basic math operation(sum, multiply, etc) on values in a
// single row from two selected fields.
mode: *"reduceRow" | "binary"
// Reduce options.
reduce: {
// Calculation to use.
reducer: string
// Fields to include in calculation.
include: [...string]
}
// Hide all other fields and display only your calculated field in the
// visualization.
replaceFields: bool | *false
}
}

View File

@@ -0,0 +1,16 @@
package transformations
// Reorder, hide, or rename fields/columns.
#Organize: {
// Transformation ID.
id: string | *"organize"
// Configuration options.
options: {
// Exclude fields by name.
excludeByName: {}
// Set field order by name.
indexByName: {}
// Rename a field by name.
renameByName: {}
}
}

View File

@@ -0,0 +1,9 @@
package variables
// Custom variables are for values that do not change.
#Custom: _variable & {
// Options as comma separated values.
query: string
// Variable type.
type: string | *"custom"
}

View File

@@ -0,0 +1,18 @@
package variables
// Data source variables allow you to quickly change the data source for an
// entire dashboard.
#Datasource: _variable & {
// Data source type.
query: string
// Query value.
queryValue: string | *""
// Refresh.
refresh: int | *1
// Regex filter for which data source instances to choose
// from in the variable value dropdown. Leave empty for
// all.
regex: string
// Variable type.
type: string | *"datasource"
}

View File

@@ -0,0 +1,30 @@
package variables
// Query variables allow you to write a data source query that can return a
// list of metric names, tag values, or keys.
#Query: _variable & {
// Data source to use.
datasource: string
// Definition.
definition?: string
// Query.
query: string
// Refresh.
refresh: int | *1
// Regex.
regex?: string
// * 0 - Disabled.
// * 1 - Alphabetical (asc).
// * 2 - Alphabetical (desc).
// * 3 - Numerical (asc).
// * 4 - Numerical (desc).
// * 5 - Alphabetical (case-insensitive, asc).
// * 6 - Alphabetical (case-insensitive, desc).
sort: int >= 0 <= 6 | *0
tagValuesQuery?: string
tags: [...string] | *[]
tagsQuery?: string
// Variable type.
type: "query"
useTags: bool | *false
}

View File

@@ -0,0 +1,33 @@
package variables
_variable: {
// Currently selected value.
current: {
selected: bool | *false
text: string | [...string]
value: string | [...string]
}
// Whether to hide the label and variable.
// * 0 - Show all.
// * 1 - Hide label.
// * 2 - Hide label and variable.
hide: int >= 0 <= 2 | *0
// Enable include all option.
includeAll: bool | *false
// When includeAll is enabled, this sets its value.
allValue?: string
// Optional display name.
label?: string
// Allows mutltiple values to be selected at the same time.
multi: bool | *false
// Variable name.
name: string
// Options for variable.
options: [...{
selected: bool
text: string
value: string
}]
// Skip URL sync.
skipUrlSync: bool | *false
}

View File

@@ -26,10 +26,11 @@ found. The dashboards are located in the `devenv/dev-dashboards` folder.
This command creates a docker-compose file with specified databases configured and ready to run. Each database has
a prepared image with some fake data ready to use. For available databases, see `docker/blocks` directory. Notice that
for some databases there are multiple images with different versions. Some blocks such as `slow_proxy_mac` or `apache_proxy_mac` are specifically for Macs.
for some databases there are multiple images, for example there is prometheus_mac specifically for Macs or different
version.
```bash
make devenv sources=influxdb,prometheus,elastic5
make devenv sources=influxdb,prometheus2,elastic5
```
Some of the blocks support dynamic change of the image version used in the Docker file. The signature looks like this:
@@ -45,25 +46,17 @@ make devenv sources=postgres,openldap,grafana postgres_version=9.2 grafana_versi
The grafana block is pre-configured with the dev-datasources and dashboards.
#### Jaeger
Jaeger block runs both Jaeger and Loki container. Loki container sends traces to Jaeger and also logs its own logs into itself so it is possible to setup derived field for traceID from Loki to Jaeger. You need to install a docker plugin for the self logging to work, without it the container won't start. See https://grafana.com/docs/loki/latest/clients/docker-driver/#installing for installation instructions.
#### Graphite
| version | source name | graphite-web port | plaintext port | pickle port |
|---------|-------------|-------------------|----------------|-------------|
| 1.1 | graphite | 8180 | 2103 | 2103 |
| 1.0 | graphite1 | 8280 | 2203 | 2203 |
| 0.9 | graphite09 | 8380 | 2303 | 2303 |
## Debugging setup in VS Code
An example of launch.json is provided in `devenv/vscode/launch.json`. It basically does what Makefile and .bra.toml do. The 'program' field is set to the folder name so VS Code loads all *.go files in it instead of just main.go.
Jaeger block runs both Jaeger and Loki container. Loki container sends traces to Jaeger and also logs its own logs into itself so it is possible to setup derived field for traceID from Loki to Jaeger. You need to install a docker plugin for the self logging to work, without it the container won't start. See https://github.com/grafana/loki/tree/master/cmd/docker-driver#plugin-installation for installation instructions.
## Troubleshooting
### Containers that read from log files fail to start (Mac OS)
If you are running Mac OSX, containers that read from the log files (e.g. Telegraf, Fileabeat, Promtail) can fail to start. This is because the default Docker for Mac does not have permission to create `grafana` folder at the `/var/log` location, as it runs as the current user. To solve this issue, manually create the folder `/var/log/grafana`, then start the containers again.
### Containers fail to start (Mac OS)
```
sudo mkdir /var/log/grafana
ERROR: for <service_name> Cannot start service <service_name>: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting ... merged/var/log/grafana: operation not permitted\\\"\"": unknown
ERROR: Encountered errors while bringing up the project.
```
If running Mac OSX the above error might be encountered when starting certain Docker containers that mount `/var/log/`. When first run this causes Docker to try to create the folder `/var/log/grafana` however by default Docker for Mac does not have permission to create folders at this location as it runs as the current user.
To solve this issue manually create the folder `/var/log/grafana` and give your user write permissions then try starting the containers again.

View File

@@ -1,13 +1,5 @@
apiVersion: 1
deleteDatasources:
- name: gdev-influxdb
- name: gdev-influxdb-telegraf
- name: gdev-influxdb2
- name: gdev-influxdb2-influxql
- name: gdev-loki-0.3
- name: gdev-loki-0.4
datasources:
- name: gdev-graphite
type: graphite
@@ -16,20 +8,6 @@ datasources:
jsonData:
graphiteVersion: "1.1"
- name: gdev-graphite-1.0
type: graphite
access: proxy
url: http://localhost:8280
jsonData:
graphiteVersion: "1.0"
- name: gdev-graphite-0.9
type: graphite
access: proxy
url: http://localhost:8380
jsonData:
graphiteVersion: "0.9"
- name: gdev-prometheus
type: prometheus
access: proxy
@@ -44,37 +22,27 @@ datasources:
isDefault: true
type: testdata
- name: gdev-influxdb1-influxql
- name: gdev-influxdb
type: influxdb
access: proxy
database: site
user: grafana
url: http://localhost:8087
url: http://localhost:8086
jsonData:
timeInterval: "15s"
secureJsonData:
password: grafana
- name: gdev-influxdb-flux
- name: gdev-influxdb-telegraf
type: influxdb
access: proxy
url: http://localhost:8086
database: telegraf
user: grafana
secureJsonData:
token: mytoken
password: grafana12345
jsonData:
version: Flux
organization: myorg
defaultBucket: mybucket
- name: gdev-influxdb-influxql
type: influxdb
access: proxy
database: mybucket
url: http://localhost:8086
jsonData:
httpHeaderName1: "Authorization"
timeInterval: "10s"
secureJsonData:
httpHeaderValue1: "Token mytoken"
password: grafana
- name: gdev-opentsdb
type: opentsdb
@@ -84,14 +52,6 @@ datasources:
tsdbResolution: 1
tsdbVersion: 1
- name: gdev-opentsdb-v2.3
type: opentsdb
access: proxy
url: http://localhost:4242
jsonData:
tsdbResolution: 1
tsdbVersion: 3
- name: gdev-elasticsearch-v2-metrics
type: elasticsearch
access: proxy
@@ -132,26 +92,6 @@ datasources:
timeField: "@timestamp"
esVersion: 5
- name: gdev-elasticsearch-v56-metrics
type: elasticsearch
access: proxy
database: "[metrics-]YYYY.MM.DD"
url: http://localhost:13200
jsonData:
interval: Daily
timeField: "@timestamp"
esVersion: 56
- name: gdev-elasticsearch-v56-logs
type: elasticsearch
access: proxy
database: "[logs-]YYYY.MM.DD"
url: http://localhost:13200
jsonData:
interval: Daily
timeField: "@timestamp"
esVersion: 56
- name: gdev-elasticsearch-v6-metrics
type: elasticsearch
access: proxy
@@ -287,6 +227,20 @@ datasources:
defaultRegion: eu-west-2
customMetricsNamespaces: "CWAgent"
# Keep to test old /api/prom API
- name: gdev-loki-0.3
type: loki
access: proxy
url: http://localhost:3103
editable: false
# First version with new v1 API (remove once v1 is out)
- name: gdev-loki-0.4
type: loki
access: proxy
url: http://localhost:3104
editable: false
- name: gdev-loki
type: loki
access: proxy
@@ -316,10 +270,3 @@ datasources:
access: proxy
url: http://localhost:9411
editable: false
- name: gdev-tempo
type: tempo
uid: gdev-tempo
access: proxy
url: http://localhost:3101
editable: false

View File

@@ -23,35 +23,27 @@ datasources:
isDefault: true
type: testdata
- name: gdev-influxdb1-influxql
- name: gdev-influxdb
type: influxdb
access: proxy
database: site
user: grafana
url: http://influxdb1:8086
url: http://influxdb:8086
jsonData:
timeInterval: "15s"
secureJsonData:
password: grafana
- name: gdev-influxdb-flux
- name: gdev-influxdb-telegraf
type: influxdb
access: proxy
url: http://influxdb:8086
secureJsonData:
token: mytoken
database: telegraf
user: grafana
url: http://telegraf:8086
jsonData:
version: Flux
organization: myorg
defaultBucket: mybucket
- name: gdev-influxdb-influxql
type: influxdb
access: proxy
database: mybucket
url: http://influxdb:8086
jsonData:
httpHeaderName1: "Authorization"
timeInterval: "10s"
secureJsonData:
httpHeaderValue1: "Token mytoken"
password: grafana
- name: gdev-opentsdb
type: opentsdb
@@ -85,7 +77,7 @@ datasources:
type: elasticsearch
access: proxy
database: "[metrics-]YYYY.MM.DD"
url: http://elasticsearch5:9200
url: http://elasticsearch5:10200
jsonData:
interval: Daily
timeField: "@timestamp"
@@ -101,26 +93,6 @@ datasources:
timeField: "@timestamp"
esVersion: 5
- name: gdev-elasticsearch-v56-metrics
type: elasticsearch
access: proxy
database: "[metrics-]YYYY.MM.DD"
url: http://elasticsearch5:9200
jsonData:
interval: Daily
timeField: "@timestamp"
esVersion: 56
- name: gdev-elasticsearch-v56-logs
type: elasticsearch
access: proxy
database: "[logs-]YYYY.MM.DD"
url: http://elasticsearch5:9200
jsonData:
interval: Daily
timeField: "@timestamp"
esVersion: 56
- name: gdev-elasticsearch-v6-metrics
type: elasticsearch
access: proxy
@@ -255,6 +227,20 @@ datasources:
authType: credentials
defaultRegion: eu-west-2
# Keep to test old /api/prom API
- name: gdev-loki-0.3
type: loki
access: proxy
url: http://loki0.3:3100
editable: false
# First version with new v1 API (remove once v1 is out)
- name: gdev-loki-0.4
type: loki
access: proxy
url: http://loki0.4:3100
editable: false
- name: gdev-loki
type: loki
access: proxy

View File

@@ -685,10 +685,6 @@
"text": "meter (m)",
"value": "lengthm"
},
{
"text": "inch (in)",
"value": "lengthin"
},
{
"text": "feet (ft)",
"value": "lengthft"
@@ -731,10 +727,6 @@
"text": "gram (g)",
"value": "massg"
},
{
"text": "pound (lb)",
"value": "masslb"
},
{
"text": "kilogram (kg)",
"value": "masskg"
@@ -1796,10 +1788,6 @@
"text": "meter (m)",
"value": "lengthm"
},
{
"text": "inch (in)",
"value": "lengthin"
},
{
"text": "feet (ft)",
"value": "lengthft"
@@ -1842,10 +1830,6 @@
"text": "gram (g)",
"value": "massg"
},
{
"text": "pound (lb)",
"value": "masslb"
},
{
"text": "kilogram (kg)",
"value": "masskg"
@@ -2887,10 +2871,6 @@
"text": "meter (m)",
"value": "lengthm"
},
{
"text": "inch (in)",
"value": "lengthin"
},
{
"text": "feet (ft)",
"value": "lengthft"
@@ -2933,10 +2913,6 @@
"text": "gram (g)",
"value": "massg"
},
{
"text": "pound (lb)",
"value": "masslb"
},
{
"text": "kilogram (kg)",
"value": "masskg"

Some files were not shown because too many files have changed in this diff Show More