Puppet 报告日志
每次 Puppet 在运行时应用目录时,都会生成一份关于其操作和您的基础设施的报告。Site24x7 AppLogs 内置支持 Puppet 报告日志。
入门
1. 登录您的 Site24x7 账户。
2. 下载并安装 Site24x7 服务器监控代理(Windows | Linux)。
3. 前往管理 > AppLogs > 日志配置文件,然后选择添加日志配置文件。
4. 输入配置文件名称。
5. 从选择日志类型下拉菜单中,选择 Puppet 报告日志。
- 下方将显示示例日志和日志模式。
示例日志:
{"host": "ip-172-31-13-154.us-east-2.compute.internal","time": "2021-07-28T15:01:38.026099904+00:00","configuration_version": 1627484498,"transaction_uuid": "6775bf60-a3ae-4b80-a15e-c8e602af16da","report_format": 10,"puppet_version": "5.5.10","message": "Using configured environment 'production'","status": "changed","transaction_completed": true,"noop": false,"noop_pending": false,"environment": "production","level": "info","source": "Puppet","catalog_application": 0.01703704400006245,"title": "/tmp/it_works.txt","file": "/etc/puppet/code/environments/production/manifests/site.pp","line": 1,"resource": "File[/tmp/it_works.txt]","resource_type": "File","provider_used": "posix","containment_path": ["Stage[main]","Main","File[/tmp/it_works.txt]"],"evaluation_time": 0.004674063,"failed": false,"failed_to_restart": false,"changed": true,"out_of_sync": true,"skipped": false,"change_count": 1,"out_of_sync_count": 1,"events": [{"audited": false,"property": "ensure","previous_value": "absent","desired_value": "present","historical_value": null,"message": "defined content as '{md5}b7765335cba924c39fe20334d017677d'","name": "file_created","status": "success","time": "2021-07-28T15:01:38.503277773+00:00","redacted": null,"corrective_change": true}],"corrective_change": true}
这些日志被拆分为多个字段,每个字段获取各自的值,然后上传至 Site24x7。 - 以下是 AppLogs 为 Puppet 报告日志默认识别的日志模式:
$host as Host$ $time:date:yyyy-MM-dd'T'HH:mm:ss.SX$ $configuration_version as ConfigVersion$ $transaction_uuid as TransUUID$ $report_format as ReportFormat$ $puppet_version as PuppetVersion$ $status as Status$ $environment as Environment$ $level as LogLevel$ $source as PuppetSource$ $catalog_application as CatalogApplication:decimal$ $title as Title$ $file as File$ $line as Line$ $resource as Resource$ $resource_type as ResourceType$ $provider_used$ $containment_path$ $evaluation_time as EvaluationTime:decimal$ $failed as Failed$ $failed_to_restart$ $changed$ $out_of_sync as OutOfSync$ $skipped$ $change_count$ $out_of_sync_count$ $events$ $corrective_change$ $message$ - 您可以添加自定义日志模式替代默认模式。为此,请点击铅笔图标并指定您的模式。

6. 从日志来源下拉菜单中,选择本地文件。
7. 默认情况下,以下路径用作文件来源:
Linux:"/opt/puppetlabs/server/data/puppetserver/reports/*.yaml"、"/var/log/puppetlabs/puppetserver/reports/*.yaml"
- 默认情况下,Puppet 以 YAML 格式写入报告。Site24x7 AppLogs 代理会将这些条目转换为 JSON 格式并上传。
- 如果您的来源路径与默认路径不同,请在"要搜索日志的文件列表"字段中指定。
8. 选择监视器或监视器组来收集日志。

9. 点击保存。
仪表板
AppLogs 为每种日志类型创建专属仪表板,并默认显示一些小部件。以下是 Puppet 报告日志仪表板上可用的小部件列表:
- 总请求数
- 跳过的资源
- 不同步的资源
- 已变更资源
- 失败资源
- 平均目录应用时间
- 按环境统计的活动
- Top 节点
- 日志级别
- Puppet 版本
- Top 错误节点
- Top 告警节点
- 错误率
- Top 错误
- 告警原因
- 告警率
- 资源状态
- 按目录应用时间排名的最慢节点

