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

WIP: add ability to export/collect scrape_jobs #141

Closed
wants to merge 1 commit into from

Conversation

costela
Copy link

@costela costela commented Jan 4, 2018

No description provided.

@costela costela changed the title add ability to export/collect scrape_jobs WIP: add ability to export/collect scrape_jobs Jan 4, 2018
@bastelfreak
Copy link
Member

Fixes #126

@@ -3,10 +3,11 @@
class prometheus::config (
$global_config,
$rule_files,
$scrape_configs,
Array[Hash] $scrape_configs,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Datatypes \o/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know the structure of the Hash? Could that be enforced as well within the datatype?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about we just don't try to fix that in this specific pull request? there wasn't a type before either...

Suggested change
Array[Hash] $scrape_configs,
$scrape_configs,

:P

$service_ensure = 'running',
$service_enable = true,
$manage_service = true,
Boolean $export_scrape_job = false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Datatypes \o/

Array $alert_relabel_config = $::prometheus::params::alert_relabel_config,
Array $alertmanagers_config = $::prometheus::params::alertmanagers_config,
String $storage_retention = $::prometheus::params::storage_retention,
Array[Hash] $collect_scrape_jobs = $::prometheus::params::collect_scrape_jobs,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Datatypes \o/

String $job_name,
Array[String] $targets,
Hash[String, String] $labels = {},

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the newline here

mode => $mode,
content => template("${module_name}/file_sd_config.yaml.erb"),
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add anewline

@bastelfreak
Copy link
Member

This looks good on a first view, but we need tests for it.

@bastelfreak bastelfreak added enhancement New feature or request needs-tests labels Jan 4, 2018
@viq
Copy link

viq commented May 17, 2018

What's the state of this? It would be really handy for me ;)

@costela
Copy link
Author

costela commented May 18, 2018

@viq sorry, this kinda fell between the cracks.
I'll try to get to it next week, but I wouldn't complain if someone could conjure up some tests before that 😉

@ajcollett
Copy link

I am super interested in this. Can you give me an idea of what still needs to happen? Not sure I can help with much, other than real world testing...

@costela
Copy link
Author

costela commented Oct 8, 2018

@ajcollett sorry, I just haven't had the time to add the needed tests. And now I also have to rebase and solve conflicts... 😒
I might be able to squeeze this in a slot on Friday, but I can't make any promises.

@ajcollett
Copy link

No problem. I hope it's easier than it seems!

I am slightly surprised this particular issue isn't more popular. Is it just that people are all doing this themselves anyway?

@bastelfreak
Copy link
Member

@ajcollett personally, I use consul for this.It already knows all services that I have, they expose a prometheus endpoint. Also I've got certain exporters that are also registered to consul. That scales way better than exported resources.

@@ -78,6 +78,9 @@
$manage_service = true,
Hash[String, Scalar] $env_vars = {},
Optional[String] $env_file_path = $::prometheus::params::env_file_path,
Boolean $export_scrape_job = false,
String $scrape_host = $::fqdn,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use $facts['fqdn']

@@ -0,0 +1,3 @@
# this file is managed by puppet; changes will be overwritten
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you provide this as a simple file resource without a template? We could pass the content to it with https://github.com/puppetlabs/puppetlabs-stdlib#to_yaml

# Array of scrape_configs. Format, e.g.:
# - job_name: some_exporter
# scheme: https
# The jobs defined here will be used to collect resources exported via prometheus::daemon,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i find this datastructure a little over-complicated and inconvenient - what if i want to collect all jobs, regardless of the type? the way it's setup now, i have to specify each one by hand....

i'm thinking of simplifying this and simply make that a mixed type of boolean / array of job names. if it's a list, it behaves basically the same way (minus the scheme override, which belongs in the scrape_job def). if it's a boolean and true, all jobs are collected. if it's false, nothing is collected of course.

i'm working on an update of this PR to make it work with latest master which includes those changes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking up the work!
I'm not sure I understand your suggestion though. I'll follow up on your new PR #304.

@anarcat
Copy link

anarcat commented Mar 18, 2019

okay, i have done my homework and this is actually working in production in #304 so I think this PR should be closed and discussion be moved there.

@costela
Copy link
Author

costela commented Mar 19, 2019

agreed

@costela costela closed this Mar 19, 2019
@costela costela deleted the export_resources branch June 13, 2019 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants