From 516b7ce8454c713f0161d195ff799824b2d393ca Mon Sep 17 00:00:00 2001 From: Andrej Ocenas Date: Mon, 25 Mar 2019 21:14:24 +0100 Subject: [PATCH] docs(dev): Update docs about devenv dir (#16208) * Update readmes * Fix devenv dasboard query * Update devenv readme * Add link to devenv from docs --- README.md | 7 ++++ devenv/README.md | 23 +++++++++-- .../datasource_tests_postgres_fakedata.json | 41 +++---------------- docs/sources/project/building_from_source.md | 6 +++ 4 files changed, 39 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 1d8a50ebc6c..84af184bda8 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,8 @@ The resulting image will be tagged as `grafana/grafana:dev` Notice: If you are using Docker for MacOS, be sure to set the memory limit to be larger than 2 GiB (at docker -> Preferences -> Advanced), otherwise `grunt build` may fail. +## Development + ### Dev config Create a custom.ini in the conf directory to override default configuration options. @@ -148,6 +150,11 @@ GRAFANA_TEST_DB=mysql go test ./pkg/... GRAFANA_TEST_DB=postgres go test ./pkg/... ``` +### Datasource and dashboard provisioning + +[Here](https://github.com/grafana/grafana/tree/master/devenv) you can find helpful scripts and docker-compose setup +that will populate your dev environment for quicker testing end experimenting. + ## Contribute If you have any ideas for improvement or have found a bug, do not hesitate to open an issue. diff --git a/devenv/README.md b/devenv/README.md index 9abf3596776..eecfb6b7710 100644 --- a/devenv/README.md +++ b/devenv/README.md @@ -2,15 +2,32 @@ This folder contains useful scripts and configuration for... * Configuring dev datasources in Grafana * Configuring dev & test scenarios dashboards. +* Creating docker-compose file with DBs and fake data. + + +# Dev dashboards and data sources ```bash ./setup.sh ``` -After restarting grafana server there should now be a number of datasources named `gdev-` provisioned as well as a dashboard folder named `gdev dashboards`. This folder contains dashboard & panel features tests dashboards. +After restarting grafana server there should now be a number of datasources named `gdev-` provisioned as well as +a dashboard folder named `gdev dashboards`. This folder contains dashboard & panel features tests dashboards. -# Dev dashboards +#### Dev dashboards -Please update these dashboards or make new ones as new panels & dashboards features are developed or new bugs are found. The dashboards are located in the `devenv/dev-dashboards` folder. +Please update these dashboards or make new ones as new panels & dashboards features are developed or new bugs are +found. The dashboards are located in the `devenv/dev-dashboards` folder. +# docker-compose with databases + +```bash +./create_docker_compose.sh influxdb prometheus2 elastic5 +docker-compose up +``` + +This command will create 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. Mind that +for some databases there are multiple images, for example there is prometheus_mac specifically for Macs or different +version. diff --git a/devenv/dev-dashboards/datasource_tests_postgres_fakedata.json b/devenv/dev-dashboards/datasource_tests_postgres_fakedata.json index 508cae86bc3..962e522c802 100644 --- a/devenv/dev-dashboards/datasource_tests_postgres_fakedata.json +++ b/devenv/dev-dashboards/datasource_tests_postgres_fakedata.json @@ -75,7 +75,7 @@ { "alias": "", "format": "time_series", - "rawSql": "SELECT\n $__timeGroup(\"createdAt\",'$summarize'),\n min(value) as \"value\",\n 'total avg' as \"metric\"\nFROM \n grafana_metric\nWHERE\n $__timeFilter(\"createdAt\") AND\n measurement = 'logins.count'\nGROUP BY time", + "rawSql": "SELECT\n $__timeGroup(\"createdAt\",'$summarize'),\n min(value) as \"value\",\n 'total avg' as \"metric\"\nFROM \n grafana_metric\nWHERE\n $__timeFilter(\"createdAt\") AND\n measurement = 'logins.count'\nGROUP BY time\nORDER BY time", "refId": "B" } ], @@ -323,11 +323,7 @@ { "alias": "", "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], + "colors": ["rgba(245, 54, 54, 0.9)", "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)"], "decimals": 2, "pattern": "/.*/", "thresholds": [], @@ -351,11 +347,7 @@ ], "schemaVersion": 16, "style": "dark", - "tags": [ - "gdev", - "fake-data-gen", - "postgres" - ], + "tags": ["gdev", "fake-data-gen", "postgres"], "templating": { "list": [ { @@ -501,32 +493,11 @@ "to": "now" }, "timepicker": { - "refresh_intervals": [ - "5s", - "10s", - "30s", - "1m", - "5m", - "15m", - "30m", - "1h", - "2h", - "1d" - ], - "time_options": [ - "5m", - "15m", - "1h", - "6h", - "12h", - "24h", - "2d", - "7d", - "30d" - ] + "refresh_intervals": ["5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d"], + "time_options": ["5m", "15m", "1h", "6h", "12h", "24h", "2d", "7d", "30d"] }, "timezone": "", "title": "Datasource tests - Postgres", "uid": "JYola5qzz", "version": 4 -} \ No newline at end of file +} diff --git a/docs/sources/project/building_from_source.md b/docs/sources/project/building_from_source.md index 35e840d6e88..0d29cbd371e 100644 --- a/docs/sources/project/building_from_source.md +++ b/docs/sources/project/building_from_source.md @@ -96,6 +96,12 @@ Writing & watching frontend tests - Jest will run all test files that end with the name ".test.ts" +### Datasource and dashboard provisioning + +[Here](https://github.com/grafana/grafana/tree/master/devenv) you can find helpful scripts and docker-compose setup +that will populate your dev environment for quicker testing end experimenting. + + ## Creating optimized release packages This step builds linux packages and requires that fpm is installed. Install fpm via `gem install fpm`.