Searches for the visually selected text in Loggly.
- A Loggly account
- Requires
curl
to be installed and in thePATH
.
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
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"'
- Install cURL and make sur it's in your
PATH
- Download https://curl.haxx.se/ca/cacert.pem as
curl-ca-bundle.crt
, and put it somewhere available in yourPATH
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.
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>
let g:loggly_default_from = "-1h"
let g:loggly_default_until = "now"
let g:loggly_default_size = "100"
Find more using :help loggly-search
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
Copyright (c) 2016 Christian Rondeau, under MIT license