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

allow specification of a custom template #25

Merged
merged 1 commit into from Nov 11, 2016
Merged

allow specification of a custom template #25

merged 1 commit into from Nov 11, 2016

Conversation

lobeck
Copy link
Contributor

@lobeck lobeck commented Nov 8, 2016

we haven't managed to pass relabel configs without weird encoding issues (. and other regex chars get interpreted and saved as values like \x5c.
so we've added a parameter to override the used template and hardcode the stuff in the template to avoid the weird hiera yaml decode and template yaml encode

example: prometheus::config_template: 'components/prometheus/aws.yaml.erb'

whereas the template might look like (this is actual example for some annoying apache storm metric rewriting)

<% require 'yaml' -%>
<% global_config = scope.lookupvar('::prometheus::global_config') -%>
<% rule_files = scope.lookupvar('::prometheus::rule_files') -%>
<% full_config = { 'global'=>global_config, 'rule_files'=>rule_files} -%>
<%= full_config.to_yaml -%>

    scrape_configs:
      - job_name: some-job-name
      scrape_interval: "5s"
      scrape_timeout: "5s"
      static_configs:
        - targets:
            - "foo:1234"
            - "bar:1234"
            - "baz:1234"
        - labels:
            alias: "Awesome Production"
      metric_relabel_configs:
        - source_labels: ['operation']
          regex:         '\"(.*)\..*\"'
          target_label:  'metric'
          replacement:   '$1'
        - source_labels: ['operation']
          regex:         '\".*\.(.*)\"'
          target_label:  'sub_metric'
          replacement:   '$1'
        - source_labels: ['operation']
          target_label:  'operation'
          replacement:   ''

- we haven't managed to pass relabel configs without weird encoding issues (\. and other regex chars get interpreted and saved as values like \x5c.
- so we've added a parameter to override the used template and hardcode the stuff in the template to avoid the weird hiera yaml decode and template yaml encode
@brutus333
Copy link
Collaborator

Looks good. I will merge this PR soon/

@brutus333 brutus333 merged commit 23d6df2 into voxpupuli:master Nov 11, 2016
roidelapluie pushed a commit that referenced this pull request Jun 21, 2017
cegeka-jenkins pushed a commit to cegeka/puppet-prometheus that referenced this pull request Aug 28, 2019
allow specification of a custom template
Rovanion pushed a commit to Rovanion/puppet-prometheus that referenced this pull request May 5, 2021
allow specification of a custom template
Rovanion pushed a commit to Rovanion/puppet-prometheus that referenced this pull request May 5, 2021
This pull request was closed.
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.

2 participants