Skip to content

Commit a50d84e

Browse files
committed
Improve documentation
1 parent 8af7476 commit a50d84e

File tree

3 files changed

+69
-55
lines changed

3 files changed

+69
-55
lines changed

README.rst

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -103,36 +103,16 @@ Before running ``grafana-wtf``, define URL and access token of your Grafana inst
103103
export GRAFANA_TOKEN=eyJrIjoiWHg...dGJpZCI6MX0=
104104

105105

106-
Searching for strings
107-
=====================
108-
109-
Find the string ``weatherbase`` throughout all dashboards and data sources::
110-
111-
grafana-wtf find weatherbase
112-
113-
.. note::
114-
115-
``grafana-wtf`` will cache HTTP responses for 300 seconds by default.
116-
When running it with the ``--drop-cache`` option, it will drop its cache upfront.
117-
118-
119-
Replacing strings
120-
=================
121-
122-
Replace all occurrences of ``ldi_v2`` with ``ldi_v3`` within dashboard with
123-
UID ``_JJ22OZZk``::
124-
125-
grafana-wtf --select-dashboard=_JJ22OZZk replace ldi_v2 ldi_v3
126-
127-
128-
Displaying changes / revision logs
129-
==================================
106+
General information
107+
===================
130108

131-
Watching out for recent editing activity on any dashboards?
132109
::
133110

134-
# Display 50 most recent changes across all dashboards.
135-
grafana-wtf log --number=50
111+
# Display a bunch of meta information and statistics.
112+
grafana-wtf info --format=yaml
113+
114+
# Display Grafana version.
115+
grafana-wtf info --format=json | jq -r '.grafana.version'
136116

137117

138118
Explore data sources
@@ -161,15 +141,37 @@ How to find dashboards which use non-existing data sources?
161141
grafana-wtf explore dashboards --format=json | jq '.[] | select( .datasources_missing ) | .dashboard + {ds_missing: .datasources_missing[] | [.name]}'
162142

163143

164-
Display common information and statistics
165-
=========================================
144+
Searching for strings
145+
=====================
146+
147+
Find the string ``weatherbase`` throughout all dashboards and data sources::
148+
149+
grafana-wtf find weatherbase
150+
151+
.. note::
152+
153+
``grafana-wtf`` will cache HTTP responses for 300 seconds by default.
154+
When running it with the ``--drop-cache`` option, it will drop its cache upfront.
155+
156+
157+
Replacing strings
158+
=================
159+
160+
Replace all occurrences of ``ldi_v2`` with ``ldi_v3`` within dashboard with
161+
UID ``_JJ22OZZk``::
162+
163+
grafana-wtf --select-dashboard=_JJ22OZZk replace ldi_v2 ldi_v3
164+
165+
166+
Display edit history
167+
====================
168+
169+
Watching out for recent editing activity on any dashboards?
166170
::
167171

168-
# Display a bunch of meta information and statistics.
169-
grafana-wtf info --format=yaml
172+
# Display 50 most recent changes across all dashboards.
173+
grafana-wtf log --number=50
170174

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

174176

175177
********

doc/backlog.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ Prio 1
99
- [o] Dockerize
1010
- [o] Statistics reports for data sources and panels: https://github.com/panodata/grafana-wtf/issues/18
1111
- [o] Finding invalid data sources: https://github.com/panodata/grafana-wtf/issues/19
12+
- [o] Add test fixture for adding dashboards at runtime from branch ``amo/test-dashboard-runtime``
1213

1314

1415
********
1516
Prio 1.5
1617
********
17-
- [o] Check if we can collect metrics from Grafana
18-
- https://grafana.com/docs/grafana/latest/administration/view-server/internal-metrics/
19-
- https://grafana.com/docs/grafana/latest/developers/plugins/backend/#collect-metrics
18+
- [o] Search through more Grafana entities (users, organizations, teams)
2019
- [o] Add test fixture which completely resets everything in Grafana before running the test harness.
2120
Move to a different port than 3000 then!
2221
- [o] Improve output format handling and error cases
@@ -37,6 +36,9 @@ Prio 2
3736
- [o] grafana-wtf log --tail | discourse
3837
- [o] grafana-wtf log --tail | wtee
3938
- [o] grafana-wtf export/import
39+
- [o] Check if we can collect metrics from Grafana
40+
- https://grafana.com/docs/grafana/latest/administration/view-server/internal-metrics/
41+
- https://grafana.com/docs/grafana/latest/developers/plugins/backend/#collect-metrics
4042

4143

4244
****

grafana_wtf/commands.py

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,33 @@ def run():
5656
Likewise, use "GRAFANA_TOKEN" instead of "--grafana-token"
5757
for propagating the Grafana API Key.
5858
59-
Search examples:
59+
60+
General information:
61+
62+
# Display a bunch of meta information and statistics.
63+
grafana-wtf info --format=yaml
64+
65+
# Display Grafana version.
66+
grafana-wtf info --format=json | jq -r '.grafana.version'
67+
68+
Explore data sources:
69+
70+
# Display all data sources and the dashboards using them, as well as unused data sources.
71+
grafana-wtf explore datasources --format=yaml
72+
73+
# Display names of unused datasources as a flat list.
74+
grafana-wtf explore datasources --format=json | jq -r '.unused[].datasource.name'
75+
76+
Explore dashboards:
77+
78+
# Display some details of all dashboards, including names of missing data sources.
79+
grafana-wtf explore dashboards --format=yaml
80+
81+
# Display only dashboards which have missing data sources, along with their names.
82+
grafana-wtf explore dashboards --format=json | jq '.[] | select( .datasources_missing ) | .dashboard + {ds_missing: .datasources_missing[] | [.name]}'
83+
84+
85+
Find dashboards and data sources:
6086
6187
# Search through all Grafana entities for string "ldi_readings".
6288
grafana-wtf --grafana-url=https://daq.example.org/grafana/ --grafana-token=eyJrIjoiWHg...dGJpZCI6MX0= find ldi_readings
@@ -78,12 +104,12 @@ def run():
78104
# Output search results in tabular format.
79105
grafana-wtf find luftdaten --format=tabular:psql
80106
81-
Replace examples:
107+
Replace labels within dashboards:
82108
83109
# Replace string within specific dashboard.
84110
grafana-wtf --select-dashboard=_JJ22OZZk replace grafana-worldmap-panel grafana-map-panel
85111
86-
History examples:
112+
Display edit history:
87113
88114
# Display 50 most recent changes across all dashboards.
89115
grafana-wtf log --number=50
@@ -97,22 +123,6 @@ def run():
97123
# Output full history table in Markdown format
98124
grafana-wtf log --format=tabular:pipe
99125
100-
Explore data sources:
101-
102-
# Display all data sources and the dashboards using them, as well as unused data sources.
103-
grafana-wtf explore datasources --format=yaml
104-
105-
# Display names of unused datasources as a flat list.
106-
grafana-wtf explore datasources --format=json | jq -r '.unused[].datasource.name'
107-
108-
Explore dashboards:
109-
110-
# Display some details of all dashboards, including names of missing data sources.
111-
grafana-wtf explore dashboards --format=yaml
112-
113-
# Display only dashboards which have missing data sources, along with their names.
114-
grafana-wtf explore dashboards --format=json | jq '.[] | select( .datasources_missing ) | .dashboard + {ds_missing: .datasources_missing[] | [.name]}'
115-
116126
"""
117127

118128
# Parse command line arguments

0 commit comments

Comments
 (0)