Skip to content

Commit fe44cd3

Browse files
author
Matthew Coleman
committed
Update readme with selective labels/filters/expressions
1 parent 440f159 commit fe44cd3

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

README.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
9895
while true; do uptime; sleep 1; done | shui
9996
```
10097

@@ -113,7 +110,21 @@ 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 rumerically indexed.
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+
### Presisting Results
117128

118129
Shui, by default, will store results and load them when re-executing the same query.
119130

@@ -143,11 +154,11 @@ Some examples:
143154
```sh
144155
# Multiply the 5m CPU average by 10. Note that we invoke `get` with a key of `"9"` because default
145156
# labels are string indexes and no labels were provided.
146-
shui --query 'uptime | tr -d ","' -expr 'get(result, "9") * 10'
157+
shui --query 'uptime | tr -d ","' --expr 'get(result, "9") * 10'
147158

148159
# Cumulatively sum 5m CPU average. Note that we need to account for prevResult being empty and we
149160
# 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)'
161+
shui --query 'uptime | tr -d ","' --filters 9 -expr 'get(result, "0") + ("0" in prevResult? float(get(prevResult, "0")) : 0)'
151162
```
152163

153164
See: <https://expr-lang.org/docs/language-definition>
@@ -165,8 +176,8 @@ Shui can create Elasticsearch documents from results.
165176
shui \
166177
--elasticsearch-addr <addr> \
167178
--elasticsearch-index <index> \
168-
--elasticsearch-user <user> \
169-
--elasticsearch-password <password
179+
--elasticsearch-password <password \
180+
--elasticsearch-user <user>
170181
```
171182

172183
- Documents are structured according to result labels supplied with `--labels`, prefixed with

cmd/shui/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ var (
8383
"elasticsearch.index": "elasticsearch-index",
8484
"elasticsearch.password": "elasticsearch-password",
8585
"elasticsearch.user": "elasticsearch-user",
86+
"prometheus.exporter": "prometheus-exporter",
87+
"prometheus.pushgateway": "prometheus-pushgateway",
8688
"tui.padding.bottom": "outer-padding-bottom",
8789
"tui.padding.left": "outer-padding-left",
8890
"tui.padding.right": "outer-padding-right",
8991
"tui.padding.top": "outer-padding-top",
90-
"prometheus.exporter": "prometheus-exporter",
91-
"prometheus.pushgateway": "prometheus-pushgateway",
9292
"tui.show.help": "show-help",
9393
"tui.show.logs": "show-logs",
9494
"tui.show.status": "show-status",

0 commit comments

Comments
 (0)