Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

[stable/prometheus] harmonization of regex references without braces #10055

Merged
merged 1 commit into from
Dec 17, 2018
Merged

[stable/prometheus] harmonization of regex references without braces #10055

merged 1 commit into from
Dec 17, 2018

Conversation

pdemagny
Copy link
Contributor

@pdemagny pdemagny commented Dec 17, 2018

Signed-off-by: Pierre DEMAGNY pierre.demagny@citymeo.fr

What this PR does / why we need it:

This PR harmonizes regex references in values.yaml. There were some references with braces, some without. Removed all occurences of reference with braces to avoid breaking external tools like Terraform Template Provider, for example:

data "template_file" "prometheus_tmpl" {
  template = "${file("templates/values-prometheus.yaml.tmpl")}"

  vars {
    PROMETHEUS_INGRESS_HOST   = "${local.workspace["prometheus_ingress_host"]}"
    PROMETHEUS_INGRESS_PATH   = "${local.workspace["prometheus_ingress_path"]}"
  }
}
server:
...
  ingress:
...
    ## Prometheus server Ingress hostnames with optional path
    ## Must be provided if Ingress is enabled
    ##
    hosts:
      - ${PROMETHEUS_INGRESS_HOST}${PROMETHEUS_INGRESS_PATH}
    #   - domain.com/prometheus

Regex references of the form ${n} are interpolated by Terraform's Template Provider, so for example in:

      - job_name: 'kubernetes-nodes'
...
        kubernetes_sd_configs:
          - role: node

        relabel_configs:
          - action: labelmap
            regex: __meta_kubernetes_node_label_(.+)
          - target_label: __address__
            replacement: kubernetes.default.svc:443
          - source_labels: [__meta_kubernetes_node_name]
            regex: (.+)
            target_label: __metrics_path__
            replacement: /api/v1/nodes/${1}/proxy/metrics

My __metrics_path__ end up with /api/v1/nodes/1/proxy/metrics and the 'kubernetes-nodes' job does not work.

When using regex references of the form $n, they are not interpolated and labelling magic works:

      - job_name: 'kubernetes-nodes'
...
        kubernetes_sd_configs:
          - role: node

        relabel_configs:
          - action: labelmap
            regex: __meta_kubernetes_node_label_(.+)
          - target_label: __address__
            replacement: kubernetes.default.svc:443
          - source_labels: [__meta_kubernetes_node_name]
            regex: (.+)
            target_label: __metrics_path__
            replacement: /api/v1/nodes/$1/proxy/metrics

My __metrics_path__ end up with /api/v1/nodes/<node_name>/proxy/metrics where <node_name> is the name of each of my nodes and the 'kubernetes-nodes' job works.

Which issue this PR fixes

There were no open issues for this.

Checklist

  • DCO signed
  • Chart Version bumped

Signed-off-by: Pierre DEMAGNY <pierre.demagny@citymeo.fr>
@helm-bot helm-bot added Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 17, 2018
@pdemagny pdemagny changed the title [stable/prometheus] harmonization of regex reference without braces [stable/prometheus] harmonization of regex references without braces Dec 17, 2018
@gianrubio
Copy link
Collaborator

/ok-to-test
/lgtm

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gianrubio, pdemagny

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. labels Dec 17, 2018
@k8s-ci-robot k8s-ci-robot merged commit f705a10 into helm:master Dec 17, 2018
@pdemagny pdemagny deleted the prometheus_regex_reference_nobraces branch December 17, 2018 23:19
coreypobrien pushed a commit to FairwindsOps/helm-charts that referenced this pull request Dec 31, 2018
…elm#10055)

Signed-off-by: Pierre DEMAGNY <pierre.demagny@citymeo.fr>
wgiddens pushed a commit to wgiddens/charts that referenced this pull request Jan 18, 2019
…elm#10055)

Signed-off-by: Pierre DEMAGNY <pierre.demagny@citymeo.fr>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). lgtm Indicates that a PR is ready to be merged. ok-to-test size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants