Grafana Dashboard Manager

Overview

Grafana dash-n-grab

Grafana Dash-n-Grab (GDG) -- Dashboard/DataSource Manager. The purpose of this project is to provide an easy to use CLI to interact with the grafana API allowing you to backup and restore dashboard and datasources.

Getting started

This project requires Go to be installed. On OS X with Homebrew you can just run brew install go.

Configuring Auth

make a copy of conf/importer-example.yml and name it conf/importer.yml You'll need administrative privileges to proceed.

You can use either an Auth Token or username/password credentials. If you configure both then the Token is given priority.

Watched folders under grafana is a white list of folders that are being managed by the tool. By default only "General" is managed.

env.output defines where the files will be saved and imported from.

Contexts

Starting with version 0.1.4 contexts are now supported. Your config can contain one or multiple contexts which are essentially a grafana server configuration.

ctx is shorthand for context

./bin/grafana-dashboard-manager ctx list -- Lists all known contexts
./bin/grafana-dashboard-manager ctx show -c qa -- shows the configuration for the selected context
./bin/grafana-dashboard-manager ctx set -c production -- updates the active config and sets it to the request value.

Users

Only supported with basic auth. Users is the only one where basic auth is given priority. API Auth is not supported, so will try to use basic auth if configured otherwise will warn the user and exit.

./bin/grafana-dashboard-manager users list -- Lists all known users
./bin/grafana-dashboard-manager users promote -u [email protected] -- promotes the user to a grafana admin

Running the app

Running it then should be as simple as:

$ make build
$ ./bin/grafana-dashboard-manager

Every namespace has three functions: list, import, export, clear operating on only the monitored folders.

Dashboards

All commands can use dashboards or dash to manage dashboards

./bin/grafana-dashboard-manager dash list -- Lists all current dashboards
./bin/grafana-dashboard-manager dash import -- Import all dashboards from grafana to local file system
./bin/grafana-dashboard-manager dash export -- Exports all dashboard from local filesystem (matching folder filter) to Grafana
./bin/grafana-dashboard-manager dash clear -- Deletes all dashboards

DataSources

DataSources credentials are keyed by the name of the DataSource. See see config example. If the datasource JSON doesn't have auth enabled, the credentials are igored. If Credentials are missing, we'll fall back on default credentials if any exist. The password is set as a value for basicAuthPassword in the API payload.

All commands can use datasources or ds to manage datasources

./bin/grafana-dashboard-manager ds list -- Lists all current datasources
./bin/grafana-dashboard-manager ds import -- Import all datasources from grafana to local file system
./bin/grafana-dashboard-manager ds export -- Exports all dashboard from local filesystem (matching folder filter) to Grafana
./bin/grafana-dashboard-manager ds clear -- Deletes all datasources

Making a release

Install goreleaser.

