使用什么配置来防止任何人访问 Prometheus Web 界面
What configuration to use to prevent anyone from accessing the Prometheus web interface
我正在尝试使用 Prometheus 来监控和可视化多个 Java 服务的性能。效果很好,与 Grafana 一起使用时,视觉概览令人印象深刻。
但我似乎没有找到如何配置 Prometheus 本身以防止其 Web 界面公开可用。 Grafana 开箱即用...
如果我想 运行 云服务器上的所有内容,如果我可以检查 /graph 和 /targets URL 来检查是否一切正常,那就太好了在 Grafana 中创建仪表板。
谁能给我指出正确的文档?
我浏览了这个页面,但没有找到我要找的东西:
https://prometheus.io/docs/prometheus/latest/configuration/configuration/
有关信息,这是我的 docker 撰写:
prometheus:
image: prom/prometheus:v2.21.0
container_name: prometheus
ports:
- 9090:9090
volumes:
- ./prometheus/alerts.yml:/etc/prometheus/alerts.yml
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- /var/app/prometheus-data:/prometheus
command: --web.enable-lifecycle --config.file=/etc/prometheus/prometheus.yml
restart: unless-stopped
grafana:
image: grafana/grafana:latest
container_name: grafana
depends_on:
- prometheus
ports:
- 3000:3000
volumes:
- ./grafana/grafana.ini:/etc/grafana/grafana.ini
- /var/app/grafana/data:/var/lib/grafana
- /var/app/grafana/provisioning:/etc/grafana/provisioning
environment:
- GF_INSTALL_PLUGINS=grafana-clock-panel
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=changeme
restart: unless-stopped
还有我的 prometheus.yml 文件:
# my global config
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).
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
- "/etc/prometheus/alerts.yml"
# Scrape configurations
scrape_configs:
# The job name is added as a label `job=<job_name>` to any time series scraped from this config.
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: [ '127.0.0.1:9090' ]
- job_name: 'java-service-1'
...
Prometheus 没有实现它自己的身份验证|授权。
您最好的方法是保护对所有主机运行所有软件的访问,在这种情况下,对主机运行这些Docker容器和所有目标的访问都是安全的你刮等等
所有云提供商都提供了一些方法,您可以通过这些方法限制对使用其平台创建的资源的访问。您需要熟悉首选平台的机制,并且应该通过向自己证明您能够在部署到这些平台时限制对服务的访问来建立信心。
也许从一个简单的测试网站开始,保护它,然后测试它是否安全。一旦您有信心执行此操作,请部署您的 Prometheus 服务。
请参阅有关 Prometheus 的文档 security
我正在尝试使用 Prometheus 来监控和可视化多个 Java 服务的性能。效果很好,与 Grafana 一起使用时,视觉概览令人印象深刻。
但我似乎没有找到如何配置 Prometheus 本身以防止其 Web 界面公开可用。 Grafana 开箱即用...
如果我想 运行 云服务器上的所有内容,如果我可以检查 /graph 和 /targets URL 来检查是否一切正常,那就太好了在 Grafana 中创建仪表板。
谁能给我指出正确的文档? 我浏览了这个页面,但没有找到我要找的东西: https://prometheus.io/docs/prometheus/latest/configuration/configuration/
有关信息,这是我的 docker 撰写:
prometheus:
image: prom/prometheus:v2.21.0
container_name: prometheus
ports:
- 9090:9090
volumes:
- ./prometheus/alerts.yml:/etc/prometheus/alerts.yml
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- /var/app/prometheus-data:/prometheus
command: --web.enable-lifecycle --config.file=/etc/prometheus/prometheus.yml
restart: unless-stopped
grafana:
image: grafana/grafana:latest
container_name: grafana
depends_on:
- prometheus
ports:
- 3000:3000
volumes:
- ./grafana/grafana.ini:/etc/grafana/grafana.ini
- /var/app/grafana/data:/var/lib/grafana
- /var/app/grafana/provisioning:/etc/grafana/provisioning
environment:
- GF_INSTALL_PLUGINS=grafana-clock-panel
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=changeme
restart: unless-stopped
还有我的 prometheus.yml 文件:
# my global config
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).
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
- "/etc/prometheus/alerts.yml"
# Scrape configurations
scrape_configs:
# The job name is added as a label `job=<job_name>` to any time series scraped from this config.
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: [ '127.0.0.1:9090' ]
- job_name: 'java-service-1'
...
Prometheus 没有实现它自己的身份验证|授权。
您最好的方法是保护对所有主机运行所有软件的访问,在这种情况下,对主机运行这些Docker容器和所有目标的访问都是安全的你刮等等
所有云提供商都提供了一些方法,您可以通过这些方法限制对使用其平台创建的资源的访问。您需要熟悉首选平台的机制,并且应该通过向自己证明您能够在部署到这些平台时限制对服务的访问来建立信心。
也许从一个简单的测试网站开始,保护它,然后测试它是否安全。一旦您有信心执行此操作,请部署您的 Prometheus 服务。
请参阅有关 Prometheus 的文档 security