[英]Working with jenkins prometheus plugin
I have Jenkins in https://jenkins.example.com
.我在
https://jenkins.example.com
有詹金斯。 Plugin working witn 2 env.插件与 2 环境一起工作。 variables:
变量:
PROMETHEUS_ENDPOINT Configures rest endpoint. Defaults to "prometheus" PROMETHEUS_NAMESPACE Configure prometheus metric namespace. Defaults to "default"
I need the metrics to be sent to https://jenkins.example.com/metrics
我需要将指标发送到
https://jenkins.example.com/metrics
What PROMETHEUS_ENDPOINT
and PROMETHEUS_NAMESPACE
values?什么
PROMETHEUS_ENDPOINT
和PROMETHEUS_NAMESPACE
值?
Shortly: You actually don't need to edit this values.简而言之:您实际上不需要编辑这些值。 if you wish so you can configure them on:
如果您愿意,您可以将它们配置为:
Jenkins -> Manage Jenkins -> Configure System -> Promethues (section)
Jenkins -> 管理 Jenkins -> 配置系统 -> Promethues(部分)
In short PROMETHEUS_ENDPOINT
using the GET Http request in order to get the index page of the jenkins metrics - https://<your-jenkins-path>/prometheus
简而言之,
PROMETHEUS_ENDPOINT
使用 GET Http 请求来获取 jenkins 指标的索引页面 - https://<your-jenkins-path>/prometheus
Useful / Golden Tips for using jenkins prometheus plugin:使用 jenkins prometheus 插件的有用/黄金提示:
set parameter Enable authentication for prometheus end-point
to true
and you'll be able to get information about internal processes and jobs running on your jenkins endpoint.将参数
Enable authentication for prometheus end-point
设置为true
,您将能够获取有关在 jenkins 端点上运行的内部进程和作业的信息。
create User account on jenkins dedicated to prometheus monitoring, create a token for authentication.在 jenkins 上创建专门用于 prometheus 监控的用户帐户,创建用于身份验证的令牌。
set screen privileges permissions for viewing jenkins metrics for this user:设置屏幕权限以查看此用户的 jenkins 指标:
For Enabling Metrics permission:对于启用指标权限:
Managing jenkins -> Manage and assign roles -> Manage Roles -> Metrics (set view and health-check to true).
管理 jenkins -> 管理和分配角色 -> 管理角色 -> 指标(将视图和健康检查设置为 true)。
For Assign this permission to specific user: (your prometheus user) -将此权限分配给特定用户:(您的普罗米修斯用户)-
Managing jenkins -> Manage and assign roles -> Assign Roles -> find your user and add screen permission.
管理 jenkins -> 管理和分配角色 -> 分配角色 -> 找到您的用户并添加屏幕权限。
- job_name: 'jenkins' metrics_path: /prometheus scheme: http tls_config: insecure_skip_verify: true static_configs: - targets: ['company.jenkins.com:8080'] basic_auth: username: 'JohnDoe@gmail.com' password: 'abc123'
curl -u user:token jenkinsURL:port/prometheus/
for example:例如:
curl -u JohnDoe@gmail.com:abc123 company.jenkins.com:8080/prometheus/
http://yourPrometheusURL.com:9090/targets
and make sure your endpoint is up.http://yourPrometheusURL.com:9090/targets
并确保您的端点已启动。 you should get the metrics and start using it.PROMETHEUS_ENDPOINT
- Configures the path. PROMETHEUS_ENDPOINT
- 配置路径。 Defaults to prometheus
thus your metrics will be accessible at the URI /prometheus/
.默认为
prometheus
因此您的指标可以在 URI /prometheus/
。
What you want is to configure PROMETHEUS_ENDPOINT
to metrics
.您想要的是将
PROMETHEUS_ENDPOINT
配置为metrics
。 You will still have to add to prometheux.xml
the variable metrics_path
and set it to /metrics/
您仍然需要向
prometheux.xml
添加变量metrics_path
并将其设置为/metrics/
PROMETHEUS_NAMESPACE
- puts a prefix to each metric. PROMETHEUS_NAMESPACE
- 为每个指标添加前缀。
http://jenkins.example.com/metrics change it http://jenkins.example.com/prometheus http://jenkins.example.com/metrics改变它http://jenkins.example.com/prometheus
by using prometheus.yml通过使用 prometheus.yml
change prometheus.yml file更改 prometheus.yml 文件
job_name: Jenkins scrape_interval: 5s metrics_path: '/prometheus' scheme: http.
job_name: Jenkins scrape_interval: 5s metrics_path: '/prometheus' 方案:http。 tls_config:
tls_config:
insecure_skip_verify: true static_configs: - targets: ['jenkins.example.com:8080']insecure_skip_verify: true static_configs: - 目标: ['jenkins.example.com:8080']
For me it works belowin prometheus.xml file对我来说,它在 prometheus.xml 文件下面工作
job_name: 'jenkins'工作名称:'詹金斯'
metrics_path: '/jenkins/prometheus'指标路径:'/詹金斯/普罗米修斯'
scheme: http方案:http
static_configs:静态配置:
basic_auth:基本身份验证:
username: 'xxxxxx'用户名:'xxxxxx'
password: 'xxxxxxxxxxxxxxxxxxxx'密码:'xxxxxxxxxxxxxxxxxxxxx'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.