综合久久久久久综合久 ,国第一产在线无码精品区,粗大进入日本高h视频,91尤物国产尤物福利在线,亚洲精品无码久久毛片波多野吉,五月婷婷丁香综合,二级特黄绝大片免费视频大片,国产欧美在线观看精品一区污

天天觀焦點:【云原生 ? Prometheus】Prometheus 注冊中心Eureka服務發現原理

來源:騰訊云

Prometheus 注冊中心Eureka服務發現原理

概述

Eureka服務發現協議允許使用Eureka Rest API檢索出Prometheus需要監控的targets,Prometheus會定時周期性的從Eureka調用Eureka Rest API,并將每個應用實例創建出一個target。


(相關資料圖)

Eureka服務發現協議支持對如下元標簽進行relabeling

__meta_eureka_app_name: the name of the app__meta_eureka_app_instance_id: the ID of the app instance__meta_eureka_app_instance_hostname: the hostname of the instance__meta_eureka_app_instance_homepage_url: the homepage url of the app instance__meta_eureka_app_instance_statuspage_url: the status page url of the app instance__meta_eureka_app_instance_healthcheck_url: the health check url of the app instance__meta_eureka_app_instance_ip_addr: the IP address of the app instance__meta_eureka_app_instance_vip_address: the VIP address of the app instance__meta_eureka_app_instance_secure_vip_address: the secure VIP address of the app instance__meta_eureka_app_instance_status: the status of the app instance__meta_eureka_app_instance_port: the port of the app instance__meta_eureka_app_instance_port_enabled: the port enabled of the app instance__meta_eureka_app_instance_secure_port: the secure port address of the app instance__meta_eureka_app_instance_secure_port_enabled: the secure port of the app instance__meta_eureka_app_instance_country_id: the country ID of the app instance__meta_eureka_app_instance_metadata_: app instance metadata__meta_eureka_app_instance_datacenterinfo_name: the datacenter name of the app instance__meta_eureka_app_instance_datacenterinfo_: the datacenter metadata

eureka_sd_configs常見配置如下:

- job_name: "eureka"  eureka_sd_configs:    - server: http://localhost:8761/eureka #eureka server地址      refresh_interval: 1m #刷新間隔,默認30s

eureka_sd_configs官網支持主要配置如下:

server: basic_auth:  [ username:  ]  [ password:  ]  [ password_file:  ]# Configures the scrape request"s TLS settings.tls_config:  [  ]# Optional proxy URL.[ proxy_url:  ]# Configure whether HTTP requests follow HTTP 3xx redirects.[ follow_redirects:  | default = true ]# Refresh interval to re-read the app instance list.[ refresh_interval:  | default = 30s ]

Eureka協議實現

基于Eureka服務發現協議核心邏輯都封裝在discovery/eureka.gofunc (d *Discovery) refresh(ctx context.Context) ([]*targetgroup.Group, error)方法中:

func (d *Discovery) refresh(ctx context.Context) ([]*targetgroup.Group, error) { // 通過Eureka REST API接口從eureka拉取元數據:http://ip:port/eureka/apps apps, err := fetchApps(ctx, d.server, d.client) if err != nil {  return nil, err } tg := &targetgroup.Group{  Source: "eureka", } for _, app := range apps.Applications {//遍歷app        // targetsForApp()方法將app下每個instance部分轉成target  targets := targetsForApp(&app)        //解析的采集點合入一起  tg.Targets = append(tg.Targets, targets...) } return []*targetgroup.Group{tg}, nil}

refresh方法主要有兩個流程:

1、fetchApps():從eureka-server/eureka/apps接口拉取注冊服務信息;

2、targetsForApp():遍歷appinstance,將每個instance解析出一個target,并添加一堆元標簽數據。

如下示例從eureka-server/eureka/apps接口拉取的注冊服務信息:

    1    UP_1_            SERVICE-PROVIDER-01                    localhost:service-provider-01:8001            192.168.3.121            SERVICE-PROVIDER-01            192.168.3.121            UP            UNKNOWN            8001            443            1                            MyOwn                                        30                90                1629385562130                1629385682050                0                1629385562132                                        8001                true                8080                        http://192.168.3.121:8001/            http://192.168.3.121:8001/actuator/info            http://192.168.3.121:8001/actuator/health            service-provider-01            service-provider-01            false            1629385562132            1629385562039            ADDED            

instance信息會被解析成采集點target

func targetsForApp(app *Application) []model.LabelSet { targets := make([]model.LabelSet, 0, len(app.Instances)) // Gather info about the app"s "instances". Each instance is considered a task. for _, t := range app.Instances {  var targetAddress string        // __address__取值方式:instance.hostname和port,沒有port則默認port=80  if t.Port != nil {   targetAddress = net.JoinHostPort(t.HostName, strconv.Itoa(t.Port.Port))  } else {   targetAddress = net.JoinHostPort(t.HostName, "80")  }  target := model.LabelSet{   model.AddressLabel:  lv(targetAddress),   model.InstanceLabel: lv(t.InstanceID),   appNameLabel:                     lv(app.Name),   appInstanceHostNameLabel:         lv(t.HostName),   appInstanceHomePageURLLabel:      lv(t.HomePageURL),   appInstanceStatusPageURLLabel:    lv(t.StatusPageURL),   appInstanceHealthCheckURLLabel:   lv(t.HealthCheckURL),   appInstanceIPAddrLabel:           lv(t.IPAddr),   appInstanceVipAddressLabel:       lv(t.VipAddress),   appInstanceSecureVipAddressLabel: lv(t.SecureVipAddress),   appInstanceStatusLabel:           lv(t.Status),   appInstanceCountryIDLabel:        lv(strconv.Itoa(t.CountryID)),   appInstanceIDLabel:               lv(t.InstanceID),  }  if t.Port != nil {   target[appInstancePortLabel] = lv(strconv.Itoa(t.Port.Port))   target[appInstancePortEnabledLabel] = lv(strconv.FormatBool(t.Port.Enabled))  }  if t.SecurePort != nil {   target[appInstanceSecurePortLabel] = lv(strconv.Itoa(t.SecurePort.Port))   target[appInstanceSecurePortEnabledLabel] = lv(strconv.FormatBool(t.SecurePort.Enabled))  }  if t.DataCenterInfo != nil {   target[appInstanceDataCenterInfoNameLabel] = lv(t.DataCenterInfo.Name)   if t.DataCenterInfo.Metadata != nil {    for _, m := range t.DataCenterInfo.Metadata.Items {     ln := strutil.SanitizeLabelName(m.XMLName.Local)     target[model.LabelName(appInstanceDataCenterInfoMetadataPrefix+ln)] = lv(m.Content)    }   }  }  if t.Metadata != nil {   for _, m := range t.Metadata.Items {                // prometheus label只支持[^a-zA-Z0-9_]字符,其它非法字符都會被替換成下劃線_    ln := strutil.SanitizeLabelName(m.XMLName.Local)    target[model.LabelName(appInstanceMetadataPrefix+ln)] = lv(m.Content)   }  }  targets = append(targets, target) } return targets}

解析比較簡單,就不再分析,解析后的標簽數據如下圖:

標簽中有兩個特別說明下:

1、__address__:這個取值instance.hostnameport(默認80),所以要注意注冊到eureka上的hostname準確性,不然可能無法抓?。?/p>

2、metadata-map數據會被轉成__meta_eureka_app_instance_metadata_格式標簽,prometheus進行relabeling一般操作metadata-map,可以自定義metric_path、抓取端口等;

3、prometheuslabel只支持[a-zA-Z0-9_],其它非法字符都會被轉換成下劃線,具體參加:strutil.SanitizeLabelName(m.XMLName.Local);但是eurekametadata-map標簽含有下劃線時,注冊到eureka-server上變成雙下劃線,如下配置:

eureka:  instance:    metadata-map:      scrape_enable: true      scrape.port: 8080

通過/eureka/apps獲取如下:

總結

基于Eureka服務發現原理如下圖:

基于eureka_sd_configs服務發現協議配置創建Discoverer,并通過協程運行Discoverer.Run方法,Eureka服務發現核心邏輯封裝discovery/eureka.gofunc (d *Discovery) refresh(ctx context.Context) ([]*targetgroup.Group, error)方法中。

refresh方法中主要調用兩個方法:

1、fetchApps:定時周期從Eureka Server/eureka/apps接口拉取注冊上來的服務元數據信息;

2、targetsForApp:解析上步驟拉取的元數據信息,遍歷app下的instance,將每個instance解析成target,并將其它元數據信息轉換成target元標簽可以用于relabel_configs操作

標簽:

推薦

財富更多》

動態更多》

熱點

主站蜘蛛池模板: 91久草视频| 国产精品视频导航| 青青草一区| 日本国产在线| 国产精品无码在线看| 欧美成人综合视频| 亚洲性影院| 国产黄色片在线看| 成人毛片免费观看| A级毛片无码久久精品免费| 免费一级毛片不卡在线播放| 激情五月婷婷综合网| 欧美精品v欧洲精品| 国产精品无码AV片在线观看播放| 国产精品成人观看视频国产 | 91精品网站| 国产亚洲视频播放9000| 国产成人精品2021欧美日韩| 日韩欧美91| 欧美人与性动交a欧美精品| 国产成人无码播放| 在线看片中文字幕| 国产鲁鲁视频在线观看| 日韩av电影一区二区三区四区| 成人免费午间影院在线观看| 在线亚洲天堂| 久久久久亚洲av成人网人人软件| 亚洲天堂成人在线观看| 欧美日韩在线成人| 欧美第一页在线| 91久久天天躁狠狠躁夜夜| 国产精品成人免费视频99| 国产成年无码AⅤ片在线| 欧美精品一区在线看| 欧美日韩亚洲综合在线观看| 亚洲免费人成影院| 日韩欧美中文| 小说区 亚洲 自拍 另类| 午夜性刺激在线观看免费| 久久这里只有精品2| 久久中文字幕不卡一二区| 亚洲国产中文在线二区三区免| 亚洲成在线观看| 香蕉综合在线视频91| 丁香婷婷激情网| 国产一级精品毛片基地| 婷五月综合| 日韩国产 在线| 欧美丝袜高跟鞋一区二区| 国产成人乱码一区二区三区在线| 国产精品精品视频| 日韩人妻精品一区| 国产小视频a在线观看| 欧美亚洲国产精品第一页| 波多野结衣久久高清免费| 色哟哟国产成人精品| 在线亚洲小视频| 91九色国产porny| 欧美a在线| 欧洲熟妇精品视频| 亚洲综合色区在线播放2019| 777午夜精品电影免费看| 热re99久久精品国99热| 色综合中文| 试看120秒男女啪啪免费| 午夜无码一区二区三区| 日本三区视频| 日韩高清在线观看不卡一区二区| 午夜福利亚洲精品| 日本三级精品| 欧美精品1区2区| 97国产在线视频| 日韩成人在线网站| 国产精品开放后亚洲| 亚洲AV无码不卡无码| 久久成人国产精品免费软件| 国产免费精彩视频| 欧美成人看片一区二区三区 | 国产在线一区视频| 99视频精品在线观看| 熟妇无码人妻| 国产综合在线观看视频|