brew install goreleaser/tap/goreleaser
brew reinstall goreleaser`

export your GITHUB_TOKEN.

export GITHUB_TOKEN="secret"

git tag v0.1.0 goreleaser release

Issues
  • Support importing Grafana panels

    Support importing Grafana panels

    Apparently, Grafana does not plan to support importing library panels through POST API and they want people to use import dashboard API that is not documented.

    https://github.com/grafana/grafana/issues/44003 https://github.com/grafana/grafana/pull/43525

    It would be great if you could use that import API to support that feature.

    I was planning on writing PR, but currently have busy schedule.

    documentation Stale 
    opened by efekete 11
  • Configuration with environment variables

    Configuration with environment variables

    It would be nice if we could specify environment variables in the configuration file importer.yml

    This will enable us to isolate secrets (tokens and passwords), and safely commit the configuration file to version control.

    opened by forzagreen 11
  • Auth Token or API key?

    Auth Token or API key?

    hi The authentication with Auth Token doesn't seem to work, even when created with Admin permission. Is it the API key I need to create or am I missing something here? Thanks a lot!

    bug 
    opened by jotka 11
  • Authentication behind a https client certificate

    Authentication behind a https client certificate

    Our Grafana is running behind a self signed certificat.

    I get this error while executing dash list

    time="2021-11-29T13:39:10+01:00" level=warning msg="Error getting organizations: Get \"https://xxx.xxx/api/orgs\": local error: tls: no renegotiation"
    time="2021-11-29T13:39:10+01:00" level=fatal msg="Failed to retrieve dashboardsGet \"https://xxx.xxx/api/search?type=dash-db\": local error: tls: no renegotiation"
    
    Stale 
    opened by Syndlex 8
  • import export of a single dashboard

    import export of a single dashboard

    Hi @safaci2000 I think it would be useful to import and export a single dashboard. A use case can be to copy a single dashboard for one organization to another when you have a lot organization and don't want, or can't, copy all dashboards every time.

    gdg ctx set -c context_a
    gdg dashboard import my-dash
    gdg ctx set -c context_b
    gdg dashboard export my-dash
    

    Any idea is appreciated, I'm waiting of your feedback to start coding.

    opened by mvalletta 7
  • Use grafana sdk instead of a forked repo

    Use grafana sdk instead of a forked repo

    Hi @safaci2000 can you use https://github.com/grafana-tools/sdk instead of your forked repo https://github.com/netsage-project/sdk ? I think it's better for security reasons

    opened by mvalletta 6
  • Allow list / export / import / delete of Grafana alarms

    Allow list / export / import / delete of Grafana alarms

    Summary

    AFAIK currently there is no way to list / export / import / delete alerts set in Grafana. We would like to start exporting them so that we can have a back up in git.

    Features

    I would like to implement the following commands:

    ./gdg alerts list
    ./gdg alerts import
    ,/gdg alerts export
    ./gdg alerts clear
    

    Also, add a new block into the configuration file / parser. Something like:

    contexts:
      all:
        dashboards_output: "dashboards"
        alerts_output: "alerts"
    

    When exporting / importing, we would consider all of the alerts, just like with datasources. Meaning it would not be possible to export / import specific alerts.

    Notes

    • API documentation https://grafana.com/docs/grafana/latest/http_api/alerting/
    • I very much won't mind implementing this, but I will have time for this at best at the start of November. So I am creating an issue to first ask whether there are any plans for this, or whether by any chance you dont have a partial code for it already. :shrug:
    enhancement 
    opened by VladMasarik 5
  • Support instances with more than 1000 dashboards

    Support instances with more than 1000 dashboards

    Thank you for this project!

    When listing/importing dashboards from a Grafana instance with more than 1000 dashboards, you only get the dashboards within the watched folder that were returned in the first 1000 results. As result, in my case I only imported 37 dashboards instead of all 225.

    I have no immediate need for this feature, but hopefully it could safe others some time or trouble in the short term.

    opened by cr1xu5 4
  • [Docs] Added import / export examples

    [Docs] Added import / export examples

    Hi, you have a wonderful project!

    As I was using it, I found a few things that were not mentioned in the documentation, and which I thought would help me get to use your project much faster. So, I created this PR.

    Things I am trying to achieve:

    • Provide minimal configuration needed to import/export the dashboards; The importer-example.yml is great, but I wasn't sure what is needed, and which parts should be adjusted.
    • Mention of how the user will know if the things are working; Before, I wasn't 100% sure whether I need to also specify organization etc., and when I successfully printed the dashboards, I also got a log complaining about permissions, although that was just fine.
    • Showcase of the folder structure in case you are uploading; Before, I wasn't sure about the structure, and if there are some "prefix" folders in Grafana, so I hope this will make it explicit.

    I am very much open to any adjustments, this was more something I quickly wrote / copy pasted from my own documentation.

    opened by VladMasarik 4
  • Difference Report

    Difference Report

    It would be interesting to explore the ability to generate a report between:

    • Server A and Server B
    • backup folder and Server
    • two backup locations to generate a diff.

    This is a bit of a more advanced feature, and initially looking at focusing it on Dashboards/DataSources.

    enhancement Stale 
    opened by safaci2000 3
  • Cloud backup

    Cloud backup

    Explore Uploading/Pulling data from GS/S3.

    Potential useful implementation/ abstraction to support multiple cloud providers: https://github.com/graymeta/stow

    enhancement Stale 
    opened by safaci2000 3
  • Support Sync contexts

    Support Sync contexts

    Is your feature request related to a problem? Please describe.

    Given two valid contexts, it would be nice to have the ability to synchronize a particular entity ie. dashboards between two contexts.

    Source context could use grafana instance or the storage system as an input while the destination should always be a grafana insurance.

    Describe the solution you'd like A clear and concise description of what you want to happen.

    Example : gdg sync dashboards staging production gdg sync datasources --backup staging production

    enhancement 
    opened by safaci2000 0
  • export from specific local folder to grafana

    export from specific local folder to grafana

    Hi all,

    I have multiple grafana instances with many folders and wanna sync my folders from one dc to another. Can we have an option to import a folder from grafana at DC1 to my local folder dashboards/DC1 and then switch context to DC2 and export dashboards/DC1 to grafana at DC2? let me also say that I don't want to change output_path of dc2 to dashboards/DC1. I need it for example as an command line argument.

    Thanks in advance.

    opened by pahla1 1
  • [Spike] Migrate to go-client

    [Spike] Migrate to go-client

    Current work for grafana is looking at generating go-client from swagger models. https://github.com/grafana/grafana/issues/47827

    It may be worth to look at switching to utilizing the go-client over other SDKs we've been using of late.

    This ticket is to capture the work to investigate if the intent of that project is an SDK replacement.

    opened by safaci2000 1
Releases(v0.2.1)
Owner
NetSage
NetSage
Grafana Dashboard Manager

Grafana dash-n-grab Grafana Dash-n-Grab (GDG) -- Dashboard/DataSource Manager. The purpose of this project is to provide an easy to use CLI to interac

NetSage 119 Jul 26, 2022
grafana-sync Keep your grafana dashboards in sync.

grafana-sync Keep your grafana dashboards in sync. Table of Contents grafana-sync Table of Contents Installing Getting Started Pull Save all dashboard

Maksym Postument 157 Jul 26, 2022
Snowflake grafana datasource plugin allows Snowflake data to be visually represented in Grafana dashboards.

Snowflake Grafana Data Source With the Snowflake plugin, you can visualize your Snowflake data in Grafana and build awesome chart. Get started with th

Michelin 29 Jun 24, 2022
Grafana-threema-forwarder - Alert forwarder from Grafana webhooks to Threema wire messages

Grafana to Threema alert forwarder Although Grafana has built in support for pus

Péter Szilágyi 2 Feb 13, 2022
Multi cluster kubernetes dashboard with batteries included. Build by developers, for developers.

kubetower Multi cluster kubernetes dashboard with batteries included. Built by developers, for developers. Features Restart deployments with one click

Emre Savcı 33 Jun 19, 2022
:bento: Highly Configurable Terminal Dashboard for Developers and Creators

DevDash is a highly configurable terminal dashboard for developers and creators who want to choose and display the most up-to-date metrics they need,

Matthieu Cneude 1.2k Aug 4, 2022
Simple Kubernetes real-time dashboard and management.

Skooner - Kubernetes Dashboard We are changing our name from k8dash to Skooner! Please bear with us as we update our documentation and codebase to ref

null 958 Jul 30, 2022
Kubernetes-native automatic dashboard for Ingress

ingress-dashboard Automatic dashboard generation for Ingress objects. Features: No JS Supports OIDC (Keycloak, Google, Okta, ...) and Basic authorizat

Aleksandr Baryshnikov 55 Jun 24, 2022
Exporter your cypress.io dashboard into prometheus Metrics

Cypress.io dashboard Prometheus exporter Prometheus exporter for a project from Cypress.io dashboards, giving the ability to alert, make special opera

Romain Guilmont 4 Feb 8, 2022
A beautiful CLI dashboard for GitHub 🚀

gh-dash ✨ A GitHub (gh) CLI extension to display a dashboard with pull requests and issues by filters you care about. Installation Install the gh CLI

Dolev Hadar 2.5k Aug 1, 2022
Terraform Provider for Azure (Resource Manager)Terraform Provider for Azure (Resource Manager)

Terraform Provider for Azure (Resource Manager) Version 2.x of the AzureRM Provider requires Terraform 0.12.x and later, but 1.0 is recommended. Terra

null 0 Oct 16, 2021
Grafana Tempo is a high volume, minimal dependency distributed tracing backend.

Grafana Tempo is an open source, easy-to-use and high-scale distributed tracing backend. Tempo is cost-efficient, requiring only object storage to ope

Grafana Labs 2.2k Aug 4, 2022
Graph and alert on '.rrd' data using grafana, RRDTool and RRDSrv.

Grafana RRD Datasource A grafana datasource for reading '.rrd' files via RRDTool and RRDsrv. With this datasource you will be able to create grafana d

null 9 Jun 7, 2022
Download your Fitbit weight history and connect to InfluxDB and Grafana

WemonFit Weight monitoring for Fitbit, using InfluxDB and Grafana Generating a new certificate openssl req -new -newkey rsa:2048 -nodes -keyout lo

Eduardo Argollo 0 Dec 5, 2021
PoC for Grafana 8.x Local File Inclusion (Pre-Auth)

Grafana 8.x Local File Inclusion (Pre-Auth) CVE: Pending All credits go to j0v and his tweet https://twitter.com/j0v0x0/status/1466845212626542607 Dis

Tay 9 Apr 13, 2022
Grafana Unauthorized arbitrary file reading vulnerability

CVE-2021-43798 Grafana Unauthorized arbitrary file reading vulnerability 8.3.1 (2021-12-07) Security: Fixes CVE-2021-43798 . For more information, see

Jas502n 275 Jul 25, 2022
Grafana DB2 Data Source Backend Plugin

Grafana DB2 Data Source Backend Plugin This template is a starting point for building Grafana Data Source Backend Plugins What is Grafana Data Source

null 2 Dec 13, 2021
Otus prometheus grafana for golang

HW Prometheus. Grafana Clone the repo: git clone https://github.com/alikhanmurzayev/otus_kuber_part_3.git && cd otus_kuber_part_3 Prepare workspace: m

null 0 Dec 17, 2021
Cole - Cole can use his sixth sense to give you metrics about your Grafana dashboards

Cole Cole can use his sixth sense to give you metrics about your Grafana dashboa

Nicolas Takashi 40 Jul 21, 2022