{"id":20263613,"url":"https://github.com/springerpe/cf-grafana-buildpack","last_synced_at":"2025-04-11T02:08:58.774Z","repository":{"id":34862861,"uuid":"174517863","full_name":"SpringerPE/cf-grafana-buildpack","owner":"SpringerPE","description":"CF buildpack for Grafana","archived":false,"fork":false,"pushed_at":"2024-02-15T09:55:25.000Z","size":136,"stargazers_count":3,"open_issues_count":0,"forks_count":9,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-11T02:08:51.390Z","etag":null,"topics":["buildpack","cf","cloud","cloudfoundry","foundry","grafana"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SpringerPE.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-08T10:33:00.000Z","updated_at":"2023-03-22T03:03:53.000Z","dependencies_parsed_at":"2024-02-15T10:47:33.609Z","dependency_job_id":null,"html_url":"https://github.com/SpringerPE/cf-grafana-buildpack","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpringerPE%2Fcf-grafana-buildpack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpringerPE%2Fcf-grafana-buildpack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpringerPE%2Fcf-grafana-buildpack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpringerPE%2Fcf-grafana-buildpack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SpringerPE","download_url":"https://codeload.github.com/SpringerPE/cf-grafana-buildpack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248328160,"owners_count":21085261,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["buildpack","cf","cloud","cloudfoundry","foundry","grafana"],"created_at":"2024-11-14T11:35:42.345Z","updated_at":"2025-04-11T02:08:58.756Z","avatar_url":"https://github.com/SpringerPE.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cf-grafana-buildpack\n\nCloudfoundry buildpack to deploy Grafana 9 and get it automatically configured.\nThis buildpack is able to automatically setup a database from a service broker\ninstance (both mysql and postgres are supported) if no database connection is provided\nit will use a sqlite database.\n\nWhen you can skip having a proper DB (mysql or postgres):\n\n1. If a single grafana instance is enough for your use case.\n2. If you do not care about user management\n3. If all dashboards and datasources are defined in configuration files.\n\nWith points 2 and 3 potentially you would have skip 1'st point and have multiple instances,\nbut this setup is not tested.\n\nHaving mysql or postgres, this buildpack allows you to deploy multiple instances because\nsessions are stored there.\n\nThis buildpack is focused on CloudSQL offered by Google Service Broker. It \"should\" support\nother service broker instances, but we have not checked it (PR are welcome!)\n\n**In order to test new versions of the buildpack, please use `dev` branch** and\nmerge with master only when you are sure it works, otherwise it would cause\na lot of pain to other users of this buildpack.\n\n## Using it\n\nFirst of all, this buildpack has no requirements at all, in order to get Grafana working,\nyou can create app folder, put a `manifest.yml` like this in your root folder: \n\n```manifest.yml\n---\napplications:\n- name: grafana\n  memory: 512M\n  instances: 1\n  stack: cflinuxfs4\n  random-route: true\n  buildpacks:\n  - https://github.com/SpringerPE/cf-grafana-buildpack.git\n  env:\n    ADMIN_USER: admin\n    ADMIN_PASS: admin\n    SECRET_KEY: yUeEBtX7eTmh2ixzz0oHsNyyxYmebSat\n```\n\nand run from the root folder `cf push`\n\nAditionally by binding the app to a SQL instance (mysql or postgres), \neverything will be saved in a persistent DB, but this is not really \nrecommented unless you are testing or you want to become a good \ndeveloper/devops (you know replicable builds, traceable changes, etc)\n\n\n# Documentation\n\nTo use this buildpack, specify the URI of this repository when push to Cloud Foundry.\n```\n$ cf push \u003cAPP-NAME\u003e -b https://github.com/SpringerPE/cf-grafana-buildpack.git\n```\n\nIf you want to deploy a specific version, have a look at the git tags available\nand put a `#` removing the `.git` extension like this:\n```\n$ cf push \u003cAPP-NAME\u003e -b https://github.com/SpringerPE/cf-grafana-buildpack#\u003cTAG\u003e\n```\n\nFor example:\n```\n$ cf push \u003cAPP-NAME\u003e -b https://github.com/SpringerPE/cf-grafana-buildpack#v1\n```\n\nor define it in the `manifest.yml`:\n\n```\n---\napplications:\n- name: grafana\n  buildpack: https://github.com/SpringerPE/cf-grafana-buildpack#v1\n```\n\n### Configuration\n\nFirst have a look at the official documentation of Grafana: http://docs.grafana.org/installation/configuration/\n\nThis buildpack is highly flexible, these are some keypoints to match the official documentation with this buildpack implementation.\n\n* The app folder is the `provisioning` folder [specified in the documentation](https://grafana.com/docs/grafana/latest/administration/provisioning/), so you can create these directories: `datasources`, `dashboards`, `notifiers` there as the official documenation says.\n* The default configuration refereed as `defaults.ini` is provided and customized for the buildpack: https://github.com/SpringerPE/cf-grafana-buildpack/blob/master/defaults.ini\n* The custom configuration file referred as `custom.ini` will be applied automatically by placing a file named `grafana.ini` in the root folder of the app, so `custom.ini` is called `grafana.ini`.\n* You can use all environment variables to setup Grafana (`GF_*`), except the ones in the `[paths]` section of the configuration file.\n* Plugins folder points to `plugins` in the root app, so all plugins will be installed there automatically.\n\n#### Important environment variables\n\nApart of the Grafana environment variables, you can define these ones:\n\n* **DEFAULT_DATASOURCE_EDITABLE** (default `false`). By default the auto-generated datasources for Prometheus and Alertmanager are not editable. Changing this value makes then editable, but if you do not use a DB be aware that changes on their properties will be lost after redeploy grafana.\n* **DEFAULT_DATASOURCE_TIMEINTERVAL** (default `60s`). Lowest interval/step value that should be used for default generated data source.\n* **HOME_DASHBOARD_UID** (default `home`). Used to setup automatically the Grafana home dashboard (the one users see automatically when they log in). If you provision a dashboard with `uid`  equal to `HOME_DASHBOARD_UID`, the buildpack will setup such dashboard as home. The `uid` is part of the url of each dashboard, and it can be defined to a string like `home` (by default is a random generated string) to give some meaning to the dashboard urls. More info: https://grafana.com/docs/http_api/dashboard/#identifier-id-vs-unique-identifier-uid.\n* **ADMIN_USER**: main admin user (default is `admin`)\n* **ADMIN_PASS**: admin password (defautl is `admin`)\n* **SECRET_KEY**: Used for signing some datasource settings like secrets and passwords. Cannot be changed without requiring an update to datasource settings to re-encode them. Because this variable is so important, if it is not defined, **it defaults to the space uuid** where the app is running.\n* **DOMAIN**: uri of the application, defauls to the first route in CF.\n* **EMAIL**: when a smtp is configured this is the `from` field, defaults to `grafana@$DOMAIN`.\n* **DB_BINDING_NAME**: name of the binding with a service instance to use as SQL database. By default is empty, so the builpack will search for bindings providing a DB connection string in their `credentials.uri` field. If it is defined it will skip automatic search and focus only on the provided one.\n* **URL**: URL of the app, defaults to `http://$DOMAIN`. If using https you will need to redefine this variable (specially for Oauth integrations!).\n\nFor production use, define a proper `ADMIN_PASS` and `SECRET_KEY`. The rest of variables should\nbe good with their defautls.\n\nWhen using a named service broker instance, you can define `MAIN_DB_BINDING_NAME`, otherwise is not needed if the app is bound to only a SQL instance used for everything (sessions, resources, cache)\n\n### Complex configuration\n\nIf you want to use your own Grafana settings, just place a `grafana.ini` file in the\napp folder with your settings. This is useful to define `oauth` settings and get users\nautomatically defined in Grafana. Have a look to the official documentation.\n \n\n### Grafana versions and plugins\n\nGrafana version can be specified in a file `runtime.txt`. Lines starting\nwith `#` are ignored, otherwise it will install the version defined in the buildpack\n(check `parameters.sh`), example:\n\n```runtime.txt\n# Define your grafana version here\n9.3.1\n```\n\nThis buildpack only supports Grafana 7.x or greater!\n\nYou can also define which plugins will be automatically installed in a file `plugins.txt`:\n\n```plugins.txt\n# Define your plugins here. Format is 2 columns: pluginid version\n# https://grafana.com/plugins\nsatellogic-3d-globe-panel 0.1.0\n```\n\nAs an alternative you can uncompress a plugin in a `plugins` folder or use locally `grafana-cli`\nspecifiying `pluginsDir` to `plugins`: `grafana-cli --pluginsDir plugins plugins install \u003cid\u003e \u003cversion\u003e`\n\n\n### Service brokers\n\nAs said, you can use a service broker instance which exposes a SQL connection string\nin `.credentials.uri`, the DB connection string has to be properly formed and only\nusing `mysql` or `postgres`.\n\nIf you do not have a service broker implementation, you can still use it via user provided\nservices:\n\n```\n$ cf create-user-provided-service mysql-db -p '{\"uri\":\"mysql://root:secret@dbserver.example.com:3306/mydatabase\"}'\n# bind a service instance to the application\n$ cf bind-service \u003capp name\u003e \u003cservice name\u003e\n# restart the application so the new service is detected\n$ cf restart\n```\n\n# TLS with GCP Service Broker and Cloud SQL Proxy\n\nThis buildpack is primary made to work with GCP Service Broker. Grafana does not support\nTLS connection strings for all DBs (e.g. session SQL DB), the way to overcome to this situation\nwas using a Cloud SQL Proxy: https://github.com/GoogleCloudPlatform/cloudsql-proxy\n\nWhen the builpack detects a GCP Service broker, it automatically runs the cloud-sql proxy\nand change all Grafana connection settings to point to localhost. The SQL proxy connects\nto the DB server using the TLS settings and `PrivateData` auth.\n\n\n# Using Oauth\n\nFor example, to define Oauth auth with Google, just create a file `grafana.ini` like this:\n```\n[auth.google]\nenabled = true\nclient_id = \"${CLIENT_ID}\"\nclient_secret = \"${CLIENT_SECRET}\"\nscopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email\nauth_url = https://accounts.google.com/o/oauth2/auth\ntoken_url = https://accounts.google.com/o/oauth2/token\nallowed_domains = companydomain1.com companydomain2.com\nallow_sign_up = true\n```\n\nIn the CF manifest, you can define the variables needed:\n```\n---\napplications:\n- name: mission-control\n  memory: 512M\n  instances: 1\n  stack: cflinuxfs4\n  buildpack: https://github.com/SpringerPE/cf-grafana-buildpack.git\n  env:\n    CLIENT_ID:  'blabla'\n    CLIENT_SECRET: 'blabla'\n    URL: https://mygrafana.companydomain.com\n```\n\nDo not forget to define `$URL` with the https protocol!.\n\n\n# Development\n\nIn order to test new versions of the buildpack, use `docker-compose build \u0026\u0026 docker-compose up`\nPlease use  a different  branch and merge with master only when you are sure it works, otherwise it would cause\na lot of pain to other users of this buildpack.\n\nImplemented using bash scripts to make it easy to understand and change.\n\nhttps://docs.cloudfoundry.org/buildpacks/understand-buildpacks.html\n\nThe builpack uses the `deps` and `cache` folders according the implementation purposes,\nso, the first time the buildpack is used it will download all resources, next times \nit will use the cached resources.\n\n# Author\n\nCopyright © Springer Nature\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspringerpe%2Fcf-grafana-buildpack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspringerpe%2Fcf-grafana-buildpack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspringerpe%2Fcf-grafana-buildpack/lists"}