【问题标题】:BOSH CLI Expected to find a map at path ... but found '[]interface {}'BOSH CLI 预计会在路径中找到地图……但找到了 '[]interface {}'
【发布时间】:2020-05-22 15:32:42
【问题描述】:

与另一个问题非常相似,但略有不同。尝试了接受的答案,但仍然没有运气。

运行命令时出现此错误:

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

预计会在路径“/instance_groups/name=prometheus2/jobs/name=prometheus2/properties/prometheus/scrape_configs/job_name=bosh/static_configs/targets?”找到地图?但找到'[]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

清单部分:

- 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

正确的路径是什么?

编辑:我查看了bosh cli ops files,但找不到像我这样的例子。

【问题讨论】:

    标签: cloud-foundry cf-bosh bosh


    【解决方案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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-25
      • 2012-08-26
      • 1970-01-01
      • 1970-01-01
      • 2020-11-08
      • 2013-02-19
      • 2021-11-18
      相关资源
      最近更新 更多