Closed rahulnandan closed 11 months ago
Dear @rahulnandan,
thank you for writing in and reporting this. Even reporting such minor findings help tremendously, your evaluation is right, and the presented jq
filter does not work as intended. Your fix does!
With kind regards, Andreas.
Hi again.
4a28071 fixes the wrong documentation about jq
filtering. May I ask you to verify it is correct now?
With kind regards, Andreas.
thanks @amotl , I will verify and update here
Thanks, now I can see the usage description with the proper syntax.
~ grafana-wtf --help
Usage:
grafana-wtf [options] info
grafana-wtf [options] explore datasources
grafana-wtf [options] explore dashboards [--data-details] [--queries-only]
grafana-wtf [options] find [<search-expression>]
grafana-wtf [options] replace <search-expression> <replacement> [--dry-run]
grafana-wtf [options] log [<dashboard_uid>] [--number=<count>] [--head=<count>] [--tail=<count>] [--reverse] [--sql=<sql>]
grafana-wtf [options] plugins list [--id=]
grafana-wtf [options] plugins status [--id=]
grafana-wtf --version
grafana-wtf (-h | --help)
Options:
--grafana-url=<grafana-url> URL to Grafana instance
--grafana-token=<grafana-token> Grafana API Key token
--select-dashboard=<uuid> Restrict operation to dashboard by UID.
Can be a list of comma-separated dashboard UIDs.
--format=<format> Output format. One of textual, tabular, json, yaml.
--cache-ttl=<cache-ttl> Time-to-live for the request cache in seconds. [default: 3600]
--drop-cache Drop cache before requesting resources
--concurrency=<concurrency> Run multiple requests in parallel. [default: 5]
--dry-run Dry-run mode for the `replace` subcommand.
--verbose Enable verbose mode
--version Show version information
--debug Enable debug messages
--http-logging Enable logging for underlying HTTP client machinery
-h --help Show this screen
Note:
Instead of obtaining the URL to the Grafana instance using
the command line option "--grafana-url", you can use the
environment variable "GRAFANA_URL".
Likewise, use "GRAFANA_TOKEN" instead of "--grafana-token"
for propagating the Grafana API Key.
General 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 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 dashboards:
# 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]}'
# 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")'
# Display dashboards and many more details about where data source queries are happening.
# Specifically, within "panels", "annotations", and "templating" slots.
grafana-wtf explore dashboards --data-details --format=json
# Display all database queries within dashboards.
grafana-wtf explore dashboards --data-details --queries-only --format=json | jq '.[].details | values[] | .[] | .expr,.jql,.query,.rawSql | select( . != null and . != "" )'
Find dashboards and data sources:
# Search through all Grafana entities for string "ldi_readings".
grafana-wtf --grafana-url=https://daq.example.org/grafana/ --grafana-token=eyJrIjoiWHg...dGJpZCI6MX0= find ldi_readings
# Search Grafana instance for string "luftdaten", using more convenient invoking flavor.
export GRAFANA_URL=https://daq.example.org/grafana/
export GRAFANA_TOKEN=eyJrIjoiWHg...dGJpZCI6MX0=
grafana-wtf find luftdaten
# Search keyword within list of specific dashboards.
grafana-wtf --select-dashboard=_JJ22OZZk,5iGTqNWZk find grafana-worldmap
# Output search results in tabular format.
grafana-wtf find luftdaten --format=tabular:psql
Replace labels within dashboards:
# Replace string within specific dashboard.
grafana-wtf --select-dashboard=_JJ22OZZk replace grafana-worldmap-panel grafana-map-panel
# Preview the changes beforehand, using the `--dry-run` option.
grafana-wtf --select-dashboard=_JJ22OZZk replace grafana-worldmap-panel grafana-map-panel --dry-run
Display edit history:
# Display 50 most recent changes across all dashboards.
grafana-wtf log --number=50
# Display 5 most recent changes for specific dashboard.
grafana-wtf log NP0wTOtmk --number=5
# Output full history table in Grid format
grafana-wtf log --format=tabular:grid
# Output full history table in Markdown format
grafana-wtf log --format=tabular:pipe
# Display dashboards with only a single edit, in JSON format.
grafana-wtf log --sql="
SELECT uid, url, COUNT(version) as number_of_edits
FROM dashboard_versions
GROUP BY uid, url
HAVING number_of_edits=1
"
# Display dashboards with only a single edit, in YAML format, `url` attribute only.
grafana-wtf log --format=yaml --sql="
SELECT url
FROM dashboard_versions
GROUP BY uid, url
HAVING COUNT(version)=1
"
List plugins:
# Inquire plugin list.
grafana-wtf plugins list
# Inquire plugin health check and metrics endpoints.
grafana-wtf plugins status
Cache control:
# Use infinite cache expiration time, essentially caching forever.
grafana-wtf find '#299c46' --cache-ttl=inf
# Set cache expiration time to zero, essentially disabling the cache.
grafana-wtf find geohash --cache-ttl=0
# Setting `--cache-ttl` per environment variable `CACHE_TTL` is also possible
export CACHE_TTL=infinite
grafana-wtf find geohash```
Excellent. Closing this. Thanks.
it's a very minor finding, issue- cli usage mentions one of the command as below.
fix- but, the proper syntax should be as below. I have not looked at the others but, they also may have issues