BOSH CLI 预期在路径处找到一个地图......但找到了'[]interface {}'。

问题描述 投票:0回答:1

和另一个问题非常相似,但有细微的差别。尝试了接受的答案,但还是没有结果。

当我运行这个命令时,我得到这个错误。

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

"instance_groupsname=prometheus2jobsname=prometheus2propertiesprometheusscrape_configsjob_name=boshstatic_configstargets?",但找到了"[]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部分。

- 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

正确的路径是什么?

EDIT: 我已经看完了 bosh cli操作文件 但找不到像我这样的例子。

cloudfoundry cf-bosh bosh
1个回答
1
投票

我也偶然发现了好几次,但一直没有找到这个用例的解决方案。我通常会做的变通办法是,在你的例子中,替换一个步骤。

/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

插值的方法是 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
© www.soinside.com 2019 - 2024. All rights reserved.