README
LogMoon
LogMoon is real-time HTTP log monitoring CLI. It will display access stats in a determined frequency and alert you if a chosen access limit is reached in 2 minutes.
Installation
You can install LogMoon as a global NPM package by running
npm i -g logmoon
Or by cloning this repository and running
npm install
LogMoon will be installed and will be available globally in your terminal.
Configuration
LogMoon has 4 configurations that can be changed via environment variables (instructions: Windows | Unix) or via the creation of a .env
file based on the .env.example
:
STATS_DISPLAY_INTERVAL
(seconds)
1. The interval to display access information (TODO).
Default value is 10. (Access information is displayed every 10 seconds);
REQUESTS_PER_SECOND_ALARM
(requests per second)
2. The number of requests per second threshold witch will display an alert when reached.
Default value is 10. (Alert is displayed if 10 or more requests per second are made in the past
LOGMOON_ALARM_PERIOD
seconds).
LOGMOON_ALARM_PERIOD
(seconds period)
3. The period where the alarm of requests per second will be tested and active.
Default value is 120. (Alert is displayed if
REQUESTS_PER_SECOND_ALARM
or more requests per second are made in the past 2 minutes).
LOG_FILE
(file location)
3. The location of the W3C-formatted HTTP access log.
Default value is /tmp/access.log. (The location from where the log file will be consumed in real-time).
LOGMOON_OUTPUT_LOCATION
(file location)
4. The location of the output file. If empty, or not present, LogMoon will not log to file, only to the terminal window
Usage
In order to use LogMoon, you can execute the following on the terminal:
logmoon
Or, if you cloned the repo, run
npm start
LogMoon should start running and displaying the information from your server log file.
Development
To install locally and be able to contribute, clone this repo and save a copy of .env.example
as .env
.
To execute the application:
npm start
To run the tests:
npm test
To generate the documentation:
npm run doc
Future improvements
- Find a less memory consuming solution for the alarm (maybe based on the average requests instead of an array)
- Make the
REQUESTS_PER_SECOND_ALARM
variable according to the log frequency - Display an alert in a permanent position in the screen
- Create other alerts, for instance for any status 50x or a certain amount of status 40x in a period of time
- Handle several logs
- Create a browser output
- Create an Electron app
- Sending push notifications (PushMe solution, for instance)