首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何为prometheus作业添加承载令牌

如何为prometheus作业添加承载令牌
EN

Stack Overflow用户
提问于 2021-06-05 06:57:43
回答 1查看 5.3K关注 0票数 0

我已经开始研究Prometheus的微型服务了。我一开始就做到了。现在,是时候将执行器端点推到spring安全性之下了。在添加安全执行机构之后,期望来自Prometheus的承载令牌。因此,如何在Prometheus作业中配置用户名和密码,以便Prometheus将从登录中获取承载令牌,并将其作为“授权”添加到所有请求的头中。

我使用下面的命令在docker容器中运行Prometheus

代码语言:javascript
复制
 1. $ docker run --name prometheus -p 9090:9090 -v prometheus.yml:/etc/prometheus/prometheus.yml -d prom/prometheus
 2. $ docker run --name grafana -d -p 3000:3000 grafana/grafana

下面是prometheus.yml文件

代码语言:javascript
复制
# 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:
# - "first_rules.yml"
# - "second_rules.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 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: 'NL-APPLICATION'
    metrics_path: '/actuator/prometheus'
    scrape_interval: 5s
    scheme: http
    static_configs:
      - targets: ['172.17.0.1:8085']

  - job_name: 'NL-ADMIN-API'
    metrics_path: '/actuator/prometheus'
    scrape_interval: 5s
    static_configs:
      - targets: ['172.17.0.1:8083']

如何指导普罗米修斯

  1. API调用‘/
  2. ’获取
  3. 令牌,使用用户名和密码
  4. ,在所有执行器API调用

中,将Bearer令牌添加为‘授权’作为头

EN

回答 1

Stack Overflow用户

发布于 2022-04-26 15:51:16

可以指定为文件,也可以将令牌添加到配置中。

代码语言:javascript
复制
- job_name: 'test'
    metrics_path: "/metrics"
    scheme: "http"
    bearer_token_file: /var/run/secrets/    OR   bearer_token: token_here
    static_configs:
- targets: ['host.com']
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67847139

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档