Skip to content

christianrondeau/vim-loggly-search

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vim Loggly Search

Searches for the visually selected text in Loggly.

Installation

Prerequisites

  • A Loggly account
  • Requires curl to be installed and in the PATH.

Plugin

Use your preferred Vim plugin installation method. If you like vim-plug:

Add to your .vimrc:

Plug 'christianrondeau/vim-loggly-search'

And install it:

:PlugInstall

Basic Configuration

You also need to assign these variables in your .vimrc:

" Your <account>.loggly.com
let g:loggly_account = "account_name"

" Either:
"  * --netrc-file path-to-netrc-file (see https://ec.haxx.se/usingcurl-netrc.html)
"  * -u username:password
"  * -H "Authorization: bearer YOUR-LOGGLY-TOKEN" (see https://mediaclip.loggly.com/account/users/api/tokens)
let g:loggly_curl_auth = '-H "Authorization: bearer 00000000-0000-0000-0000-000000000000"'

Windows

Usage

Type <leader>loggly to start a search and show results in a new split buffer. It also will automatically prepopulate the search when using the shortcut in visual mode. It remembers the last search.

You can use the command :LogglySearch "my search query" if you prefer.

Mapping

You can create your own mapping if you want:

map <leader>log <Plug>LogglySearch

You can also create maps for searches you do often:

nnoremap <leader>errors :LogglySearch "json.level:ERROR"<cr>

Settings

let g:loggly_default_from = "-1h"
let g:loggly_default_until = "now"
let g:loggly_default_size = "100"

Find more using :help loggly-search

Extending

You can call arbitrary code after the resut is returned in the buffer, e.g.:

let g:loggly_filter = "call MyLogglyFilter()"

function! MyLogglyFilter()
  " Keep only messages
  v/"message"/d
  %s/\v^ *"message": "//
  %s/\v"$,?//
endfunction

LICENSE

Copyright (c) 2016 Christian Rondeau, under MIT license

About

A vim plug-in to easily search in loggly

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published