Module: GreenHat::ShellHelper::Filter

Defined in:
lib/greenhat/shell/filter_help.rb

Overview

Unify Filter / Filter Help

Class Method Summary collapse

Class Method Details

.helpObject

rubocop:disable Metrics/MethodLength



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/greenhat/shell/filter_help.rb', line 7

def self.help
  puts "\u2500".pastel(:cyan) * 20
  puts 'Filter'.pastel(:yellow)
  puts "\u2500".pastel(:cyan) * 20

  puts 'Options'.pastel(:blue)
  puts '--raw'.pastel(:green)
  puts '  Disable formatting and page/less'
  puts

  puts '--page'.pastel(:green)
  puts '  Specifically enable or disable paging'
  puts '  E.g. --page (default to true), --page=true, --page=false'
  puts

  puts '--round'.pastel(:green)
  puts '  Attempt to round all integers. Default: 2.'
  puts '  E.g. --round, --round=3, --round=0'
  puts

  puts '--limit'.pastel(:green)
  puts '  Limit total output lines. Disabled by default. Default without value is based on screen height'
  puts '  E.g. --limit, --limit=5'
  puts

  puts '--json'.pastel(:green)
  puts '  Print output back into JSON'
  puts

  puts '--or'.pastel(:green)
  puts '  Filters will use OR instead of AND (all match vs any match)'
  puts

  puts '--total'.pastel(:green)
  puts '  Print only total count of matching entries'
  puts

  puts '--fields'.pastel(:green)
  puts '  Print only Available fields for selected files'
  puts

  puts '--slice'.pastel(:green)
  puts '  Extract specific fields from entries (slice multiple with comma)'
  puts '  Ex: --slice=path or --slice=path,params'
  puts

  puts '--except'.pastel(:green)
  puts '  Exclude specific fields (except multiple with comma)'
  puts '  Ex: --except=params --except=params,path'
  puts

  puts '--exists'.pastel(:green)
  puts '  Ensure field exists regardless of contents'
  puts '  Ex: --exists=params --exists=params,path'
  puts

  puts '--stats'.pastel(:green)
  puts '  Order/Count occurrances by field. Combine with `truncate` for key names'
  puts '  Ex: --stats=params --except=params,path'
  puts

  puts '--uniq'.pastel(:green)
  puts '  Show unique values only'
  puts '  Ex: --uniq=params --uniq=params,path'
  puts

  puts '--pluck'.pastel(:green)
  puts '  Extract values from entries'
  puts '  Ex: --pluck=params --pluck=params,path'
  puts

  puts '--archive'.pastel(:green)
  puts '  Limit to specific archvie name (partial matching /inclusive). Matching SOS tar.gz name'
  puts '  Ex: --archive=dev-gitlab_20210622154626, --archive=202106,202107'
  puts

  puts '--sort'.pastel(:green)
  puts '  Sort by multiple fields'
  puts '  Ex: --sort=duration_s,db_duration_s'
  puts

  puts '--reverse'.pastel(:green)
  puts '  Reverse all results'
  puts '  Ex: --reverse'
  puts

  puts '--combine'.pastel(:green)
  puts '  Omit archive identifier dividers. Useful with sort or time filters'
  puts '  Ex: --combine'
  puts

  puts '--case'.pastel(:green)
  puts '  Exact case match. Defaults to case insensitive'
  puts '  Ex: --case; --name=Jon, --name=jane --case'
  puts

  puts '--exact'.pastel(:green)
  puts '  Exact parameter/value match. Defaults to partial match'
  puts '  Ex: --field=CommonPartial --exact'
  puts

  puts '--start'.pastel(:green)
  puts '  Show events after specified time. Filtered by the `time` field'
  puts '  Use with `--end` for between selections'
  puts '  Ex: log filter --start="2021-06-22 14:44 UTC" --end="2021-06-22 14:45 UTC"'
  puts

  puts '--end'.pastel(:green)
  puts '  Show events before specified time. Filtered by the `time` field'
  puts '  Use with `--start` for between selections'
  puts '  Ex: log filter --end="2021-06-22"'
  puts

  puts '--time_zone'.pastel(:green)
  puts '  Manipulate the `time` field into a specific timezone'
  puts '  Ex: log filter --time_zone=EDT'
  puts

  puts '--text'.pastel(:green)
  puts '  Full entry text searching (slow)'
  puts '    --text="anything here"'
  puts

  puts '--table_style'.pastel(:green)
  puts '  Renderer used for formatted output. basic, ascii, or unicode(default)'
  puts '  Ex: log filter --table_style=base'
  puts

  puts '--truncate'.pastel(:green)
  puts '  Truncate field length. On by default (4 rows). Performance issues!'
  puts '  Disable with --truncate=0'.pastel(:bright_red)
  puts '  Ex: --truncate=200, --truncate=2048"'
  puts

  puts 'Field Searching'.pastel(:blue)
  puts '  --[key]=[value]'
  puts '  Search in key for value'
  puts '  Example: --path=mirror/pull'
  puts

  puts 'Search specific logs'.pastel(:blue)
  puts '  Any non dash parameters will be the log list to search from'
  puts "  Ex: log filter --path=api sidekiq/current (hint: use  `#{'ls'.pastel(:yellow)}` for log names"
  puts

  puts 'Example Queries'.pastel(:blue)
  puts "  Also see #{'examples'.pastel(:bright_blue)} for even more examples"
  puts '  log filter --class=BuildFinishedWorker sidekiq/current --slice=time,message'
  puts '  log filter gitlab-rails/api_json.log --slice=ua --uniq=ua --ua=gitlab-runner'

  puts
end