Vasily
Vasily

Reputation: 71

Working with jenkins prometheus plugin

I have Jenkins in https://jenkins.example.com. Plugin working witn 2 env. 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

What PROMETHEUS_ENDPOINT and PROMETHEUS_NAMESPACE values?

Plugin documentation

Upvotes: 3

Views: 13213

Answers (4)

ASHOK
ASHOK

Reputation: 1

For me it works belowin prometheus.xml file

  • job_name: 'jenkins'

    metrics_path: '/jenkins/prometheus'

    scheme: http

    static_configs:

    • targets: ['domainname:port']

    basic_auth:

    username: 'xxxxxx'

    password: 'xxxxxxxxxxxxxxxxxxxx'

Upvotes: 0

Aviv
Aviv

Reputation: 14467

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)

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

Useful / Golden Tips for using jenkins prometheus plugin:

  1. 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.

  2. create User account on jenkins dedicated to prometheus monitoring, create a token for authentication.

  3. set screen privileges permissions for viewing jenkins metrics for this user:

For Enabling Metrics permission:

Managing jenkins -> Manage and assign roles -> Manage Roles -> Metrics (set view and health-check to 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.

  1. Configure this credentials on prometheus.yml in your prometheus stack. I'm attaching example for this, this pattern works for me:
- job_name: 'jenkins'
metrics_path: /prometheus
scheme: http
tls_config:
  insecure_skip_verify: true
static_configs:
  - targets: ['company.jenkins.com:8080']
basic_auth:
  username: '[email protected]'
  password: 'abc123'
  1. In order to test this is actual works use curl for perform http request the plugin api and integration for jenkins. curl -u user:token jenkinsURL:port/prometheus/

for example:

curl -u [email protected]:abc123 company.jenkins.com:8080/prometheus/
  1. For testing your integration with prometheus, go to your http://yourPrometheusURL.com:9090/targets and make sure your endpoint is up. you should get the metrics and start using it. Good Luck.

Upvotes: 7

Zauxst
Zauxst

Reputation: 51

PROMETHEUS_ENDPOINT - Configures the path. Defaults to prometheus thus your metrics will be accessible at the URI /prometheus/.

What you want is to configure PROMETHEUS_ENDPOINT to metrics. You will still have to add to prometheux.xml the variable metrics_path and set it to /metrics/

PROMETHEUS_NAMESPACE - puts a prefix to each metric.

Upvotes: 2

Aravind
Aravind

Reputation: 105

http://jenkins.example.com/metrics change it http://jenkins.example.com/prometheus

by using prometheus.yml

change prometheus.yml file

job_name: Jenkins scrape_interval: 5s metrics_path: '/prometheus' scheme: http. tls_config:
insecure_skip_verify: true static_configs: - targets: ['jenkins.example.com:8080']

Upvotes: 0

Related Questions