All Projects → m110 → Grafcli

m110 / Grafcli

Licence: mit
Grafana CLI for quick and easy dashboards management.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Grafcli

Pgwatch2
PostgreSQL metrics monitor/dashboard
Stars: ✭ 960 (+531.58%)
Mutual labels:  grafana, dashboard
Spring Boot Actuator Demo
Spring Boot Actuator: Health Check, Metrics Gathering, Auditing, and Monitoring
Stars: ✭ 61 (-59.87%)
Mutual labels:  grafana, dashboard
Solarthing
Monitors an Outback MATE and a Renogy Rover - MPPT Charge Controller. Integrates with Grafana, PVOutput and more!
Stars: ✭ 33 (-78.29%)
Mutual labels:  grafana, dashboard
Prometheus
Kubernetes Setup for Prometheus and Grafana
Stars: ✭ 824 (+442.11%)
Mutual labels:  grafana, dashboard
Dynein
DynamoDB CLI written in Rust.
Stars: ✭ 126 (-17.11%)
Mutual labels:  cli, backup
Mongodb Backup Cli
mongodb-backup cli for Nodejs
Stars: ✭ 17 (-88.82%)
Mutual labels:  cli, backup
Grafana Zabbix Dashboards
Grafana dashboards for Zabbix
Stars: ✭ 50 (-67.11%)
Mutual labels:  grafana, dashboard
Mt Aws Glacier
Perl Multithreaded Multipart sync to Amazon Glacier
Stars: ✭ 522 (+243.42%)
Mutual labels:  cli, backup
Butler
Export/Import Jenkins jobs & plugins 📤
Stars: ✭ 113 (-25.66%)
Mutual labels:  cli, backup
Grafana
The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
Stars: ✭ 45,930 (+30117.11%)
Mutual labels:  grafana, dashboard
Bandwhich
Terminal bandwidth utilization tool
Stars: ✭ 6,737 (+4332.24%)
Mutual labels:  cli, dashboard
Ghbackup
Embarrassingly simple GitHub backup tool
Stars: ✭ 139 (-8.55%)
Mutual labels:  cli, backup
Grafterm
Metrics dashboards on terminal (a grafana inspired terminal version)
Stars: ✭ 613 (+303.29%)
Mutual labels:  grafana, dashboard
Devdash
🍱 Highly Configurable Terminal Dashboard for Developers and Creators
Stars: ✭ 939 (+517.76%)
Mutual labels:  cli, dashboard
World Cup 2018 Cli Dashboard
⚽🏆A World Cup 2018 CLI dashboard – Watch matches in your terminal
Stars: ✭ 529 (+248.03%)
Mutual labels:  cli, dashboard
Iota Prom Exporter
Iota Exporter for Prometheus Metrics
Stars: ✭ 33 (-78.29%)
Mutual labels:  grafana, dashboard
Telegram backup
Java app to download all your telegram data.
Stars: ✭ 409 (+169.08%)
Mutual labels:  cli, backup
Docker monitoring logging alerting
Docker host and container monitoring, logging and alerting out of the box using cAdvisor, Prometheus, Grafana for monitoring, Elasticsearch, Kibana and Logstash for logging and elastalert and Alertmanager for alerting.
Stars: ✭ 479 (+215.13%)
Mutual labels:  grafana, dashboard
Grafana Aws Cloudwatch Dashboards
☁️ 30+ Grafana dashboards for AWS CloudWatch metrics: EC2, Lambda, S3, ELB, EMR, EBS, SNS, SES, SQS, RDS, EFS, ElastiCache, Billing, API Gateway, VPN, Step Functions, Route 53, CodeBuild, ...
Stars: ✭ 1,210 (+696.05%)
Mutual labels:  grafana, dashboard
Kui
A hybrid command-line/UI development experience for cloud-native development
Stars: ✭ 2,052 (+1250%)
Mutual labels:  cli, dashboard

grafcli

Build Status

Grafana CLI for fast and easy dashboards management.

Please note that grafcli has been tested for a while, but it still can have some minor defects. All help by contributions and suggestions is welcomed! Remember to back up your dashboards first.

Also note that grafcli was created when grafana itself lacked some features, like exports or API. Although it's still nice to have some of those in form of a CLI application.

Credit goes to b3niup for the original idea!

Featuring:

  • Dashboards backup and restore.
  • Easy rows and panels moving/copying between dashboards.
  • Editing dashboards/rows/panels in-place.
  • Templates of dashboards, rows and panels.
  • File export/import.
  • Interactive CLI with completions support.
  • Compatibility across older Grafana versions.
  • ...and more!

Why?

  • Lets you easily manage your dashboards using just your keyboard.
  • Provides convenient way to backup dashboards and restore them.
  • Can be used by any shell script with even more logic added.

How?

Grafcli connects to Grafana HTTP API or directly to one of the backends (Elastic, SQLite, MySQL, PostgreSQL) and modifies the dashboards. This is all hidden behind an interface you already know well, similar to *nix filesystem.

Requirements

Installation

pip3 install grafcli

or get the source and run:

python3 setup.py install

Then define your hosts in the config file (see below for details).

cp /etc/grafcli/grafcli.conf.example /etc/grafcli/grafcli.conf

You will need at least one of the backend libraries listed above (except sqlite3, which comes with Python).

TODO

  • Improve confirmation prompt.
  • Improve completions.
  • Implement asterisk (*) handling.

Usage

Navigation

Use cd and ls commands to list nodes and move around.

