0x0i.prometheus
Ansible角色:🔥📐Prometheus
目录
Ansible角色用于安装和配置Prometheus:一个多维、非分布式的时间序列数据库及监控/告警工具包。
支持的平台:
* Debian
* Redhat(CentOS/Fedora)
* Ubuntu
要求
需要在目标主机上安装unzip/gtar
工具。请查看ansible unarchive
模块 说明 了解详细信息。
角色变量
变量可用,并按照以下软件和机器配置阶段进行组织:
- 安装
- 配置
- 启动
- 卸载
安装
prometheus
及其关联的alertmanager
可以使用压缩文件(.tar
, .zip
)进行安装,这些文件从多个来源下载和解压。
以下变量可自定义,以控制此安装过程的各个方面,从软件版本和二进制文件源位置到存储它们的安装目录:
managed_services: <list-of-services (prometheus | alertmanager)>
(默认: *['prometheus']*)
- 通过此角色管理的Prometheus工具包服务列表
prometheus_user: <service-user-name>
(默认: prometheus)
prometheus
用于权限分离的专用服务用户和组(具体说明请参见这里)
install_dir: </path/to/installation/dir>
(默认: /opt/prometheus
)
- 在目标主机上提取
prometheus
二进制文件的路径
archive_url: <path-or-url-to-archive>
(默认: 请参见defaults/main.yml
)
- 包含
prometheus
二进制文件的压缩tar或zip归档的地址。此方法技术上支持安装任何可用版本的prometheus
,官方版本的链接可以在这里找到。
archive_checksum: <path-or-url-to-checksum>
(默认: 请参见defaults/main.yml
)
- 用于验证指定
prometheus
归档数据完整性的校验和文件地址。虽然建议并且通常认为是最佳实践,但指定校验和不是必需的,可以通过提供空字符串(''
)来禁用其值。
checksum_format: <string>
(默认: 请参见sha256
)
- 用于与指定归档校验和相关联的文件验证的哈希算法。有关校验和/加密哈希的更多信息,请参见这里。
alertmgr_installdir: </path/to/installation/dir>
(默认: /opt/alertmanager
)
- 在目标主机上提取
alertmanager
二进制文件的路径
exporter_installdir: </path/to/installation/dir>
(默认: {{ install_dir }}/exporters
)
- 在目标主机上提取Prometheus导出器二进制文件的路径
alertmgr_archive_url: <path-or-url-to-archive>
(默认: 请参见defaults/main.yml
)
- 包含
alertmanager
二进制文件的压缩tar或zip归档的地址。此方法技术上支持安装任何可用版本的alertmanager
,官方版本的链接可以在这里找到。
alertmgr_archive_checksum: <path-or-url-to-checksum>
(默认: 请参见defaults/main.yml
)
- 用于验证指定
alertmanager
归档数据完整性的校验和文件地址。虽然建议并且通常认为是最佳实践,但指定校验和不是必需的,可以通过提供空字符串(''
)来禁用其值。
alertmgr_checksum_format: <string>
(默认: 请参见sha256
)
- 用于与指定归档校验和相关联的文件验证的哈希算法。有关校验和/加密哈希的更多信息,请参见这里。
filesd_path: </path/to/file-sd-files>
(默认: {{ install_dir }}/filesd
)
- Prometheus文件发现文件默认存储在目标主机上的路径
rules_path: </path/to/rule-files>
(默认: {{ install_dir }}/rules.d
)
- Prometheus规则文件默认存储在目标主机上的路径
templates_path: </path/to/alertmanager-template-files>
(默认: {{ alertmgr_installdir }}/templates
)
- Alertmanager模板文件默认存储在目标主机上的路径
配置
使用此角色,prometheus
安装的配置按照以下组件组织:
- prometheus服务配置(
prometheus.yml
) - 文件服务发现(
file_sd - *.[json|yml]
) - 记录和告警规则(
rule_files - *.[json|yml]
) - alertmanager服务配置(
alertmanager.yml
) - alertmanager模板文件(
*.tmpl
)
每个配置都可以通过以下变量来表示,以自定义指定配置文件的内容和设置:
config_dir: </path/to/configuration/dir>
(默认: {{ install_dir }}
)
- 在目标主机上,
prometheus
配置文件应该被渲染的路径
data_dir: </path/to/data/dir>
(默认: /var/data/prometheus
)
- 在目标主机上,
prometheus
存储数据的路径
alertmgr_configdir: </path/to/configuration/dir>
(默认: {{ alertmgr_installdir }}
)
- 在目标主机上,
alertmanager
配置文件应该被渲染的路径
alertmgr_datadir: </path/to/data/dir>
(默认: /var/data/alertmanager
)
- 在目标主机上,
alertmanager
存储数据的路径
Prometheus服务配置
Prometheus服务配置可以通过哈希prometheus_config
表示,该哈希包含一组键值对,表示不同的抓取目标(从中收集度量)的部分,服务发现机制,记录/警报规则以及与Prometheus服务使用的远程读写系统的接口配置。
这些键的值通常是字典或字典列表,包含一组键值对,表示与每个部分相关的规格/设置(例如,抓取间隔或全局抓取目标的频率)。以下提供了每个部分的概述和示例配置以供参考。
:global
[prometheus_config:] global: <key: value,...>
(默认: 请参见defaults/main.yml
)
- 指定所有其他配置上下文中有效并作为默认值的参数。有关更多详细信息,请查看这里。
示例
prometheus_config:
global:
# 默认的抓取目标频率。
scrape_interval: 15s
# 抓取请求超时的时间。
scrape_timeout: 30s
# 评估规则的频率。
evaluation_interval: 30s
# 与外部系统(联邦、远程存储、Alertmanager)通信时要添加的标签。
external_labels:
monitor: example
foo: bar
:scrape_configs
[prometheus_config:] scrape_configs: <list-of-dicts>
(默认: 请参见defaults/main.yml
)
- 指定一组目标和描述如何抓取它们的参数,组织成作业
目标可以静态配置,也可以使用支持的服务发现机制动态发现。有关更多详细信息,请查看这里和这里获取支持的服务发现方法列表。
示例
prometheus_config:
scrape_configs:
- job_name: static-example
static_configs:
- targets: ['localhost:9090', 'localhost:9191']
labels:
example: label
- job_name: kubernetes-example
kubernetes_sd_configs:
- role: endpoints
api_server: 'https://localhost:1234'
namespaces:
names:
- default
:rule_files
[prometheus_config:] rule_files: <list>
(默认: 请参见defaults/main.yml
)
- 指定一组表示文件名和路径的模式
会从所有匹配的文件中读取规则。规则分为两类:记录和告警。有关记录规则的详细信息,请访问这里,有关告警规则的详细信息,请访问这里。
示例
prometheus_config:
rule_files:
- "example.yml"
- "example_rules/*"
:remote_read
[prometheus_config:] remote_read: <list-of-dicts>
(默认: 请参见defaults/main.yml
)
- 指定与远程读取功能相关的设置
有关更多详细信息,请查看这里。有关可用的远程读取/存储插件/集成的列表,请参考此链接。
示例
prometheus_config:
remote_read:
- url: http://remote1/read
read_recent: true
name: default
- url: http://remote2/read
read_recent: false
name: read_special
required_matchers:
job: special
tls_config:
cert_file: valid_cert_file
key_file: valid_key_file
:remote_write
[prometheus_config:] remote_write: <list-of-dicts>
(默认: 请参见defaults/main.yml
)
- 指定与远程写入功能相关的设置
有关更多详细信息,请查看这里。有关可用的远程写入/存储插件/集成的列表,请参考此链接。
示例
prometheus_config:
remote_write:
- name: drop_expensive
url: http://remote1/push
write_relabel_configs:
- source_labels: [__name__]
regex: expensive.*
action: drop
- name: rw_tls
url: http://remote2/push
tls_config:
cert_file: valid_cert_file
key_file: valid_key_file
:alerting
[prometheus_config:] alerting: <key: value,...>
(默认: 请参见defaults/main.yml
)
- 指定与Alertmanager相关的设置,以及Prometheus服务器将警报发送到的Alertmanager实例
此部分提供配置与这些Alertmanager进行通信的参数。Alertmanager可以通过静态配置参数静态配置,也可以使用支持的服务发现机制动态发现。有关更多详细信息,请查看这里。
示例
prometheus_config:
alerting:
alertmanagers:
- scheme: https
static_configs:
- targets:
- "1.2.3.4:9093"
- "1.2.3.5:9093"
文件服务发现
基于文件的服务发现提供了一种更通用的方式来配置静态目标,并作为插入自定义服务发现机制的接口。它读取包含零个或多个<static_config>
的文件集。所有定义文件的更改通过磁盘监视检测并立即应用。文件可以以YAML或JSON格式提供。仅应用导致有效目标组的更改。有关更多详细信息,请查看这里。
prometheus_file_sd: <list-of-dicts>
(默认: [])
- 指定要呈现的prometheus file_sd配置
使用此角色,基于文件的服务发现配置设置可以通过哈希prometheus_file_sd
表示,该哈希包含一组字典,封装了要被prometheus加载以进行基于文件的发现的yaml
或json
文件的路径、名称和配置内容。
[prometheus_file_sd : <entry>:] name: <string>
(默认: NONE - 必需)
- 要呈现的file_sd文件的名称
[prometheus_file_sd : <entry>:] path: <string>
(默认: {{ install_dir }}/file_sd
)
- 要呈现的file_sd文件的路径
[prometheus_file_sd : <entry>:] config: <list-of-dicts>
(默认: NONE - 必需)
- 代表设置的一系列字典,指示在file_sd文件中指定的静态目标集合
示例
prometheus_file_sd:
- name: example-file.slow.json
config:
- targets: ["host1:1234"]
labels:
test-label: example-slow-file-sd
- name: file.yml
path: /etc/prometheus/file_sd
config:
- targets: ["host2:1234"]
注意: 预期在prometheus.yml
文件中包含一个相关的file_sd
服务发现抓取配置,以便成功加载。
规则文件
Prometheus支持两种类型的规则,这些规则可以配置并定期评估:记录规则和告警规则。记录规则允许您预先计算频繁需要或计算开销大的表达式,并将其结果保存为一组新的时间序列。告警规则允许您基于Prometheus表达式语言定义警报条件,并将有关触发警报的通知发送到外部服务。有关更多详细信息,请查看这里。
prometheus_rule_files: <list-of-dicts>
(默认: [])
- 指定要呈现的prometheus规则文件
使用此角色,记录和告警规则可以在哈希prometheus_rule_files
中表示,该哈希包含一组字典,封装了要被prometheus加载的yaml
或json
文件的路径、名称和配置内容。
[prometheus_rule_files : <entry>:] name: <string>
(默认: NONE - 必需)
- 要呈现的规则文件名称
[prometheus_rule_files : <entry>:] path: <string>
(默认: {{ install_dir }}/rules.d
)
- 要呈现的规则文件路径
[prometheus_rule_files : <entry>:] config: <list-of-dicts>
(默认: NONE - 必需)
- 代表设置的一系列字典,指示在规则文件中指定的规则组集合
示例
prometheus_rule_files:
- name: example-rules.yml
config:
groups:
- name: recording rule example
rules:
- record: job:http_inprogress_requests:sum
expr: sum(http_inprogress_requests) by (job)
- name: nondefault-path-example-rules.yml
path: /etc/prometheus/rules.d
config:
groups:
- name: alerting rule example
rules:
- alert: HighRequestLatency
expr: job:request_latency_seconds:mean5m{job="myjob"} > 0.5
for: 10m
labels:
severity: page
annotations:
summary: High request latency
注意: 预期在prometheus.yml
文件中包含一个相关的rule_files
部分,以便成功加载。
Alertmanager服务配置
Alertmanager服务配置可以通过哈希alertmanager_config
表示,该哈希包含一组键值对,表示不同路由、接收器、模板和告警抑制配置的部分。
这些键的值通常是字典或字典列表,包含一组键值对,表示与每个部分相关的规格/设置(例如,用于Slack通知的API URL)。以下提供了每个部分的概述和示例配置以供参考。
:global
[alertmanager_config:] global: <key: value,...>
(默认: 请参见defaults/main.yml
)
- 指定所有其他配置上下文中有效并作为默认值的参数。有关更多详细信息,请查看这里。
示例
alertmanager_config:
global:
# 用于邮件通知的智能主机和SMTP发送者。
smtp_smarthost: 'localhost:25'
smtp_from: '[email protected]'
smtp_auth_username: 'alertmanager'
smtp_auth_password: 'password'
# Hipchat的身份验证令牌。
hipchat_auth_token: '1234556789'
# Hipchat的备用主机。
hipchat_api_url: 'https://hipchat.foobar.org/'
:route
[alertmanager_config:] route: <key: value,...>
(默认: 请参见defaults/main.yml
)
- 定义路由树中的节点及其子节点
每个警报都在配置的顶层路由处进入路由树,该路由必须匹配所有警报(即没有配置匹配器)。然后遍历子节点。如果continue设置为false,则在第一个匹配的子节点后停止。如果在匹配节点上设置为true,则该警报将继续与后续的兄弟节点匹配。有关更多详细信息,请查看这里。
示例
alertmanager_config:
route:
receiver: 'default-receiver'
group_wait: 30s
group_interval: 5m
repeat_interval: 4h
group_by: [cluster, alertname]
# 所有不匹配以下子路由的告警将保持在根节点上并被调度到'default-receiver'。
routes:
# 所有服务=mysql或服务=cassandra的告警将被调度到数据库传递器。
- receiver: 'database-pager'
group_wait: 10s
match_re:
service: mysql|cassandra
# 所有带有team=frontend标签的告警匹配该子路由。
# 它们按产品和环境进行分组,而不是按集群和警报名称。
- receiver: 'frontend-pager'
group_by: [product, environment]
match:
team: frontend
:receivers
[alertmanager_config:] inhibit_rules: <list-of-dicts>
(默认: 请参见defaults/main.yml
)
- 指定通知接收器的列表
接收器是一个或多个通知集成的命名配置。有关更多详细信息,请查看这里。
示例
alertmanager_config:
receivers:
- name: 'team-X-mails'
email_configs:
- to: '[email protected]'
pagerduty_configs:
- service_key: <team-X-key>
hipchat_configs:
- auth_token: <auth_token>
room_id: 85
message_format: html
notify: true
:inhibit_rules
[alertmanager_config:] inhibit_rules: <list-of-dicts>
(默认: 请参见defaults/main.yml
)
- 指定抑制规则的列表
抑制规则在存在匹配另一组匹配器的警报(源)时,静音匹配一组匹配器的警报(目标)。有关更多详细信息,请查看这里。
示例
alertmanager_config:
inhibit_rules:
- source_match:
severity: 'critical'
target_match:
severity: 'warning'
# 如果警报名称相同,则应用抑制。
equal: ['alertname', 'cluster', 'service']
:templates
[alertmanager_config:] templates: <list>
(默认: 请参见defaults/main.yml
)
- 指定用于读取通知模板的文件和目录
最后一个组件可以使用通配符匹配,例如templates/*.tmpl
。有关通知模板参考,请查看这里以及此链接中的示例。
示例
alertmanager_config:
templates:
- '/etc/alertmanager/template/*.tmpl'
Alertmanager模板
Prometheus创建并将警报发送到Alertmanager,Alertmanager随后根据其标签将通知发送到不同的接收器。发送给接收器的通知是通过模板构建的。Alertmanager附带默认模板,但也可以自定义。有关更多详细信息,请查看这里。
altermanager_templates: <list-of-dicts>
(默认: [])
- 指定要呈现的
alertmanager
通知模板配置
使用此角色,alertmanager模板配置设置可以在哈希alertmanager_templates
中表示,该哈希包含一组字典,表示并封装要被alertmanager加载的模板文件的路径、名称和配置内容。
[alertmanager_templates : <entry>:] name: <string>
(默认: NONE - 必需)
- 要呈现的模板文件名称
[alertmanager_templates : <entry>:] path: <string>
(默认: {{ alertmgr_installdir }}/templates
)
- 要呈现的模板文件路径
[alertmanager_templates : <entry>:] config: <list-of-dicts>
(默认: NONE - 必需)
- 代表设置的一系列字典,指示要呈现的模板配置集合
示例
alertmanager_templates:
- name: test
config:
- define: "myorg.test.guide"
template: 'https://internal.myorg.net/wiki/alerts/\{\{ .GroupLabels.app \}\}/\{\{ .GroupLabels.alertname \}\}'
- name: test2
path: /etc/alertmanager/templates
config:
- define: "myorg.test.text"
template: 'summary: \{\{ .CommonAnnotations.summary \}\}\ndescription: \{\{ .CommonAnnotations.description \}\}'
注意: 预期在alertmanager.yml
文件中包含一个相关的templates
配置部分,以便成功加载。
启动
此角色支持启动Prometheus监控和告警工具包生态系统的所有组件。包括Prometheus和Alertmanager服务以及大量的度量导出器。运行每个服务是通过使用systemd服务管理工具完成的,该工具作为后端进程或守护进程来管理服务,受其底层管理框架提供的配置和执行潜力的影响。
以下变量可自定义,以管理服务的systemd [Service]单元定义和执行配置/策略:
Prometheus
extra_run_args: <prometheus-cli-options>
(默认: []
)
- 要在运行时传递给二进制文件的
prometheus
命令行参数列表,以自定义启动。
支持prometheus
的cli的完整表达,该变量使启动可以根据用户的规格自定义。
custom_unit_properties: <hash-of-systemd-service-settings>
(默认: []
)
- 用于自定义Prometheus systemd服务的
[Service]
单元配置和执行环境的哈希设置。
Alertmanager
extra_alertmgr_args: <alertmanager-cli-options>
(默认: []
)
- 要在运行时传递给二进制文件的
alertmanager
命令行参数列表,以自定义启动。
支持alertmanager
的cli的完整表达,该变量使启动可以根据用户的规格自定义。
custom_alertmgr_properties: <hash-of-systemd-service-settings>
(默认: []
)
- 用于自定义Alertmanager systemd服务的
[Service]
单元配置和执行环境的哈希设置。
导出器
prometheus_exporters: <list-of-dicts>
(默认: [])
- 指定要安装、启动和作为systemd服务管理的prometheus导出器。
每个导出器字典条目预期指示多个属性,包括名称;url和监听地址,以便正确设置和与Prometheus服务器通信。还可以通过extra_args
变量指定其他用于自定义导出器操作的属性,该属性将提供的命令行参数附加到导出器的单元ExecStart设置中。有关更多详细信息和导出器插件的列表,请查看这里。
[prometheus_exporters : <entry>:] name: <string>
(默认: NONE - 必需)
- 要安装的Prometheus导出器的名称
[prometheus_exporters : <entry>:] url: <string>
(默认: NONE - 必需)
- 要安装的Prometheus导出器的URL
[prometheus_exporters : <entry>:] description: <string>
(默认: <exporter-name>
)
- 要包含在导出器的Systemd单元文件中的Prometheus导出器的描述或文档
[prometheus_exporters : <entry>:] unit_properties: <hash>
(默认: {}
)
- 用于自定义*
* systemd服务的 [Service]
单元配置和执行环境的哈希设置
示例
prometheus_exporters:
- name: node_exporter
url: https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
description: https://github.com/prometheus/node_exporter
unit_properties:
User: exporter
Group: exporter
extra_args:
- '--web.listen-address=0.0.0.0:9110'
- '--log.level=debug'
卸载
支持卸载和删除应用此角色所需的工件,允许用户/操作员将目标主机返回到应用此角色之前的配置状态。这对于回收节点和角色提供更优雅/管理的过渡可能是有用的。
以下变量可自定义,以管理此卸载过程:
perform_uninstall: <true | false>
(默认: false
)
- 是否卸载并删除目标主机上所有
prometheus
安装的工件和残余物(参见:handlers/main.yml
以获取详细信息)
依赖
- 0x0i.systemd
示例剧本
默认示例:
- hosts: all
roles:
- role: 0x0I.prometheus
仅仅安装和管理Prometheus服务(禁用alertmanager设置):
- hosts: all
roles:
- role: 0x0I.prometheus
vars:
managed_services: ['prometheus']
安装特定版本的Prometheus:
- hosts: all
roles:
- role: 0x0I.prometheus
vars:
archive_url: https://github.com/prometheus/prometheus/releases/download/v2.15.0/prometheus-2.15.0.linux-amd64.tar.gz
archive_checksum: 1c2175428e7a70297d97a30a04278b86ccd6fc53bf481344936d6573482203b4
调整Prometheus和Alertmanager的安装、配置和数据目录:
- hosts: all
roles:
- role: 0x0I.prometheus
vars:
install_dir: /usr/local
config_dir: /etc/prometheus
data_dir: /var/lib/prometheus
alertmgr_installdir: /usr/local
alertmgr_configdir: /etc/alertmanager
alertmgr_datadir: /var/lib/alertmanager
自定义全局抓取和评估设置:
- hosts: all
roles:
- role: 0x0I.prometheus
vars:
prometheus_config:
global:
scrape_interval: 30s
scrape_timeout: 30s
evaluation_interval: 30s
自定义Prometheus告警/Alertmanager配置:
- hosts: all
roles:
- role: 0x0I.prometheus
vars:
prometheus_config:
alerting:
alertmanagers:
- scheme: https
static_configs:
- targets:
- "1.2.3.4:9093"
创建记录和告警规则:
- hosts: all
roles:
- role: 0x0I.prometheus
vars:
prometheus_config:
rule_files:
- /etc/prometheus/rules.d/*
prometheus_rule_files:
- name: example-rules.yml
path: /etc/prometheus/rules.d/*
config:
groups:
- name: recording rule example
rules:
- record: job:http_inprogress_requests:sum
expr: sum(http_inprogress_requests) by (job)
- name: another-example.yml
path: /etc/prometheus/rules.d
config:
groups:
- name: alerting rule example
rules:
- alert: HighRequestLatency
expr: job:request_latency_seconds:mean5m{job="myjob"} > 0.5
for: 10m
labels:
severity: page
annotations:
summary: High request latency
static
目标抓取配置与抓取和评估设置的覆盖:
- hosts: all
roles:
- role: 0x0I.prometheus
vars:
prometheus_config:
scrape_configs:
- job_name: static-example
static_configs:
- targets: ['localhost:9090', 'localhost:9191']
labels:
my: label
your: label
scrape_interval: 10s
scrape_timeout: 10s
evaluation_interval: 10s
file_sd
基于文件的抓取配置与抓取和评估设置的覆盖:
- hosts: all
roles:
- role: 0x0I.prometheus
vars:
prometheus_config:
scrape_configs:
- job_name: file-sd-example
file_sd_configs:
- files:
- foo/*.slow.json
- single/file.yml
refresh_interval: 10m
- files:
- bar/*.yml
prometheus_file_sd:
- name: example-file.slow.json
path: foo
config:
- targets: ["host1:1234"]
labels:
test-label: example-slow-file-sd
- name: foo.yml
path: bar
config:
- targets: ["host2:1234"]
- name: file.yml
path: single
config:
- targets: ["host3:1234"]
dns
-基于目标的抓取配置:
- hosts: all
roles:
- role: 0x0I.prometheus
vars:
prometheus_config:
scrape_configs:
- job_name: dns-example
dns_sd_configs:
- refresh_interval: 15s
names:
- first.dns.address.domain.com
- second.dns.address.domain.com
- names:
- third.dns.address.domain.com
kubernetes
目标抓取配置,配置了TLS和基本身份验证设置:
- hosts: all
roles:
- role: 0x0I.prometheus
vars:
prometheus_config:
scrape_configs:
- job_name: kubernetes-example
kubernetes_sd_configs:
- role: endpoints
api_server: 'https://localhost:1234'
tls_config:
cert_file: valid_cert_file
key_file: valid_key_file
basic_auth:
username: 'myusername'
password: 'mysecret'
ec2
目标抓取配置:
- hosts: all
roles:
- role: 0x0I.prometheus
vars:
prometheus_config:
scrape_configs:
- job_name: ec2-example
ec2_sd_configs:
- region: us-east-1
access_key: access
secret_key: mysecret
profile: profile
filters:
- name: tag:environment
values:
- prod
- name: tag:service
values:
- web
- db
openstack
目标抓取配置:
- hosts: all
roles:
- role: 0x0I.prometheus
vars:
prometheus_config:
scrape_configs:
- job_name: openstack-example
openstack_sd_configs:
- role: instance
region: RegionOne
port: 80
refresh_interval: 1m
azure
目标抓取配置:
- hosts: all
roles:
- role: 0x0I.prometheus
vars:
prometheus_config:
scrape_configs:
- job_name: azure-example
azure_sd_configs:
- environment: AzurePublicCloud
authentication_method: OAuth
subscription_id: 11AAAA11-A11A-111A-A111-1111A1111A11
tenant_id: BBBB222B-B2B2-2B22-B222-2BB2222BB2B2
client_id: 333333CC-3C33-3333-CCC3-33C3CCCCC33C
client_secret: mysecret
port: 9100
marathon
目标抓取配置:
- hosts: all
roles:
- role: 0x0I.prometheus
vars:
prometheus_config:
scrape_configs:
- job_name: marathon-example
marathon_sd_configs:
- servers:
- 'https://marathon.example.com:443'
auth_token: "mysecret"
consul
目标抓取配置:
- hosts: all
roles:
- role: 0x0I.prometheus
vars:
prometheus_config:
scrape_configs:
- job_name: consul-example
consul_sd_configs:
- server: 'localhost:1234'
token: mysecret
services: ['nginx', 'cache', 'mysql']
tags: ["canary", "v1"]
node_meta:
rack: "123"
allow_stale: true
scheme: https
许可证
MIT
作者信息
此角色由O1.IO于2019年创建。
Prometheus - a multi-dimensional time-series data monitoring and alerting toolkit
ansible-galaxy install 0x0i.prometheus