-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1340 from Jaseci-Labs/logger
[LOGGER]: Initial Jac-Cloud logger handler
- Loading branch information
Showing
13 changed files
with
460 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,3 +51,7 @@ out.txt | |
# Mypy files # | ||
.mypy_cache* | ||
.jac_mypy_cache | ||
|
||
|
||
# Jac-Cloud # | ||
logs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Logging | ||
* jac-cloud server logs incoming requests and outgoing responses by default to log files stored in `/tmp/` directory | ||
* The log files are on a daily rotation. Meaning there will be a new log file created every day to prevent log files gets too large. | ||
* For production usage, we recommend connect your jac-cloud logs to an Elastic instance. | ||
# Quick Start: Integration with Elasitc | ||
* Assuming you have a running Elastic instance, you just need to use filebeat to ingest the log files into elastic. | ||
* We provide a template filebeat config file to get started at `scripts/filebeat-template.yaml`. If you want to adopt the default configuration, simply change the `hosts` and `api_key` field. | ||
* Change the hosts field to point to your elastic instance. | ||
|
||
> :warning: It seems that filebeat automatically append a 9200 port to the host URL if no port is specified. If your elastic instance is behind a load balancer and simply has a URL without a custom port, you will need to add either :80 or :443 to the hosts config. For example, `hosts: ["https://my_elastic_instance.me.com:443/]` | ||
* Then simply run `filebeat -e -c scripts/filebeat-template.yaml`. | ||
|
||
## More Details on Configuring and Starting Filebeat | ||
- [Download](https://www.elastic.co/downloads/beats/filebeat) and install filebeat. | ||
- setup yml based on your setup | ||
```yml | ||
filebeat.inputs: | ||
- type: log | ||
enabled: true | ||
paths: | ||
- /tmp/jac_cloud_logs/*-jac-cloud-*.log | ||
- /tmp/jac_cloud_logs/jac-cloud.log | ||
json: | ||
keys_under_root: true | ||
overwrite_keys: true | ||
add_error_key: true | ||
expand_keys: true | ||
|
||
output.elasticsearch: | ||
hosts: ["localhost:9200"] | ||
protocol: https | ||
api_key: "id:api_key" | ||
index: "filebeat-testing" | ||
|
||
setup.template.name: "filebeat" | ||
setup.template.pattern: "filebeat-*" | ||
``` | ||
- to run without restriction, run filebeat as root | ||
- `sudo cp filebeat.yml /etc/filebeat/filebeat.yml` | ||
- `sudo filebeat -e` | ||
- normal run | ||
- `filebeat -e -c filebeat.yml` | ||
- for complete documentation | ||
- https://www.elastic.co/guide/en/cloud/current/ec-getting-started-search-use-cases-python-logs.html | ||
- https://www.elastic.co/guide/en/beats/filebeat/current/configuring-howto-filebeat.html | ||
|
||
## Additional Env Vars to customize logger | ||
| **NAME** | **DESCRIPTION** | **DEFAULT** | | ||
|-----------|-------------------|---------------| | ||
| LOGGER_NAME | Specified logger name | app | | ||
| LOGGER_LEVEL | Control log level | debug | | ||
| LOGGER_FILE_PATH | Log directory and name | /tmp/jac_cloud_logs/jac-cloud.log | | ||
| LOGGER_ROLLOVER_INTERVAL | M = every minute, H = hourly, D = daily, W = weekly | D | | ||
| LOGGER_MAX_BACKUP | Maximum number of backup files before it will deletes old file. Non positive value will not have maximum | -1 | | ||
| LOGGER_ROLLOVER_MAX_FILE_SIZE | Maximum file size in bytes before it will rollover to new file | 10000000 | | ||
| LOGGER_USE_UTC | If logger will use UTC | false | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.