SUSE / DeepSea

A collection of Salt files for deploying, managing and automating Ceph.
GNU General Public License v3.0
161 stars 75 forks source link

monitoring: enable custom scrape configurations #1868

Closed p-se closed 3 years ago

p-se commented 3 years ago

Scrape configurations cannot be loaded externally by using a statement like include inside the Prometheus configuration file. The configuration management system is supposed to create the Prometheus configuration file appropriately. By using service discovery the user wouldn't be able to configure some details like the scrape_interval or those would need to be configured separately.

This implementation enables to provide a whole block to /srv/pillar/ceph/stack/global.yml under the monitoring:prometheus:custom_scrape_configs hierarchy and does so by iterating the keys and values for least implementation effort.

Fixes: https://bugzilla.suse.com/show_bug.cgi?id=1179029

Signed-off-by: Patrick Seidensal pseidensal@suse.com

smithfarm commented 3 years ago

@p-se ~Could you include (ideally, in the commit message itself) a brief explanation why this can't be done upstream?~

UPDATE: nevermind and sorry for the noise. I thought this was targeting SUSE/ceph, but now I see it's SUSE/DeepSea o.O

p-se commented 3 years ago

In my experience, Jinja's behavior when it comes to newlines (whether they get added or not) is odd and difficult to control.

If this patch has been tested and shown to work, then I don't have any problem with it.

Yes, it has been tested and proven to work.

The resulting YAML snippet does not look as readable as YAML is used to, as it is exported in JSON format (which is luckily 100% compatible with YAML), but it enables to simply write all kinds of values (even those with nested structures) into the file without any issues.

It would have to be evaluated, but maybe this implementation could even be used as basis for clean-ups which could potentially reduce the complexity and size of many of the SLS files in the project.