In a nutshell EasyLogs
is a simple, but powerful, dashboard to visualize logs.
EasyLogs is a agnostic dashboard for display and filter logs. It can be used with any log source.
The main idea is to provide a simple and lightweight dashboard to visualize logs that you can use quickly.
- Real-time logs.
- Simple dashboard interface.
- Filter logs by level, date, message, etc.
- Text search in logs messages.
- Log aggregation.
- Mobile-first design.
- PWA support (See images below).
There are a lot of log dashboards out there:
- Kibana
- Graylog
- Splunk
- Logstash
- ...
But most of them are very complex to configure and use. EasyLogs is a simple dashboard that can be used with any log source.
- You want to use a simple dashboard.
- You want to visualize logs in a simple way.
- You want only a basic logs filtering.
- You want a fast deployment and lightweight dashboard.
- You don't need a complex log dashboard.
- You don't want to spend time configuring a log dashboard.
- You don't need analytics of your logs.
EasyLogs is composed by:
- The Web Application, aka, the Dashboard.
- MongoDB database for storing logs.
- Redis database for storing sessions.
So, you need to have both running.
EasyLogs is configured using environment variables. This table shows all the available configuration options:
Variable | Description | Default value |
---|---|---|
REDIS_URI |
Redis Connection string | redis://127.0.0.1:6379/0 |
MONGO_DB |
MongoDB database | easylogs |
MONGO_URI |
MongoDB Connection string | mongodb://root:example@127.0.0.1:27099 |
ADMIN_USER |
Admin user | admin |
ADMIN_PASSWORD |
Admin Password | adminadmin |
RECEIVE_LOGS_KEY |
Key used to authenticate loggers | LIh982y87GgljahsadfklJHLIUG87g1u1e7f6eb2ee145571858e8e24 |
EMBEDED_DB |
If this variable is set, enables MongoDB and Redis embedded databases. Allowed values: TRUE | TRUE |
NOTE: If you want to use MongoDB embedded database, you don't need to set
MONGO_URI
andMONGO_DB
variables.
Currently, EasyLogs only support fixed authentication. In the future, we will add support for other authentication methods.
Easylog has the possibility to run MongoDB and the Web Application in the same container. This is the easiest way to run EasyLogs.
> docker run -e EMBEDED_DB=1 -p 8080:8080 cr0hn/easylogs
NOTE: Not recommended for production environments.
If you want to run EasyLogs in a production environment, you should use an external MongoDB & Redis databases.
> export MONGO_URI=mongodb://...
> export REDIS_URI=redis://...
> docker run -e MONGODB_URI=$MONGODB_URI -e REDIS_URI=$REDIS_URI -p 8080:8080 cr0hn/easylogs
NOTE: If you don't want to deploy and maintain a MongoDB, you can use a MongoDB Atlas cloud database. It's free, simple and fast. NOTE: If you don't want to deploy and maintain a Redis, you can use a Redis Labs cloud database. It's free, simple and fast.
You can use the provided docker-compose.yaml
file to run EasyLogs with an external MongoDB database.
> export MONGO_INITDB_ROOT_USERNAME=root
> export MONGO_INITDB_ROOT_PASSWORD=example
> docker-compose -p easy-logs up -d
NOTE: If you want to expose MongoDB & Redis ports, be sure you add the
ports:
section in thedocker-compose.yaml
file.
Once you have EasyLogs running, you can connect to it using the default credentials (Unless you have changed them):
- User:
admin
- Password:
adminadmin
Then you can connect to the dashboard using the URL: http://localhost:8080
EasyLogs can be used with any log source.
Python has a builtin HTTP Handler log that can be used to send logs to EasyLogs:
"""
This file configures a logger and sent the log to a remote HTTP server.
"""
from urllib.parse import urlparse
import logging
import logging.handlers
def get_log(name: str):
# Get new logger
logging.basicConfig()
logger = logging.getLogger(name)
# Configure logger to send logs to EasyLogs
easy_logs_host = "http://localhost:8080"
easy_logs_path = "/loggers/python/http-handler"
easy_logs_token = "LIh982y87GgljahsadfklJHLIUG87g1u1e7f6eb2ee145571858e8e24"
parsed_url = urlparse(easy_logs_host)
# Create HTTP handler
http_handler = logging.handlers.HTTPHandler(
parsed_url.netloc,
f'{easy_logs_path}?key={easy_logs_token}',
method='POST',
secure=True if parsed_url.scheme == "https" else False
)
logger.addHandler(http_handler)
return logger
logger = get_log("easylogs")
logger.setLevel(logging.DEBUG)
# Send logs
logger.info('This is a test log message')
try:
1 / 0
except Exception as e:
logger.error('Error', exc_info=e, extra={'foo': 'bar'}, stack_info=True)
logger.exception("asdf", e)
WARNING: The default handler doesn't manager connections errors. Bot a better resilient HTTP handler see next point.
This is a fault-tolerant HTTP handler for send logs. If server doesn't responds, keep the logs and try again later.
from urllib.parse import urlparse
import queue
import logging
import logging.handlers
#
# This is the HTTP Handler for a resilient log client
#
class HTTPHandlerResilient(logging.handlers.HTTPHandler):
def __init__(self, host, url, method='GET', secure=True):
super().__init__(host, url, method, secure)
self._queue = queue.Queue()
def emit(self, record):
try:
super().emit(record)
# If not error, try to send any remaining messages
while True:
try:
super().emit(self._queue.get_nowait())
except queue.Empty:
break
except ConnectionError:
self._queue.put(record)
def handleError(self, record):
raise ConnectionError()
def get_log(name: str):
# Get new logger
logging.basicConfig()
logger = logging.getLogger(name)
# Configure logger to send logs to EasyLogs
easy_logs_host = "http://localhost:8080"
easy_logs_path = "/loggers/python/http-handler"
easy_logs_token = "LIh982y87GgljahsadfklJHLIUG87g1u1e7f6eb2ee145571858e8e24"
parsed_url = urlparse(easy_logs_host)
#
# CHANGE THIS: logging.handlers.HTTPHandler -> HTTPHandlerResilient
#
http_handler = HTTPHandlerResilient(
parsed_url.netloc,
f'{easy_logs_path}?key={easy_logs_token}',
method='POST',
secure=True if parsed_url.scheme == "https" else False
)
logger.addHandler(http_handler)
return logger
Contributions are welcome! If you want to implement a new log source, please, open an issue.
Contributions are welcome! If you want to implement a new log source, please, open an issue.
Contributions are welcome! If you want to implement a new log source, please, open an issue.
Contributions are welcome! If you want to implement a new log source, please, open an issue.
Contributions are welcome! If you want to implement a new log source, please, open an issue.
You can contribute to this project in many ways:
- Reporting bugs
- Suggesting new features
- Writing or editing documentation
- Adding new loggers (Python, Go, NodeJS, C#, Ruby, ...)
Thanks for your interest in contributing to EasyLogs!
If you want to add a new logger, please, follow this steps:
- Create a new folder under
examples
folder with the name of the language. - Create a new file with the name of the logger (e.g:
http-handler.go
) - Create a README.md file with the instructions to use the logger.
Have in count that I'll need to reproduce the example to test it and add a new end-point to the API. So I'll need to execute the example.
If you are here, thanks! You are awesome!
If you also know Python and want to add a new end-point to the API, please, follow this steps:
- Copy & paste the
easy_logs/loggers/python
package and rename it to the name of the language. - Adapt the code to the new language following the same structure.
- Improve pagination for long logs
- Add generic endpoint to push logs.
- Add tests
- Add more languages
- Improve authentication system: add API key support, multi-user...
- Add download logs button
- Add filter by date
- Real-time receive los support
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
This dashboard is based on SB Admin2 template.