亚洲乱淫 I 香蕉成人av I 哺乳期av I 欧美播放器 I 成人私密视频 I 福利小导航 I 男人都懂的网站 I 日韩av网址在线观看 I 91超碰成人 I 色噜噜久久 I av无限看 I 国产综合在线播放 I 亚洲综合免费观看高清完整版 I 双腿张开被9个男人调教 I 欧美裸体xxx I 在线午夜电影 I 日韩女女同性aa女同 I 成人91 I 日本中文字幕免费 I 91久久久国产精品 I 免费观看黄色大片 I 伊人天堂视频 I 欧美日韩国产999 I 操人黄色 I 久久久久久性高 I 亚洲综合熟女久久久30p I 视频二区最新视频 I 亚洲国产成人二区 I 岛国黄色专区 I 亚洲www. I 欧美特黄视频在线观看 I 黄色三级软件 I 国产9页 I 久久动漫av I 免费看18禁止观看黄网站 I 青青久在线视观看视 I 欧美一夜爽爽爽爽爽爽 I 波多野结衣vs黑人 I 国产最爽乱淫视频免费

天天觀焦點:【云原生 ? 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準確性,不然可能無法抓取;

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操作

標簽:

推薦

財富更多》

動態更多》

熱點

主站蜘蛛池模板: 精品人妻无码专区在中文字幕 | 亚洲中亚洲中文字幕无线乱码 | av国语| 久久精品人人做人人综合试看 | 久久久人人人婷婷色东京热 | 天堂色视频| 可以免费看av的网站 | 国产av电影区二区三区曰曰骚网 | 日本乱淫| www.一区二区三区在线 | 欧洲 | 婷婷五月深深久久精品 | 久久av无码精品人妻系列果冻传媒 | 中文字幕不卡在线播放 | 亚洲国产在 | 成人免费乱码大片a毛片 | www.xxx久久| 欧美一级黄色网 | 狠狠婷婷综合久久久久久 | 国产一区二区日本欧美精品久久久 | 国产成人片视频一区二区 | 久久久九九精品国产毛片a片 | 天天做天天爱夜夜夜爽毛片 | 久久人人爽人人爽人人片av免费 | 国产无线乱码一区二三区 | 极品美女高潮呻吟国产剧情 | 黄色av高清 | 欧美老熟妇乱人伦人妻 | 国产成人涩涩涩视频在线观看 | 日本少妇丰满大bbb的小乳沟 | 欧美精品一区二区三区免费视频 | 蜜臀av人妻国产精品建身房 | 免费午夜福利在线观看不卡 | 伊人成年网站综合网 | 国产在线播放网站 | 天堂资源在线播放 | youjizz.com亚洲 | 欧美成人精品三级在线观看 | 婷婷久久久久久 | 国产日韩在线视看高清视频手机 | www噜噜偷拍在线视频 | 久久精品影视免费观看 | 国产又粗又大又爽的视频 | 亚洲中国久久精品无码 | 久久久久久久久久久综合 | 久草aⅴ| 日本久操 | 99青青草 | 狠狠爱五月丁香亚洲综合 | 午夜一级黄色片 | 欧美阿v天堂视频在99线 | 午夜精品网 | 日韩精品一卡2卡3卡4卡新区 | 欧美精品一区二区三区四区 | 亚洲人色婷婷成人网站在线观看 | 国产精品久久久久久久久久辛辛 | 三集黄色片| 国内精品久久久久影院蜜芽 | 婷婷久久网 | 99久久影院| 国产精品天干天干在线观看澳门 | 亚洲一区免费视频 | 久久久久久综合岛国免费观看 | 天天性综合| 无码精品人妻一区二区三区涩爱 | 黄色大片在线看 | 欧美精品videosex极品 | 欧美综合社区 | 亚州男人天堂 | 欧美爽爽 | 国产丝袜一区二区三区免费视频 | 美女黄网站18禁免费看 | 色琪琪一区二区三区亚洲区 | 精品久久久久中文字幕一区 | 欧美日韩亚洲天堂 | 正在播放亚洲 | 无码毛片视频一区二区本码 | www.yeyecao| 欧美巨大xxxx做受中文字幕 | 中国精品无码免费专区午夜 | 成人性生活毛片 | 日本性欧美 | 男同志毛片特黄毛片 | 免费福利在线观看 | 久久不见久久见免费影院 | 天堂在线网| juy416友田真希中文字幕 | 中文字幕奈奈美被公侵犯 | 麻豆人人妻人人妻人人片av | 亚洲精品乱码久久久久久蜜桃欧美 | 国产亚洲欧美在线观看三区 | 亚洲第一中文av | 麻豆日产精品卡2卡3卡4卡5卡 | 免费无码黄真人影片在线 | 亚洲日本中文字幕乱码中文 | 国产情侣作爱视频免费观看 | 成在线人免费视频 | 超碰在线亚洲 | 性猛交富婆xxxⅹ乱大交 | 日日噜噜噜夜夜爽爽狠狠小说 |