Package: grafana-wtf
grafana-wtfAboutgrafana-wtf - grep through all Grafana entities in the spirit ofgit-wtf.Attention!This program can put significant load on your Grafana instance
and the underlying database machinery. Handle with care!SynopsisSearch Grafana (dashboards and datasources) for string “weatherbase”.grafana-wtf find weatherbaseDisplay 50 most recent changes across all dashboards.grafana-wtf log --number=50Explore dashboards and datasources in more detail.grafana-wtf explore dashboards
grafana-wtf explore datasourcesExplore plugins.grafana-wtf plugins list
grafana-wtf plugins statusRun with Docker:# Access Grafana instance on localhost, without authentication.
docker run --rm -it \
    --env GRAFANA_URL="http://host.docker.internal:3000" \
    ghcr.io/panodata/grafana-wtf grafana-wtf info

# Access Grafana instance with authentication.
docker run --rm -it \
    --env GRAFANA_URL="https://grafana.example.org/grafana" \
    --env GRAFANA_TOKEN="eyJrIjoiWHg...dGJpZCI6MX0=" \
    ghcr.io/panodata/grafana-wtf grafana-wtf infoScreenshotsgrafana-wtffindgrafana-wtflogSetupInstallgrafana-wtfpip install grafana-wtfConfigure GrafanaPlease take these steps to create an API key with your Grafana instance:Go tohttps://daq.example.org/grafana/org/apikeys.Choose “New API Key”.Key name: grafana-wtfRole: AdminFrom the outputcurl-H"Authorization: BearereyJrIjoiWHg...dGJpZCI6MX0="...,
please take note of the Bearer token. This is your Grafana API key.ConfigurationGrafana connectionTo configure to which Grafana instance to connect to, and how to authenticate, use
the--grafana-urland--grafana-tokencommand line options.Alternatively, before runninggrafana-wtf, you can define URL and access token
of your Grafana instance by using environment variables:export GRAFANA_URL=https://daq.example.org/grafana/
export GRAFANA_TOKEN=eyJrIjoiWHg...dGJpZCI6MX0=In order to accept untrusted SSL certificates, append the?verify=noquery string
to theGRAFANA_URL:export GRAFANA_URL=https://daq.example.org/grafana/?verify=noCachinggrafana-wtfwill cache HTTP responses for 60 minutes by default, in order to save
resources, by not hitting the server each server. You can configure that setting by using
the--cache-ttloption, or theCACHE_TTLenvironment variable.When invoking the program with the--drop-cacheoption, it will drop its cache upfront.UsageGeneral information# 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'Explore data sourcesHow to find unused data sources?# Display all data sources and the dashboards using them, as well as unused data sources.
grafana-wtf explore datasources --format=yaml

# Display names of unused datasources as a flat list.
grafana-wtf explore datasources --format=json | jq -r '.unused[].datasource.name'Explore dashboardsHow to find dashboards which use non-existing data sources?# Display some details of all dashboards, including names of missing data sources.
grafana-wtf explore dashboards --format=yaml

# Display only dashboards which have missing data sources, along with their names.
grafana-wtf explore dashboards --format=json | \
    jq '.[] | select(.datasources_missing) | .dashboard + {ds_missing: .datasources_missing[] | [.name]}'How to find dashboards using specific data sources?# Display all dashboards which use a specific data source, filtered by data source name.
grafana-wtf explore dashboards --format=json | jq '.[] | select(.datasources | .[].type=="<datasource_name>")'

# Display all dashboards using data sources with a specific type. Here: InfluxDB.
grafana-wtf explore dashboards --format=json | jq '.[] | select(.datasources | .[].type=="influxdb")'How to list all queries used in all dashboards?grafana-wtf explore dashboards --data-details --queries-only --format=json | \
    jq '.[].details | values[] | .[] | .expr,.jql,.query,.rawSql | select( . != null and . != "" )'Searching for stringsFind the stringweatherbasethroughout all dashboards and data sources:grafana-wtf find weatherbaseReplacing stringsReplace all occurrences ofldi_v2withldi_v3within dashboard with
UID_JJ22OZZk:grafana-wtf --select-dashboard=_JJ22OZZk replace ldi_v2 ldi_v3In order to preview the changes, you should use the--dry-runoption
beforehand:grafana-wtf --select-dashboard=_JJ22OZZk replace ldi_v2 ldi_v3 --dry-runDisplay edit historyWatching out for recent editing activity on any dashboards?# Display 50 most recent changes across all dashboards.
grafana-wtf log --number=50ExamplesFor discovering more command line parameters and their arguments, please invokegrafana-wtf--helpand have a look atgrafana-wtf examples.Developmentgit clone https://github.com/panodata/grafana-wtf
cd grafana-wtf

# Run all tests.
make test

# Run selected tests.
pytest --keepalive -vvv -k test_find_textual