[/]> cd templates
[/templates]> ls
dashboards
rows
panels
[/templates]> ls dashboards
example_dashboard
another_dashboard
[/templates]> ls dashboards/example_dashboard
1-Example-Row
2-Another-Row
3-Yet-Another-Row
[/templates]> ls dashboards/example_dashboard/1-Example-Row
1-Example-Panel
2-Another-Panel

Directories

In the root directory, you will find three basic directories:

  • backups - for storing backups of your dashboards (surprised?).
  • remote - which lets you access remote hosts.
  • templates - that contains templates of dashboards, rows and panels.

Management

Most of the arguments here are paths to a dashboard, row or panel.

  • cat <path> - display JSON of given element.
  • $EDITOR <path> - edit the JSON of given element in-place and update it afterwards. Editor name can be set in the config file.
  • merge <paths> - merge documents together. Merge tool can be set in the config file.
  • cp <source> <destination> - copies one element to another. Can be used to copy whole dashboards, rows or single panels.
  • mv <source> <destination> - the same as cp, but moves (renames) the source.
  • rm <path> - removes the element.
  • template <path> - saves element as template.
  • backup <remote_host> <system_path> - saves backup of all dashboards from remote host as .tgz archive.
  • restore <system_path> <remote_host> - restores saved backup.
  • export <path> <system_path> - saves the JSON-encoded element to file.
  • import <system_path> <path> - loads the JSON-encoded element from file.
  • pos <path> <index> - change position of row in a dashboard or panel in a row.

Configuration

Grafcli will attempt to read ./grafcli.conf, ~/.grafcli.conf and /etc/grafcli/grafcli.conf in that order.

Here is the configuration file explained.

[grafcli]
# Your favorite editor - this name will act as a command!
editor = vim
# Executable used as merge tool. Paths will be passed as arguments.
mergetool = vimdiff
# Commands history file. Leave empty to disable.
history = ~/.grafcli_history
# Additional verbosity, if needed.
verbose = off
# Answer 'yes' to all overwrite prompts.
force = on

[resources]
# Directory where all local data will be stored (including backups).
data-dir = ~/.grafcli

# List of remote Grafana hosts.
# The key names do not matter, as long as matching section exists.
# Set the value to off to disable the host.
[hosts]
host.example.com = on

[host.example.com]
type = elastic
# In case of more hosts, use comma-separated values.
hosts = host1.example.com,host2.example.com
port = 9200
index = grafana-dash
ssl = off
# HTTP user and password, if any.
user =
password =

You can use other backends as well.

HTTP API:

[api.example.com]
type = api
url = http://localhost:3000/api
# Use either user and password or just the token
user =
password =
# token can also be stored in the GRAFANA_API_TOKEN environment variable
token =

MySQL:

[mysql.example.com]
type = mysql
host = mysql.example.com
port = 3306
user = grafana
password =
database = grafana

PostgreSQL:

[postgresql.example.com]
type = postgresql
host = postgresql.example.com
port = 5432
user = grafana
password =
database = grafana

SQLite:

[sqlite.example.com]
type = sqlite
path = /opt/grafana/data/grafana.db

Tips

Batch mode

Any command can be passed directly as arguments to grafcli, which will exit just after executing it. If you run it without arguments, you will get to interactive mode (preferable choice in most cases).

Batch mode:

$ grafcli ls remote
host.example.com
another.example.com
$ 

Interactive mode:

$ grafcli
[/]> ls remote
host.example.com
another.example.com
[/]> 

Short names

All rows and panels names start with a number and it may seem that typing all that stuff gets boring soon. There are completions available (triggered by the TAB key) to help you with that.

It is enough to provide just the number of the row or panel. So instead of typing:

[/]> cp /templates/dashboards/dashboard/1-Top-Row/1-Top-Panel /remote/example/dashboard/1-Top-Row

You can just do:

[/]> cp /templates/dashboards/dashboard/1/1 /remote/example/dashboard/1

But then again, TAB-completions make it easy enough to type full names.

Examples

Some of the common operations.

  • Store dashboard as template (saved to templates/dashboards/main_dashboard):
[/]> template remote/example/main_dashboard
  • Create the exact copy of dashboard's template:
[/templates/dashboards]> cp main_dashboard new_dashboard
  • Update remote dashboard with local template:
[/]> cp templates/dashboards/new_dashboard remote/main_dashboard
  • Move row from one dashboard to another (adds one more row to destination dashboard):
[/templates/dashboards]> cp main_dashboard/1-Top-Row new_dashboard
  • Move row from one dashboard to another and replace existing row:
[/templates/dashboards]> cp main_dashboard/1-Top-Row new_dashboard/2-Some-Existing-Row
  • Copy panel between rows (add one more panel to destination row).
[/templates/dashboards]> cp main_dashboard/1-Top-Row/1-Top-Panel new_dashboard/1-Top-Row
  • Copy panel between rows and replace existing panel.
[/templates/dashboards]> cp main_dashboard/1-Top-Row/1-Top-Panel new_dashboard/1-Top-Row/2-Second-Panel
  • Backup all dashboards.
[/] backup remote/example ~/backup.tgz
  • Restore a backup.
[/] restore ~/backup.tgz remote/example
  • Import dashboard from a file.
[/]> import ~/dashboard.json templates/dashboards/dashboard
  • Export dashboard to a file.
[/]> export templates/dashboards/dashboard ~/dashboard.json

Development

Running tests

Unit tests can be run by:

make unittests

To run integration tests:

make integration

The first run of integration tests can take a bit longer, since images will be built and downloaded.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].