Graylog command line interface (pygray fork).
Project description
PyGray
===============================
* Free software: Apache Software License 2.0
PyGray is an open source command line interface for Graylog2.
Instalation
--------
Try:
pip3 install pygray
or you can even install it from a GitHub clone:
git clone https://github.com/globocom/pygray
cd pygray/
pip3 install . -r requirements.txt
Usage
--------
PyGray enables you to make searches using the official Graylog query language. To understand how to make queries
please see the `documentation <http://docs.graylog.org/en/2.1/pages/queries.html>`.
Once you've installed the tool now it's time to run some commands, the following:
> pygray -h mygraylog.server.com -u john.doe -p password -@ "10 minutes ago" "source:my-app-server"
-
> pygray -h mygraylog.server.com -u john.doe -p password "message:200"
-
> pygray -h mygraylog.server.com -u john.doe -p password -f
-
> pygray -h mygraylog.server.com -u john.doe -p password "level:DEBUG"
-
> pygray -h mygraylog.server.com -u john.doe -p password "level:DEBUG" -f
-
> pygray -h mygraylog.server.com -u john.doe -p password "level:DEBUG" -d --fields timestamp,level,message -o dump.csv
-
> pygray -h mygraylog.server.com -u john-doe -p password -@ "2016-11-21 00:00:00" -# "2016-11-21 01:00:00" 'message:blabla'
-
> pygray -e dev -r short
-
> pygray -e dev -r short -st mystreamid
-
> pygray -e dev -r short -st '*'
Configuration
--------
PyGray can reuse some common configurations like address of your Graylog server and your credentials, it will look for a
*~/.pygray.cfg* or a *pygray.cfg* (in your current directory). PyGray will use default environment and format
whenever an environment or format is omitted.
Here is a example for your pygray.cfg file:
[environment:default]
host=mygraylogserver.com
port=443
username=john.doe
[environment:dev]
host=mygraylogserver.dev.com
port=443
proxy=mycompanyproxy.com
username=john.doe
default_stream=57e14cde6fb78216a60d35e8
[format:default]
format={host} {level} {facility} {timestamp} {message}
[format:short]
format=[{timestamp}] {level} {message}
[format:long]
format=time: [{timestamp}] level: {level} msg: {message} tags: {tags}
color=false
Please run the *help* command to more detailed information about all the client features.
Usage: pygray [OPTIONS] [QUERY]
Options:
-v, --version Prints your pygray version
-h, --host TEXT Your graylog node's host
-e, --environment TEXT Label of a preconfigured graylog node
-sq, --saved-query List user saved queries for selection
--port TEXT Your graylog port
--no-tls Not use TLS to connect to Graylog server
-u, --username TEXT Your graylog username
-p, --password TEXT Your graylog password (default: prompt)
-k, --keyring / -nk, --no-keyring
Use keyring to store/retrieve password
-@, --search-from TEXT Query range from
-#, --search-to TEXT Query range to (default: now)
--tail Show the last n lines for the query
(default)
-d, --dump Print the query result as a csv
--fields TEXT Comma separated fields to be printed in the
csv.
-o, --output TEXT Output logs to file (only tail/dump mode)
-f, --follow Poll the logging server for new logs
matching the query (sets search from to now,
limit to None)
-n, --limit INTEGER Limit the number of results (default: 100)
-a, --latency INTEGER Latency of polling queries (default: 2)
-st, --stream TEXT Stream ID of the stream to query (default:
no stream filter)
-s, --sort TEXT Field used for sorting (default: timestamp)
--asc / --desc Sort ascending / descending
--proxy TEXT Proxy to use for the http/s request
-r, --format-template TEXT Message format template for the log
(default: default format
--no-color Don't show colored logs
-c, --config TEXT Custom config file path
--help Show this message and exit.
Contributing
--------
See `contributing <https://github.com/pantuza/pygray/blob/master/CONTRIBUTING.rst>` document to learn how to contribute with us.
=======
History
=======
0.9.4 (2019-03-15)
------------------
* Session expiration was not handled properly when create-session was set and stored
session Id was expired. It should try to authenticate again. Fixed.
0.9.4 (2019-03-15)
------------------
* Allow the session Id to be stored in the configuration file for subsequent pygray
calls
* Fixed various calls to str's "encode", no longer necessary in Python3
0.9.2 (2019-03-15)
------------------
* Messages were printed as Python3's "bytestrings", not regular strings. Fixed.
0.9.1 (2019-03-15)
------------------
* Fixed crash when follow mode was activated
0.9.0 (2019-03-15)
------------------
* First release on PyPI.
===============================
* Free software: Apache Software License 2.0
PyGray is an open source command line interface for Graylog2.
Instalation
--------
Try:
pip3 install pygray
or you can even install it from a GitHub clone:
git clone https://github.com/globocom/pygray
cd pygray/
pip3 install . -r requirements.txt
Usage
--------
PyGray enables you to make searches using the official Graylog query language. To understand how to make queries
please see the `documentation <http://docs.graylog.org/en/2.1/pages/queries.html>`.
Once you've installed the tool now it's time to run some commands, the following:
> pygray -h mygraylog.server.com -u john.doe -p password -@ "10 minutes ago" "source:my-app-server"
-
> pygray -h mygraylog.server.com -u john.doe -p password "message:200"
-
> pygray -h mygraylog.server.com -u john.doe -p password -f
-
> pygray -h mygraylog.server.com -u john.doe -p password "level:DEBUG"
-
> pygray -h mygraylog.server.com -u john.doe -p password "level:DEBUG" -f
-
> pygray -h mygraylog.server.com -u john.doe -p password "level:DEBUG" -d --fields timestamp,level,message -o dump.csv
-
> pygray -h mygraylog.server.com -u john-doe -p password -@ "2016-11-21 00:00:00" -# "2016-11-21 01:00:00" 'message:blabla'
-
> pygray -e dev -r short
-
> pygray -e dev -r short -st mystreamid
-
> pygray -e dev -r short -st '*'
Configuration
--------
PyGray can reuse some common configurations like address of your Graylog server and your credentials, it will look for a
*~/.pygray.cfg* or a *pygray.cfg* (in your current directory). PyGray will use default environment and format
whenever an environment or format is omitted.
Here is a example for your pygray.cfg file:
[environment:default]
host=mygraylogserver.com
port=443
username=john.doe
[environment:dev]
host=mygraylogserver.dev.com
port=443
proxy=mycompanyproxy.com
username=john.doe
default_stream=57e14cde6fb78216a60d35e8
[format:default]
format={host} {level} {facility} {timestamp} {message}
[format:short]
format=[{timestamp}] {level} {message}
[format:long]
format=time: [{timestamp}] level: {level} msg: {message} tags: {tags}
color=false
Please run the *help* command to more detailed information about all the client features.
Usage: pygray [OPTIONS] [QUERY]
Options:
-v, --version Prints your pygray version
-h, --host TEXT Your graylog node's host
-e, --environment TEXT Label of a preconfigured graylog node
-sq, --saved-query List user saved queries for selection
--port TEXT Your graylog port
--no-tls Not use TLS to connect to Graylog server
-u, --username TEXT Your graylog username
-p, --password TEXT Your graylog password (default: prompt)
-k, --keyring / -nk, --no-keyring
Use keyring to store/retrieve password
-@, --search-from TEXT Query range from
-#, --search-to TEXT Query range to (default: now)
--tail Show the last n lines for the query
(default)
-d, --dump Print the query result as a csv
--fields TEXT Comma separated fields to be printed in the
csv.
-o, --output TEXT Output logs to file (only tail/dump mode)
-f, --follow Poll the logging server for new logs
matching the query (sets search from to now,
limit to None)
-n, --limit INTEGER Limit the number of results (default: 100)
-a, --latency INTEGER Latency of polling queries (default: 2)
-st, --stream TEXT Stream ID of the stream to query (default:
no stream filter)
-s, --sort TEXT Field used for sorting (default: timestamp)
--asc / --desc Sort ascending / descending
--proxy TEXT Proxy to use for the http/s request
-r, --format-template TEXT Message format template for the log
(default: default format
--no-color Don't show colored logs
-c, --config TEXT Custom config file path
--help Show this message and exit.
Contributing
--------
See `contributing <https://github.com/pantuza/pygray/blob/master/CONTRIBUTING.rst>` document to learn how to contribute with us.
=======
History
=======
0.9.4 (2019-03-15)
------------------
* Session expiration was not handled properly when create-session was set and stored
session Id was expired. It should try to authenticate again. Fixed.
0.9.4 (2019-03-15)
------------------
* Allow the session Id to be stored in the configuration file for subsequent pygray
calls
* Fixed various calls to str's "encode", no longer necessary in Python3
0.9.2 (2019-03-15)
------------------
* Messages were printed as Python3's "bytestrings", not regular strings. Fixed.
0.9.1 (2019-03-15)
------------------
* Fixed crash when follow mode was activated
0.9.0 (2019-03-15)
------------------
* First release on PyPI.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pygray-0.9.8.tar.gz
(32.9 kB
view details)
File details
Details for the file pygray-0.9.8.tar.gz
.
File metadata
- Download URL: pygray-0.9.8.tar.gz
- Upload date:
- Size: 32.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5f2b421800f830414c0b75f22b5afeb7f0161f6c3015d1bd1e02e8b2f384f9f |
|
MD5 | ed85c223c22144e5b78663a73a99ef6f |
|
BLAKE2b-256 | 52bf6ba54f2fb59ffc3113446117688459a434fdee096b9cd567077fefcb587a |