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

have node file definitions use underscore instead of column #435

Merged
merged 4 commits into from
Mar 3, 2020

Conversation

ndelic0
Copy link

@ndelic0 ndelic0 commented Mar 2, 2020

Pull Request (PR) description

Currently if collect_scrape_jobs is set to true all file definitions created in /etc/prometheus/file_sd_config.d/ will contain \:. This change would make file definitions look cleaner.
On the other note, if all the exporters running on a node are running on a loop back interface - behind reverse proxy, exported resource will complain on double declarations. This change should give us more ways to set file definition names.

This Pull Request (PR) fixes the following issues

@ndelic0 ndelic0 changed the title have node file definitions use underscore instead of column WIP - have node file definitions use underscore instead of column Mar 2, 2020
@ndelic0 ndelic0 changed the title WIP - have node file definitions use underscore instead of column have node file definitions use underscore instead of column Mar 2, 2020
@bastelfreak bastelfreak added the bug Something isn't working label Mar 3, 2020
@bastelfreak
Copy link
Member

Thanks for the fix!

@bastelfreak bastelfreak merged commit ed5334d into voxpupuli:master Mar 3, 2020
@antondollmaier
Copy link

Sorry for commenting on an already merged PR.

This change broke our custom prometheus::scrape_job usages: the Scrape job name must now be specified explicitly in the declaration, instead of relying on scrape_job to use the proper file name.

While appreciating the change itself, it's kind of breaking existing behaviour - and a note in the Changelog would have been appreciated.

Should a note be added to the changelog?

@ndelic0
Copy link
Author

ndelic0 commented Apr 28, 2020

@antondollmaier Maybe you can share how custom prometheus::scrabe_job on your side? Wondering if this could be refactored so that it does not break existing behaviour.

@antondollmaier
Copy link

@antondollmaier Maybe you can share how custom prometheus::scrabe_job on your side?

Sure!

Previously working example below. It's used to add the native RabbitMQ Prometheus plugin of 3.8 without the exporter.

class mod::rabbitmq (
  Boolean $export_scrape_job = true,
  String $scrape_host = $facts['fqdn'],
  String $scrape_job_name = 'rabbitmq',
  Integer $stats_port = 15692,
) {
  if $export_scrape_job {
    @@prometheus::scrape_job { "${facts['fqdn']}:${stats_port}":
      job_name => $scrape_job_name,
      targets  => ["${scrape_host}:${stats_port}"],
    }
  }

Obviously, the change to my code is simple and does the job perfectly. Targets are scraped again.

-    @@prometheus::scrape_job { "${facts['fqdn']}:${stats_port}":
+    @@prometheus::scrape_job { "${scrape_job_name}_${facts['fqdn']}_${stats_port}":

When comparing with the previous version in prometheus::daemon, it was identical to my adaption (well, I copied from there):

    @@prometheus::scrape_job { "${scrape_host}:${scrape_port}":

BTW, the $job_name parameter seems to be unused as well. Dropping it will break more, I suppose, but I don't see any reference to that parameter any more.

As I said, I don't object in any way with the change (especially, as it's already released), I only wasn't able to read that change from the changelog and was left wondering why my targets weren't found any more.

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
…name

have node file definitions use underscore instead of column
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants