我想用 tls 和身份验证来保护我的 Alertmanager,这样在我的网络中,并不是每个人都能访问面向公众的端点。我不想使用 nginx 服务器作为代理。 这将是我的普罗米修斯配置:
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- scheme: https
basic_auth:
username: abc
password: ####
tls_config:
ca_file: ca.crt
cert_file: ca.crt
key_file: ca.key
static_configs:
- targets: ['localhost:9093']
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
- "alertRules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
scheme: https
basic_auth:
username: abc
password: ###
tls_config:
ca_file: ca.crt
static_configs:
- targets: ['localhost:9090']
最佳答案
从 0.22 版开始,Alertmanager 支持基本身份验证和 https。检查original documentation查看如何配置它,因为您的配置似乎与那里的描述不符。
有关如何散列密码和测试整个设置的详细信息可以改编自 Prometheus documentation .
更新:我再次查看了您的问题,我想我被标题弄糊涂了。看起来您正在尝试做的是将 Prometheus 配置为与需要基本身份验证的 Alertmanager 一起工作。我在本文开头提供的解决方案是将 Alertmanager 配置为需要基本身份验证。
如果您想将 Prometheus 配置为与需要基本身份验证的 Alertmanager 通信,您的配置似乎是正确的,如 Prometheus documentation 的本节所述.
关于security - 为 Alertmanager 配置 HTTPS 和基本身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67269503/