# Prometheus-rules **Repository Path**: olinux/prometheus-rules ## Basic Information - **Project Name**: Prometheus-rules - **Description**: 扩展告警规则 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 1 - **Created**: 2021-03-09 - **Last Updated**: 2021-12-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Introduction 放置 Prometheus rules # 规范 ## 目录命名 每层级目录请已`exporter`名称命名,方便区分. 对于应用的`metrics`接口,请已应用名称命名. ## 文件命名 每个json文件请已功能分类命名, 如:`disk`, `network`,`general` 库文件请已`*.libsonnet`结尾 ## Prometheus rules规范 - `alert`:简明扼要的提示性信息, 精炼为主, 不要过长. - `annotations`: - `message`: 告警详情信息, 一般为告警邮件的主题内容 - `summary`: 告警的总结性信息 - `runbook`:指导手册, 出现告警后如何解决,此为内部链接 - `expr`: 触发告警的表达式 - `for`: 出发后多久发送告警信息 - `labels`: 额外标签 - `severity`: 告警等级 - `critical`: 严重的 - `warning`: 警告 - `info`: 提醒 1. 表达式中,使用标签选择器时,除特殊基本不变动的内容,其余情况一律将变量定义在 `config.libsonnet`中 ``` { // 低于3% Inode挂载目录 alert: 'NodeFilesystemAlmostOutOfFiles', annotations: { message: '{{ $labels.instance }} 下挂载目录 {{ $labels.device }} 只剩下 {{ printf "%.2f" $value }}% 可用 inode 节点', summary: 'Filesystem has less than 3% inodes left.', runbook: $._config.runbook, }, expr: ||| ||| % $._config, 'for': '1h', labels: { severity: 'critical', }, }, ``` ## 注释 1. `config`配置中, 请对配置项进行说明 # 使用 ## 安装jsonnet和gojsontoyaml工具 ``` wget https://github.com/google/go-jsonnet/releases/download/v0.17.0/go-jsonnet_0.17.0_Linux_x86_64.tar.gz tar zxf go-jsonnet_0.17.0_Linux_x86_64.tar.gz go get github.com/brancz/gojsontoyaml ``` 默认在/bin/目录下已经有编译好的工具 ## 生成配置 - 运行 ``` bash build.sh ```