LinuxCommandLibrary

grafana-cli

Manage Grafana plugins

TLDR

Install, update, or remove specific plugins

$ grafana-cli plugins [install|update|remove] [plugin_id1 plugin_id2 ...]
copy

List all installed plugins
$ grafana-cli plugins ls
copy

SYNOPSIS

grafana-cli [global-options] command [command-options] [arguments]

PARAMETERS

plugins
    Subcommands for managing Grafana plugins:

  • install : Installs a specified plugin from the official Grafana plugin repository.
  • ls: Lists all currently installed plugins.
  • update : Updates a specific plugin to its latest compatible version.
  • update-all: Updates all installed plugins to their latest compatible versions.
  • remove : Uninstalls a specified plugin.


admin
    Subcommands for administrative tasks:
  • reset-admin-password : Resets the password for the default Grafana administrator user.
  • change-user-password : Changes the password for a specific user.
  • panel-plugins-version-check: Checks if all installed panel plugins are compatible with the current Grafana version.


upgrade
    Migrates the Grafana database to the latest version required by a Grafana upgrade. Typically run after a Grafana binary update.

--version / -v
    Displays the current version of grafana-cli.

--help / -h
    Displays help information for the command or a subcommand.

DESCRIPTION

grafana-cli is the official command-line utility for managing Grafana installations. It serves as a powerful tool for administrators to perform various operations, primarily focused on plugin management such as installing, listing, updating, and removing plugins. Beyond plugins, it also provides functionalities for administrative tasks like resetting administrator passwords, changing user passwords, upgrading Grafana, and validating configurations.

It is an essential component for automating Grafana maintenance tasks, especially in environments where direct access to the Grafana UI might be restricted or for scripting deployments. The command operates directly on the Grafana installation directory, requiring appropriate permissions, often `sudo`, to modify system-level files or install plugins into Grafana's data directories.

CAVEATS

  • Requires appropriate file system permissions, often `sudo` or root privileges, to install plugins or modify Grafana configurations, especially when Grafana is installed in system directories.
  • After installing, updating, or removing plugins, it is usually necessary to restart the Grafana server process for the changes to take effect.
  • The grafana-cli binary must be accessible in the system's PATH or invoked with its full path (e.g., `/usr/sbin/grafana-cli`).
  • Plugin installation requires an active internet connection to download from the Grafana plugin repository.
  • Running the upgrade command without prior Grafana binary update can lead to unexpected behavior.

EXECUTION CONTEXT

grafana-cli typically needs to be run from the Grafana installation directory or pointed to it via environment variables if the Grafana service is not running. However, when installed via system packages, it's often configured to locate the Grafana installation automatically.

PLUGIN DEPENDENCIES

Some plugins may have external dependencies that need to be manually installed on the operating system before the plugin can function correctly. This is usually specified in the plugin's documentation.

HISTORY

grafana-cli was introduced relatively early in Grafana's development lifecycle to simplify plugin management and offer command-line administrative capabilities. As Grafana grew in popularity and functionality, the CLI evolved to support more administrative tasks, becoming an indispensable tool for deployments, automation, and troubleshooting, especially for large-scale or non-GUI Grafana installations. Its design allows for direct interaction with the Grafana backend without needing to access the web UI.

SEE ALSO

systemctl(1), journalctl(1), apt(8), yum(8), docker(1)

Copied to clipboard