@@ -90,11 +90,8 @@ shui \
9090 --display 3 \
9191 --labels " NVME Used Space" \
9292 --query ' df -h | grep nvme0n1p2 | awk ' \' ' {print $3}' \' ' '
93- ```
94-
95- You can also execute Shui from standard input, which works like query mode.
9693
97- ``` sh
94+ # You can also execute Shui from standard input, which works like query mode.
9895while true ; do uptime; sleep 1; done | shui
9996```
10097
@@ -113,7 +110,37 @@ See [example/shui.toml](example/shui.toml) for an example.
113110> NOTE: Most options may be mixed, but queries and expressions may only be supplied with either
114111> flags or configuration and not both.
115112
116- ### Persistence
113+ ### Manipulating Results
114+
115+ There are ways to play with the results of queries.
116+
117+ - ** Labels** are ways to name a stream of data. Query outputs are expected to be space delimited
118+ information, like a log. Labels allow keyword indexing of these results, creating an untyped
119+ schema. By default, information will be labelled with numeric indexes.
120+
121+ - ** Filters** allow output to be selected for specific labels. This is necessary for some display
122+ modes.
123+
124+ - ** Expressions** allow transformation of results based on a expression statement. This is
125+ [ explained more below] ( #expressions ) .
126+
127+ Queries act as delimiters for these arguments. For example;
128+
129+ ``` sh
130+ shui \
131+ # Labels, filters, and expressions below only apply to this query.
132+ --query ' uptime | awk ' \' ' {print $10 $11 $12}' \' ' | tr "," " "' \
133+ --filters " 5m,10m" \
134+ --labels " 5m,10m,15m" \
135+ --expr ' mean([get(result, "5m"), get(result, "10m")])' \
136+
137+ # Futher labels, filters, and expressions apply to the next query.
138+ --query ' whoami' \
139+ --labels " Me" \
140+ --expr ' upper(get(result, "Me"))'
141+ ```
142+
143+ ### Presisting Results
117144
118145Shui, by default, will store results and load them when re-executing the same query.
119146
@@ -143,11 +170,11 @@ Some examples:
143170``` sh
144171# Multiply the 5m CPU average by 10. Note that we invoke `get` with a key of `"9"` because default
145172# labels are string indexes and no labels were provided.
146- shui --query ' uptime | tr -d ","' -expr ' get(result, "9") * 10'
173+ shui --query ' uptime | tr -d ","' -- expr ' get(result, "9") * 10'
147174
148175# Cumulatively sum 5m CPU average. Note that we need to account for prevResult being empty and we
149176# must convert the prevResult from a string to a float.
150- shui --query ' uptime | tr -d ","' -filters 9 -expr ' get(result, "0") + ("0" in prevResult? float(get(prevResult, "0")) : 0)'
177+ shui --query ' uptime | tr -d ","' -- filters 9 -expr ' get(result, "0") + ("0" in prevResult? float(get(prevResult, "0")) : 0)'
151178```
152179
153180See: < https://expr-lang.org/docs/language-definition >
@@ -165,8 +192,8 @@ Shui can create Elasticsearch documents from results.
165192shui \
166193 --elasticsearch-addr < addr> \
167194 --elasticsearch-index < index> \
168- --elasticsearch-user < user > \
169- --elasticsearch-password < password
195+ --elasticsearch-password < password \
196+ --elasticsearch-user < user >
170197```
171198
172199- Documents are structured according to result labels supplied with ` --labels ` , prefixed with
0 commit comments