首页  

prometheus http_sd_config 基于http服务发现     所属分类 prometheus 浏览量 613
https://prometheus.io/docs/prometheus/latest/configuration/configuration/

# List of HTTP service discovery configurations.
http_sd_configs:


HTTP-based service discovery provides a more generic way to configure static targets and serves as an interface to plug in custom service discovery mechanisms.

It fetches targets from an HTTP endpoint containing a list of zero or more static_config . 
The target must reply with an HTTP 200 response. 
The HTTP header Content-Type must be application/json, and the body must be valid JSON.

Example response body:

[
  {
    "targets": [ "host", ... ],
    "labels": {
      "labelname": "labelvalue", ...
    }
  },
  ...
]
The endpoint is queried periodically at the specified refresh interval. 
The prometheus_sd_http_failures_total counter metric tracks the number of refresh failures.

Each target has a meta label __meta_url during the relabeling phase. 
Its value is set to the URL from which the target was extracted.



static_configs - job_name: 'app1' # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ['192.168.0.8:8000','192.168.0.8:8010'] - job_name: 'app2' metrics_path:'/my/metrics' static_configs: - targets: ['127.0.0.1:8080','127.0.0.1:8090']
scrape_configs: - job_name: 'http-sd-demo' http_sd_configs: - url: http://127.0.0.1:8080/api/services
[ { "targets": ["10.0.10.2:9100", "10.0.10.3:9100", "10.0.10.4:9100", "10.0.10.5:9100"], "labels": { "__meta_datacenter": "london", "__meta_prometheus_job": "node" } }, { "targets": ["10.0.40.2:9200", "10.0.40.3:9200"], "labels": { "__meta_datacenter": "london", "__meta_prometheus_job": "alertmanager" } }, { "targets": ["10.0.40.2:9093", "10.0.40.3:9093"], "labels": { "__meta_datacenter": "newyork", "__meta_prometheus_job": "alertmanager" } } ]
./prometheus --version prometheus, version 2.17.1 (branch: HEAD, revision: ae041f97cfc6f43494bed65ec4ea4e3a0cf2ac69) ./promtool check config prometheus.yml Checking prometheus.yml FAILED: parsing YAML file prometheus.yml: yaml: unmarshal errors: line 92: field http_sd_configs not found in type config.plain
使用nacos的服务发现功能,自动获取实例配置监控,将某服务的实例列表写入文件。 https://gitee.com/lhtzbj12/prometheus-sd-nacos

上一篇     下一篇
rabbitmq 基础

nacos 配置安装

SpringCloud与SpringCloud Alibaba的区别

简单家常菜

flink prometheus 监控指标

JMS 和 AMQP