Skip to content

Commit

Permalink
changes v 0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
peekjef72 committed Feb 2, 2022
1 parent 95fef17 commit 1994ef4
Show file tree
Hide file tree
Showing 8 changed files with 529 additions and 204 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
rebuild.sh
*/__pycache__/*
.eggs/*
*.egg-info/*
.vscode/*
build/*
INFO.txt
dist/*
*.egg-*/
10 changes: 10 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

# History

## 0.1.0 (2022-02-01)
* fixe behavior for dashboard moved from one folder to another

## 0.0.3 (2022-02-31)
* add remove dashboard feature

## 0.0.2 (2022-01-07)
* change config file format from json to yml
* add labels in config to define multi grafana servers.

## 0.0.1 (2021-03-15)

* First release on github.
Expand Down
17 changes: 16 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,24 @@
History
=======

# 0.1.0 (2022-02-01)
====================

* fixe behavior for dashboard moved from one folder to another

# 0.0.3 (2022-02-31)
====================

* add remove dashboard feature

# 0.0.2 (2022-01-07)
====================

* change config file format from json to yml
* add labels in config to define multi grafana servers.

# 0.0.1 (2021-03-15)
====================

* First release on github.


41 changes: 28 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Grafana import Tool

A python3 bases application to play with grafana dashboards using [Grafana API](https://grafana.com/docs/grafana/latest/http_api/) and a python interface [grafana_api](https://github.com/m0nhawk/grafana_api)
A python3 based application to play with grafana dashboards using [Grafana API](https://grafana.com/docs/grafana/latest/http_api/) and a python interface [grafana_api](https://github.com/m0nhawk/grafana_api)

The aim of this tool is to:
1. Export easilly an existing Grafana dashboard.
3. Import a dashboard in JSON format into a Grafana.
1. Export easilly an existing Grafana dashboard from a folder.
2. Import a dashboard in JSON format into a Grafana.
3. Remove a dashboard

## Install using this repo

Expand Down Expand Up @@ -87,29 +88,38 @@ then enter into your directory and type in you commands.

**usage**:
```shell
usage: grafana-import [-h] [-b BASE_PATH] [-c CONFIG_FILE] [-d DASHBOARD_NAME]
[-g GRAFANA_LABEL] [-f GRAFANA_FOLDER]
[-i DASHBOARD_FILE] [-o] [-p] [-v] [-V]
usage: grafana-import [-h] [-a] [-b BASE_PATH] [-c CONFIG_FILE]
[-d DASHBOARD_NAME] [-g GRAFANA_LABEL]
[-f GRAFANA_FOLDER] [-i DASHBOARD_FILE] [-o] [-p] [-v]
[-V]
[ACTION]

play with grafana dashboards json files.

positional arguments:
ACTION action to perform. Is one of 'export' or 'import'
(default). export: lookup for dashboard name in
Grafana and dump it to local file. import: import a
local dashboard file (previously exported) to Grafana.
ACTION action to perform. Is one of 'export', 'import'
(default), or 'remove'.
export: lookup for dashboard name in Grafana and dump
it to local file.
import: import a local dashboard file (previously
exported) to Grafana.
remove: lookup for dashboard name in Grafana and remove
it from Grafana server.


optional arguments:
-h, --help show this help message and exit
-a, --allow_new if a dashboard with same name exists in an another
folder, allow to create a new dashboard with same name
it that folder.
-b BASE_PATH, --base_path BASE_PATH
set base directory to find default files.
-c CONFIG_FILE, --config_file CONFIG_FILE
path to config files.
-d DASHBOARD_NAME, --dashboard_name DASHBOARD_NAME
name of dashboard to export.
-g GRAFANA_LABEL, --grafana_label GRAFANA_LABEL
label in the config file that represent the grafana to
label in the config file that represents the grafana to
connect to.
-f GRAFANA_FOLDER, --grafana_folder GRAFANA_FOLDER
the folder name where to import into Grafana.
Expand All @@ -125,9 +135,8 @@ optional arguments:
```
import action preserves the version history.
***Example:***
* **import** the dashboard located in default directory imports to grafana folder "Application"
* **import** the dashboard located in default directory imports to grafana folder "Applications"
```bash
$ grafana-import -i my-first-dashboard_202104011548.json -f Applications -o
Expand All @@ -141,6 +150,12 @@ then you can go into Grafana Gui and find the folder Applications
$ /usr/local/bin/grafana-import -d "my-first-dashboard" -p export
OK: dashboard exported to './exports/my-first-dashboard_20210401165925.json'.
```
When the dashboard is not required anymore, you can remove it:
* **remove** the dashboard "my-first-dashboard" from folder "Applications"
```bash
$ grafana-import -f Applications -d "my-first-dashboard" remove
OK: dashboard my-first-dashboard removed from 'Applications'.
```
Loading

0 comments on commit 1994ef4

Please sign in to comment.