module GreenHat::ShellHelper::Filter

Unify Filter / Filter Help

Public Class Methods

help() click to toggle source

rubocop:disable Metrics/MethodLength

# 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 '  Do not use less/paging'
  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 '--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'
  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 '--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