Table of Contents
I created this project to get into Go development and as such, it is probably far from being perfect. Keep an open mind to that and feel free to contribute if you want to optimize or extend its functionality.
The idea is to use grafana-oss-team-sync as an FOSS tool to create teams, users and even folders in Grafana and keep them (and their permissions) in sync with a configured source.
This functionality does exist in Grafana itself ("Team Sync"), but is a is an enterprise feature and as such only usable with an appropriate license key.
Sources are internally set-up as plug-ins, which can be easily extended to others in the future.
Currently the following sources are supported:
- Entra ID (formerly "Azure Active Directory")
The list of features include:
- search your
sourcefor specificgroupsand create them asteamsin your Grafana instance - (optional) create
usersfrom each configured source group - (optional) create
foldersfrom config input and add groups to thepermissionlist as either aviewer,editororadminrole
Things which potentially will be added in the future:
- allow to reference
userson folder permissions - allow to reference
roleson folder permissions - allow to assign
adminpermissions to team members - delete users and groups when removed from the source / sync list
( Back to top )
In it's current state, only Microsoft Entra ID is available as a source for groups and users.
The idea is to add new sources in the future as a "plug-in" feature.
Feel free to contribute your desired source.
This tool works with Grafana versions >=11.1.0.
We are running tests against versions v11.1.0, v12.0.0, v13.0.0 and latest
( Back to top )
There are multiple ways of using this tool. The easiest option would be to use the ready-to-go container image which is automatically uploaded as a package to this repository on GitHub. It is currently available for architectures linux/amd64 as well as linux/arm64.
You can start evaluating by using the latest tag and then switch to a release version. Just have a look at available tags in the package linked above.
Example:
podman pull ghcr.io/skuethe/grafana-oss-team-sync:latest
As an alternative, you can download your favourite (linux) binary which is attached to each release. Have a look at the latest release to find your preferred one (currently building apk, deb and rpm for both linux/amd64 as well as linux/arm64).
If you are still missing your installation method or OS architecture of choice, you can either Build It Yourself, or open a PR with an enhancement to the build-process (goreleaser).
( Back to top )
The following tool-specific configuration is available.
Details on Grafana and source specific requirements can be found below.
You can configure these either in the config.yaml, via environment variables (starting with GOTS_) or via command arguments.
The following hierarchy is used when merging different config sources, overriding already existing data (with the exception of the authfile in step 4):
- The
config.yamlyou specify - Environment variables set (also respecting an
.envfile) - Command arguments passed
- (Optional) content from an
authfile1
| Configuration | Configuration via | Description |
|---|---|---|
| Configuration file | argument: --config or -cenv var: GOTS_CONFIG |
Define the path to your config file (required) |
| Log level | config.yaml: loglevelargument: --loglevel or -lenv var: GOTS_LOGLEVEL |
Define the log level Type: intAllowed: 0 (INFO), 1 (WARN), 2 (ERROR), 99 (DEBUG)Default: 0 (INFO) |
| Source plug-in | config.yaml: sourceargument: --source or -senv var: GOTS_SOURCE |
Define the source plug-in you want to use Type: stringAllowed: entraid |
| Authentication file | config.yaml: authfileargument: --authfileenv var: GOTS_AUTHFILE |
Define an optional file to load authentication data from. File content needs to be in .env syntax (so key=value per line)Type: string |
| Feature: disable folder sync | config.yaml: features.disableFoldersargument: --disablefoldersenv var: GOTS_DISABLEFOLDERS |
Control the folder sync feature Type: boolDefault: false |
| Feature: disable user sync | config.yaml: features.disableUserSyncargument: --disableusersyncenv var: GOTS_DISABLEUSERSYNC |
Control the user sync feature Type: boolDefault: false |
| Feature: add local admin to teams | config.yaml: features.addLocalAdminToTeamsargument: --addlocaladmintoteamsenv var: GOTS_ADDLOCALADMINTOTEAMS |
Control adding Grafana local admin to each team Type: boolDefault: true |
| Team sync | config.yaml: teamsargument: --teams or -tenv var: GOTS_TEAMS |
Define the list of teams to sync Type: []string |
| Folder sync | config.yaml: folders |
Define the list of folders to sync Type: []interface |
Ideally you have set-up SSO authentication with the same source as your group and user sync
| Requirements | |
|---|---|
| Version | >= 11.1.0 2 |
| Authentication | Using either one of the available authentication options basic auth or service account token 3 |
| Configuration | Configuration via | Description |
|---|---|---|
| Authentication Type | config.yaml: grafana.authtypeargument: --authtypeenv var: GOTS_AUTHTYPE |
Define the authentication type to use Type: stringAllowed: basicauth, tokenDefault: basicauth |
| Authentication: Basic Auth | argument: --username and --password or -u and -penv var: GOTS_USERNAME and GOTS_PASSWORD |
Define user name and password for basic authentication to Grafana Type: string |
| Authentication: Service Account Token | argument: --token or -tenv var: GOTS_TOKEN |
Define token for service account token auth to Grafana Type: string |
| Connection: Scheme | config.yaml: grafana.connection.schemeargument: --schemeenv var: GOTS_SCHEME |
Define the scheme to use Type: stringAllowed: http, httpsDefault: http |
| Connection: Host | config.yaml: grafana.connection.hostargument: --host or -henv var: GOTS_HOST |
Define the host to use Type: stringDefault: localhost:3000 |
| Connection: Base Path | config.yaml: grafana.connection.basepathargument: --basepathenv var: GOTS_BASEPATH |
Define the base path to use Type: stringDefault: /api |
| Connection: Retry | config.yaml: grafana.connection.retryargument: --retry or -renv var: GOTS_RETRY |
Define the connection retry, waiting 2 seconds in between each. Only used when the return status code equals 429 or 5xxType: intDefault: 0 |
If you have enabled EntraID OAuth for SSO authentication in Grafana with the same EntraID tenant, it is possible to set allow_sign_up = false in your EntraID OAuth configuration options, so that only users which are synced by Grafana OSS Team Sync are able to log into your Grafana instance.
| Requirements | |
|---|---|
| Authentication | Using Azure app via environment variables: CLIENT_ID, TENANT_ID, CLIENT_SECRET |
| Application permissions | Minimum: User.ReadBasic.All, GroupMember.Read.AllTo list the members of a hidden membership group, the Member.Read.Hidden permission is required |
( Back to top )
Please note the following opinionated behaviour of this tool.
- this tool should be the single point of truth for creating groups in Grafana. For that matter, we are enforcing the following:
Teams: all members of each configured team are completely overridden with matching users from the source. If you added additional users or changed their permission (to "admin" e.g.), these changes will be lost during the next sync operation. This also helps with keeping the groups up to date with your configured source (when removing users for example)Folders: the permissions of each folder are completely overridden with the input from your config. If you don't want this to happen, you can always disable the folder sync feature via config / env variable or command argument
- if the user sync feature is enabled, all newly created users will get a randomly generated password assigned. This password is not available afterwards, as it should not be used in the first place. Ideally you have set-up SSO authentication with the same source as your group and user sync
( Back to top )
If you want to build the project yourself, do the following
- Clone this repository
git clone https://github.com/skuethe/grafana-oss-team-sync.git
cd grafana-oss-team-sync- Build the binary
CGO_ENABLED=0 go build .- Create the container image (adapt to your preferred tool for creating images)
podman build -t localhost/grafana-oss-team-sync:dev -f build/package/Dockerfile .( Back to top )
Contributions are what makes the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repository and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
See CONTRIBUTING for more information.
( Back to top )
This projects uses Semantic Versioning ("SemVer") for releases.
All available versions can be found on the releases page.
( Back to top )
Distributed under the GNU General Public License v3.0 or later ("GPL-3.0-or-later").
This project adheres to the SPDX® open standard. It is also REUSE-compliant
See LICENSE for more information.
( Back to top )
Footnotes
-
We are using godotenv, which will NOT override existing environment variables. ↩
-
Please note that
service account tokenauth only works if you disable theUserSyncfeature, as creating new users in Grafana uses the Admin API, which requires the usage of basicauth. ↩