Navigation Menu

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

source_labels and module must be unquoted #165

Closed
wants to merge 1 commit into from

Conversation

yackushevas
Copy link

for example source_labels:

bad:

 relabel_configs:
  - source_labels: "['__meta_consul_service']"
    regex: "(.*)"
    target_label: service
    replacement: "$1"

good:

 relabel_configs:
  - source_labels: ['__meta_consul_service']
    regex: "(.*)"
    target_label: service
    replacement: "$1"

and blackbox_exporter:

bad:

- job_name: http_check
  metrics_path: "/probe"
  params:
    module: "[http_2xx]"

good:

- job_name: http_check
  metrics_path: "/probe"
  params:
    module: [http_2xx]

blackbox_exporter module must be unquoted
@bastelfreak
Copy link
Member

Hi @yackushevas, thanks for the PR. The change looks a bit cryptic. Can you add a test that verifies the correct behavior?

@yackushevas
Copy link
Author

#98
same thing, but for prometheus 2.x

@bastelfreak
Copy link
Member

Hi,
I'm going to close this PR. This got already implemented.

commit b81faa0af76ffbaf97591fdbd7e848fa0bf995e3
Author: Sebastian Rakel <sebastian@devunit.eu>
Date:   Mon Jun 18 23:19:07 2018 +0200

    Remove double quotes from source_labels value with gsub
    
    The value in source_labels have to be without quotes, but sometimes you
    have to use brackets in the value and puppet surrounds it with double
    quotes.
    
    So we need to replace the double quotes with nothing in the template

diff --git a/templates/prometheus.yaml.erb b/templates/prometheus.yaml.erb
index b59941a..483c475 100644
--- a/templates/prometheus.yaml.erb
+++ b/templates/prometheus.yaml.erb
@@ -22,7 +22,7 @@ if @prometheus_v2
 end
  -%>
 <%= if @prometheus_v2
-full_config.to_yaml
+full_config.to_yaml().gsub(/source_labels: ".+?"/) { |x| x.gsub('"', '') }
 else
 full_config.to_yaml(options = {:line_width => -1}).gsub(/source_labels: ".+?"/) { |x| x.gsub('"', '') }
 end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants