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

Error while using YAML string formatted scrape target relabeling configuration. #32

Open
Abuelodelanada opened this issue Oct 4, 2023 · 1 comment

Comments

@Abuelodelanada
Copy link

Bug Description

Most of our config options, for instance relabel_configs, are required to be YAML formatted:

  relabel_configs:
    description: YAML string formatted scrape target relabeling configuration.
    type: string

But if you use YAML it fails.

To Reproduce

  1. Deploy this bundle:
bundle: kubernetes
applications:
  prometheus:
    charm: prometheus-k8s
    channel: edge
    series: focal
    resources:
      prometheus-image: 128
    scale: 1
    constraints: arch=amd64
    storage:
      database: kubernetes,1,1024M
    trust: true
  scrape-config:
    charm: prometheus-scrape-config-k8s
    channel: edge
    series: focal
    scale: 1
    options:
      scrape_interval: 12s
      scrape_timeout: 9s
    constraints: arch=amd64
  zinc:
    charm: zinc-k8s
    channel: edge
    resources:
      zinc-image: 120
    scale: 1
    constraints: arch=amd64
    storage:
      data: kubernetes,1,1024M
relations:
- - prometheus:metrics-endpoint
  - scrape-config:metrics-endpoint
- - zinc:metrics-endpoint
  - scrape-config:configurable-scrape-jobs
  1. Create a relabel config like this one.:
    a. Create a variable with the YAML

     $ relabel="source_labels: [__address__]                                 
     separator: ':'
     regex: '(.*):(.*)'
     replacement: '${1}'
     target_label: instance"

    b. Add this config:

     juju config scrape-config relabel_configs=$relabel
  2. Check error while validating scrape jobs:

 unit-prometheus-0: 16:45:46.874 ERROR unit.prometheus/0.juju-log metrics-endpoint:2: Validating scrape jobs failed: b'time="2023-10-04T19:45:46Z" level=fatal msg="parsing YAML file /tmp/tmpas8qx_44: yaml: unmarshal errors:\\n  line 4: cannot unmarshal !!str `source_...` into []*relabel.Config"\n'

Environment

Model  Controller  Cloud/Region        Version  SLA          Timestamp
cos    microk8s    microk8s/localhost  3.1.5    unsupported  16:46:49-03:00

App            Version  Status  Scale  Charm                         Channel  Rev  Address         Exposed  Message
prometheus     2.46.0   active      1  prometheus-k8s                edge     150  10.152.183.115  no       
scrape-config  n/a      active      1  prometheus-scrape-config-k8s  edge      42  10.152.183.200  no       
zinc           ...      active      1  zinc-k8s                      edge     125  10.152.183.151  no       

Unit              Workload  Agent  Address      Ports  Message
prometheus/0*     active    idle   10.1.38.104         
scrape-config/0*  active    idle   10.1.38.89          
zinc/0*           active    idle   10.1.38.99          

Relation provider               Requirer                                Interface          Type     Message
prometheus:prometheus-peers     prometheus:prometheus-peers             prometheus_peers   peer     
scrape-config:metrics-endpoint  prometheus:metrics-endpoint             prometheus_scrape  regular  
zinc:metrics-endpoint           scrape-config:configurable-scrape-jobs  prometheus_scrape  regular  
zinc:zinc-peers                 zinc:zinc-peers                         zinc_peers         peer   

Relevant log output

unit-prometheus-0: 16:45:46.874 ERROR unit.prometheus/0.juju-log metrics-endpoint:2: Validating scrape jobs failed: b'time="2023-10-04T19:45:46Z" level=fatal msg="parsing YAML file /tmp/tmpas8qx_44: yaml: unmarshal errors:\\n  line 4: cannot unmarshal !!str `source_...` into []*relabel.Config"\n'

Additional context

No response

@sed-i
Copy link
Contributor

sed-i commented Oct 11, 2023

This is possibly because the $relabel is not quoted and whitespace breaks up.
Can you confirm with juju config that the config value matches the expected?

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

No branches or pull requests

2 participants