Logscraper¶
Logscraper 工具可以作为一次性日志抓取运行,也可以作为周期性检查,以查看是否有新的日志作业可用。
该工具具有帮助功能,可以显示其可用选项。可以通过输入以下命令来访问:
logscraper --help
Fetch and push last Zuul CI job logs:
optional arguments:
-h, --help show this help message and exit
--zuul-api-url ZUUL_API_URL
URL(s) for Zuul API. Parameter can be set multiple
times.
--job-name JOB_NAME CI job name(s). Parameter can be set multiple times.
If not set it would scrape every latest builds.
--follow Keep polling zuul builds
--insecure Skip validating SSL cert
--checkpoint-file CHECKPOINT_FILE
File that will keep information about last uuid
timestamp for a job.
--workers WORKERS Worker processes for logscraper
--max-skipped MAX_SKIPPED
How many job results should be checked until last uuid
written in checkpoint file is founded
--debug Print more information
--directory DIRECTORY
Directory, where the logs will be stored. Defaults to:
/tmp/logscraper
基本用法¶
根据使用场景,我们可以运行 logscraper。
示例
将日志下载到 /mnt/logscraper。注意:如果您使用的是容器服务,则需要挂载此目录!
logscraper --zuul-api-url https://zuul.opendev.org/api/tenant/openstack --directory /mnt/logscraper --download
容器化工具¶
您可以构建包含 logscraper 工具的自定义容器镜像,而不是使用 pip 工具,例如:
docker build -t logscraper -f Dockerfile
然后您可以执行上述命令。
注意:如果您想使用参数 –checkpoint-file,则需要将卷挂载到容器中,例如:
docker run -v $(pwd):/checkpoint-dir:z -v /mnt/logscraper:/mnt/logscraper:z -d logscraper logscraper --zuul-api-url https://zuul.opendev.org/api/tenant/openstack --checkpoint-file /checkpoint-dir/checkpoint --directory /mnt/logscraper --download --follow