在prometheus配置中,Json导出器需要传递目标并将json作为参数传递

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

我有一个使用prometheus操作员的prometheus设置。我已经配置了一个黑盒出口商,用于使用prometheus监控一些网址。类似地,我已经实现了一个json导出器,用于从json url路径获取指标。我的配置如下:

  metrics_path: /probe
  params:
    jsonpath: [$.details.db.details.hello] # Look for the nanoseconds field
  static_configs:
    - targets:
      - https://URL path
  relabel_configs:
    - source_labels: [__address__]
      target_label: __param_target
    - source_labels: [__param_target]
      target_label: instance
    - target_label: __address__
      replacement: jsonexporter:9116  # Json exporter.
  metric_relabel_configs:
    - source_labels: value
      target_label:  hello``` 



But the issue is, getting error while reloading the Prometheus as follows:

level=error ts=2019-04-16T06:05:24.395218368Z caller=main.go:597 err="Error loading config couldn't load configuration (--config.file=/etc/prometheus/config_out/prometheus.env.yaml): parsing YAML file /etc/prometheus/config_out/prometheus.env.yaml: yaml: unmarshal errors:\n  line 3871: cannot unmarshal !!str `value` into model.LabelNames"

Cam someone help me to correct this?
prometheus prometheus-operator
1个回答
0
投票

我已经解决了这个问题。修改配置如下;

  metrics_path: /probe
  params:
    jsonpath: [$.details.db.details.hello] # 
  static_configs:
    - targets:
      - https://URL path
  relabel_configs:
        - source_labels: [__address__]     # set param 'target' to the original target
          target_label: __param_target
          replacement: ${1}
        - source_labels: [__param_target]  # set label 'instance' to it as well
          target_label: instance
          replacement: ${1}
        - target_label: __address__
          replacement: jsonexporter:9116```
© www.soinside.com 2019 - 2024. All rights reserved.