Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scrape job file names to ensure job_name is prefix #450

Merged
merged 1 commit into from
May 18, 2020

Conversation

treydock
Copy link

Pull Request (PR) description

This fixes a regression from 829aa4e. Basically I have dozens of profile classes that do things like this:

  @@prometheus::scrape_job { "${facts['networking']['fqdn']}-${name}":
    job_name => 'tcp-probe',
    targets  => $targets,
    labels   => {
      'host' => $facts['networking']['hostname'],
      'cluster' => lookup('prometheus_cluster'),
      'environment' => lookup('prometheus_environment'),
      'service' => $name,
      'module' => $module,
      'role'  => $role,
    }
  }

Before the referenced commit, this worked, now the filename lacks the job_name prefix and thus never picked up by prometheus. If the job_name is going to be hardcoded prefix in prometheus::config class then I think this module should always ensure scrape jobs have the job name as prefix.

@ghoneycutt ghoneycutt merged commit 123cad5 into voxpupuli:master May 18, 2020
@anarcat
Copy link

anarcat commented Feb 22, 2021

between this and #435, we now have the job name twice in the filename:

Notice: /Stage[main]/Prometheus::Config/Prometheus::Scrape_job[apache_perdulce.torproject.org_9117]/File[/etc/prometheus/file_sd_config.d/apache_apache_perdulce.torproject.org_9117.yaml]/ensure: defined content as '{md5}9e1a35d39f151eab884e55588321b5b2'

this used to be:

Notice: /Stage[main]/Prometheus::Config/File[/etc/prometheus/file_sd_config.d/apache_perdulce.torproject.org:9117.yaml]/ensure: removed

so i'll send a PR to fix this incongruity.

anarcat added a commit to anarcat/puppet-prometheus that referenced this pull request Feb 22, 2021
Between voxpupuli#435 and voxpupuli#450, the file path for the exported job names was
changed to use underscores instead of colons. That's fine, except
that, in the end, the actual filename had a superfluous
`$scrape_job_name` parameter added. Taking the Apache exporter as an
example, I used to have:

    /etc/prometheus/file_sd_config.d/apache_perdulce.torproject.org:9117.yaml

I now have:

    /etc/prometheus/file_sd_config.d/apache_apache_eugeni.torproject.org_9117.yaml

That still works of course: the old file is removed and the new one is
picked up, but it does look silly and needlessly redundant.

I should note that this might mean some clashes between jobs, if the
same host/port combination is scraped by multiple jobs on the
Prometheus server. I have no idea if that's a valid use case, but I
should point out that, if it is, then the `job_name` parameter should
just be removed and instead the resource name should forcibly include
the job name, instead of enforcing this weird duplication.

In other words, maybe this is also an API breaking change that should
warrant a changelog entry, but I'll let my co-maintainers be the
judges of this.
anarcat added a commit to anarcat/puppet-prometheus that referenced this pull request Feb 22, 2021
Between voxpupuli#435 and voxpupuli#450, the file path for the exported job names was
changed to use underscores instead of colons. That's fine, except
that, in the end, the actual filename had a superfluous
`$scrape_job_name` parameter added. Taking the Apache exporter as an
example, I used to have:

    /etc/prometheus/file_sd_config.d/apache_perdulce.torproject.org:9117.yaml

I now have:

    /etc/prometheus/file_sd_config.d/apache_apache_eugeni.torproject.org_9117.yaml

That still works of course: the old file is removed and the new one is
picked up, but it does look silly and needlessly redundant.

I should note that this might mean some clashes between jobs, if the
same host/port combination is scraped by multiple jobs on the
Prometheus server. I have no idea if that's a valid use case, but I
should point out that, if it is, then the `job_name` parameter should
just be removed and instead the resource name should forcibly include
the job name, instead of enforcing this weird duplication.

In other words, maybe this is also an API breaking change that should
warrant a changelog entry, but I'll let my co-maintainers be the
judges of this.
Rovanion pushed a commit to Rovanion/puppet-prometheus that referenced this pull request May 5, 2021
Fix scrape job file names to ensure job_name is prefix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants