GitLab exporter with Prometheus

797 views
Skip to first unread message

Anne

unread,
Feb 14, 2018, 6:54:33 PM2/14/18
to Prometheus Users
I'm totally new to Prometheus and I'm very confused.

GitLab says you can monitor GitLab runners with prometheus by setting the metrics_server config option. I set it to `metrics_server = :9252` because GitLab suggests using that port.

I'm also trying to integrate with DataDog. A default setting there is `prometheus_endpoint: http://localhost:9252/metrics`. 

I can't find any instructions on how to set up the Prometheus component of this. What I've done so far:

0. Set up GitLab runner. 
1. Downloaded version 2.1.0 (linux) of Prometheus.
2. Made a simple file based on the sample config, named `gitlab-runner-tests-config.yml`:
```
global:
  scrape_interval:     15s # By default, scrape targets every 15 seconds.

  # Attach these labels to any time series or alerts when communicating with
  # external systems (federation, remote storage, Alertmanager).
  external_labels:
    monitor: 'gitlab-runner-test-thing'

scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus-gitlab-runner-test'

    # Override the global default and scrape targets from this job every 5 seconds.
    scrape_interval: 5s

    static_configs:
      - targets: ['localhost:9252']
```
3. Started prometheus with `./prometheus --web.listen-address="localhost:9252" --config.file=gitlab-runner-test-config.yml`
4. Ran `curl localhost:9252/metrics`. Saw stuff that didn't look related to my GitLab runner. 

I think I'm wrong about setting `static_configs.targets` to `localhost:9252`. How do I figure out what this should be? (Am I wrong to be creating a config file at all? The GitLab docs aren't clear about what's built in.)

Julius Volz

unread,
Feb 15, 2018, 3:57:24 AM2/15/18
to Anne, Prometheus Users
On Thu, Feb 15, 2018 at 6:54 AM, Anne <6nn...@gmail.com> wrote:
I'm totally new to Prometheus and I'm very confused.

GitLab says you can monitor GitLab runners with prometheus by setting the metrics_server config option. I set it to `metrics_server = :9252` because GitLab suggests using that port.

I'm also trying to integrate with DataDog. A default setting there is `prometheus_endpoint: http://localhost:9252/metrics`. 

I can't find any instructions on how to set up the Prometheus component of this. What I've done so far:

0. Set up GitLab runner. 
1. Downloaded version 2.1.0 (linux) of Prometheus.
2. Made a simple file based on the sample config, named `gitlab-runner-tests-config.yml`:
```
global:
  scrape_interval:     15s # By default, scrape targets every 15 seconds.

  # Attach these labels to any time series or alerts when communicating with
  # external systems (federation, remote storage, Alertmanager).
  external_labels:
    monitor: 'gitlab-runner-test-thing'

scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus-gitlab-runner-test'

    # Override the global default and scrape targets from this job every 5 seconds.
    scrape_interval: 5s

    static_configs:
      - targets: ['localhost:9252']
```
3. Started prometheus with `./prometheus --web.listen-address="localhost:9252" --config.file=gitlab-runner-test-config.yml`

--web.listen-address="localhost:9252" is the port that Prometheus listens on itself. You probably want to keep that at the default of 9090, but at least it should not clash with the port 9252 of the GitLab runner, in case that's also running on the same machine.
 
4. Ran `curl localhost:9252/metrics`. Saw stuff that didn't look related to my GitLab runner. 

Yeah, you'd be getting Prometheus's own metrics about itself then, if you run it like above.

The config looks fine though (you don't need the external_labels stuff), if you have the *runner* (not Prometheus) listen on that port.
 
I think I'm wrong about setting `static_configs.targets` to `localhost:9252`. How do I figure out what this should be? (Am I wrong to be creating a config file at all? The GitLab docs aren't clear about what's built in.)

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/4e8273fe-70ee-4909-a287-8f4944ab3f34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ben Kochie

unread,
Feb 15, 2018, 8:44:56 AM2/15/18
to Anne, Prometheus Users
Thanks for pointing this out.  This looks like a mistake in our flag naming.

I have filed an issue[0] to rename this to "listen address" so it's less confusing.


--
Reply all
Reply to author
Forward
0 new messages