grafana-wtf

About

grafana-wtf is a command-line program for accessing Grafana in ways beyond we have been able to do before.

image image image image

Features

  • Use the Grafana HTTP API to inquire detailed information about what’s inside your Grafana instance.
  • Filter and convert ingress data based on different perspectives, using Python code and a CLI interface.
  • Output results in different formats. The program covers JSON, YAML, plain tabular, and colorful CLI reports.
  • Provide a framework for becoming one of the best-in-class looking-glass tools for Grafana, based on a lovely community spirit and creative coding, with a high acceptance for contributions of any sort.

Examples

Some reports of grafana-wtf are provided in JSON and YAML formats, others are just implemented using textual console output. Where data-based reports are used, they can be easily filtered, customized, and converted using downstream programs like jq, by piping the output of grafana-wtf into it.

Search Content

Search Grafana (dashboards and datasources).

grafana-wtf find weatherbase

Explore dashboards and datasources in more detail.

grafana-wtf explore dashboards
grafana-wtf explore datasources

Replace Content

Replace all string matches with another string within the given dashboard’s JSON values.

grafana-wtf --select-dashboard=_JJ22OZZk replace ldi_v2 ldi_v3

Inquire Metadata

General metadata and status inquiry is always nice to have.

# Display a bunch of meta information and statistics.
grafana-wtf info --format=yaml

# Display Grafana version.
grafana-wtf info --format=json | jq -r '.grafana.version'

Want to know something about the status of your plugins?

# Explore plugins.
grafana-wtf plugins list
grafana-wtf plugins status

Watching out for recent editing activity happening on any of your dashboards?

# Display the 50 most recent changes across all dashboards.
grafana-wtf log --number=50

Enjoy exploring more grafana-wtf hands-on recipes on its README.

Install

grafana-wtf is provided as a Python package on PyPI and as an OCI image per GHCR, so you can either install it within a Python environment on your workstation, add it as a library dependency to your project, or easily run it on Docker, Podman, Kubernetes, and friends.

Permanent

pipx install grafana-wtf

Container

Access Grafana instance on localhost, without authentication.

docker run --rm -it \
  --env GRAFANA_URL="http://host.docker.internal:3000" \
  ghcr.io/grafana-toolbox/grafana-wtf grafana-wtf info

Access remote Grafana instance with authentication.

docker run --rm -it \
  --env GRAFANA_URL="https://grafana.example.org/grafana" \
  --env GRAFANA_TOKEN="eyJrIjoiWHg...dGJpZCI6MX0=" \
  ghcr.io/grafana-toolbox/grafana-wtf grafana-wtf info

Read about more detailed setup instructions of grafana-wtf on its README.

Just yesterday, the program received some love to be able to replace stuff within dashboards through Add option to replace string within dashboard · grafana-toolbox/grafana-wtf@a01d8e8 · GitHub. While this is currently a very basic implementation, it can be expanded to be capable of more sophisticated things.

In that manner, we just found Pinch.

Hi again,

grafana-wtf version 0.10.0 has been released and published just yesterday, mitigating some problems with the "replace" subcommand when replacing strings within dashboards and with ANSI escape codes when redirecting the output into other programs or files.

We also have been able to integrate a contribution from the community, unlocking tabular output for the "find" subcommand. Thanks a stack for all bug reports and patches.

Enjoy!

With kind regards,
Andreas.

grafana-wtf 0.19.0 has been released, again with many suggestions for improvements coming from the community. Thank you so much!

The most prominent update, to use grafana-client 4.0.0, revolves around switching the HTTP client backend from Requests to Niquests. Thanks for your support on this matter, Ahmed.