cloud-foundrycf-boshbosh

BOSH CLI Expected to find a map at path ... but found '[]interface {}'


Very similar to another question, but there are slight differences. Tried the accepted answer and still no luck.

I get this error when I run the command:

bosh -d prometheus deploy -n pfg-prometheus-boshrelease/manifests/prometheus.yml -o replace_vars.yml

Expected to find a map at path '/instance_groups/name=prometheus2/jobs/name=prometheus2/properties/prometheus/scrape_configs/job_name=bosh/static_configs/targets?' but found '[]interface {}'

replace_vars.yml:

- type: replace
  path: /instance_groups/name=prometheus2/jobs/name=prometheus2/properties/prometheus/scrape_configs/job_name=bosh/static_configs/targets?/-
  value: 192.168.123.26:9190

Manifest section:

- name: prometheus2
    properties:
      prometheus:
        rule_files:
        - ...
        scrape_configs:
        - file_sd_configs:
          - files:
            - /var/vcap/store/bosh_exporter/bosh_target_groups.json
          job_name: prometheus
          relabel_configs:
          - action: keep
            ...
          - regex: (.*)
            ...
        - job_name: bosh
          scrape_interval: 2m
          scrape_timeout: 1m
          static_configs:
          - targets:
            - localhost:9190

What would the correct path be?

EDIT: I have looked through bosh cli ops files but cannot find an example like mine.


Solution

  • I also stumpled upon this several times and never found a solution for this use case. What I usually do as a workaround is to replace one step up. For your example:

    /tmp/replace-vars.yml:

    - type: replace
      path: /instance_groups/name=prometheus2/jobs/name=prometheus2/properties/prometheus/scrape_configs/job_name=bosh/static_configs/0
      value:
        targets:
        - 192.168.123.26:9190
        - localhost:9190
    

    /tmp/test-manifest.yml:

    instance_groups:
    - name: prometheus2
      jobs:
        - name: prometheus2
          properties:
            prometheus:
              rule_files:
              - abc
              scrape_configs:
              - file_sd_configs:
              - files:
                - /var/vcap/store/bosh_exporter/bosh_target_groups.json
              job_name: prometheus
              relabel_configs:
              - action: keep
              - regex: (.*)
              - job_name: bosh
              scrape_interval: 2m
              scrape_timeout: 1m
              static_configs:
              - targets:
                - localhost:9190
    

    Interpolated by bosh int /tmp/test-manifest.yml -o /tmp/replace-vars.yml:

    instance_groups:
    - jobs:
      - name: prometheus2
          properties:
            prometheus:
              rule_files:
              - abc
              scrape_configs:
              - file_sd_configs:
              - files:
                - /var/vcap/store/bosh_exporter/bosh_target_groups.json
              job_name: prometheus
              relabel_configs:
              - action: keep
              - regex: (.*)
              - job_name: bosh
              scrape_interval: 2m
              scrape_timeout: 1m
              static_configs:
              - targets:
                - 192.168.123.26:9190
                - localhost:9190
      name: prometheus2