Skip to content

relabel_configs replacement regex failing #1201

Closed
@lkysow

Description

@lkysow
receivers:
  prometheus:
    config:
      global:
        scrape_interval: 15s
        scrape_timeout: 10s
      scrape_configs:
        - job_name: consul
          metrics_path: /metrics
          consul_sd_configs:
            - server: '<address>:8500'
          relabel_configs:
            - source_labels:
                - __meta_consul_tagged_address_lan
              regex: '(.*)'
              replacement: '${1}:9102'
              target_label: '__address__'
              action: 'replace'

relabel_configs with the replacement key fails to output the matched string. I just get these errors:

Get \"http://:9102/metrics\": dial tcp :9102: connect: connection refused"

The weird thing is if I don't use the replacement key:

          relabel_configs:
            - source_labels:
                - __meta_consul_tagged_address_lan
              regex: '(.*)'
              target_label: '__address__'
              action: 'replace'

Then it correctly substitutes the address (but then uses port 80 which doesn't work for my use-case).

Additional context

Full config:

receivers:
  prometheus:
    config:
      global:
        scrape_interval: 15s
        scrape_timeout: 10s
      scrape_configs:
        - job_name: consul
          metrics_path: /metrics
          consul_sd_configs:
            - server: '<address>:8500'
          relabel_configs:
            - source_labels:
                - __meta_consul_tagged_address_lan
              regex: '(.*)'
              replacement: '${1}:9102'
              target_label: '__address__'
              action: 'replace'
  awsecscontainermetrics:
    collection_interval: 10s
processors:
  filter:
    metrics:
      include:
        match_type: strict
        metric_names:
          - ecs.task.memory.utilized
          - ecs.task.memory.reserved
          - ecs.task.cpu.utilized
          - ecs.task.cpu.reserved
          - ecs.task.network.rate.rx
          - ecs.task.network.rate.tx
          - ecs.task.storage.read_bytes
          - ecs.task.storage.write_bytes
exporters:
  awsprometheusremotewrite:
    endpoint: <ep>
    aws_auth:
      region: us-east-1
      service: aps
  logging:
    loglevel: info
extensions:
  health_check:
  pprof:
    endpoint: :1888
  zpages:
    endpoint: :55679
service:
  telemetry:
    logs:
      level: debug
  extensions: [pprof, zpages, health_check]
  pipelines:
    metrics:
      receivers: [prometheus]
      exporters: [logging, awsprometheusremotewrite]
    metrics/ecs:
      receivers: [awsecscontainermetrics]
      processors: [filter]
      exporters: [logging, awsprometheusremotewrite]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions