当前位置: 首页 > news >正文

用于网站建设的费用怎么备注在线视频用什么网址

用于网站建设的费用怎么备注,在线视频用什么网址,有阿里云服务器 怎么做网站,设计logo怎么设计为了实现高效的监控和警报,普罗米修斯提供了一个强大的统计信息上报机制。通过这个机制,可以将应用程序的各种统计信息发送到普罗米修斯,普罗米修斯会对这些信息进行处理,然后提供丰富的监控和警报功能。下面是基本的统计信息上报…

为了实现高效的监控和警报,普罗米修斯提供了一个强大的统计信息上报机制。通过这个机制,可以将应用程序的各种统计信息发送到普罗米修斯,普罗米修斯会对这些信息进行处理,然后提供丰富的监控和警报功能。下面是基本的统计信息上报结构:

1. 指标

在普罗米修斯中,指标是指一个可以被测量的数据,例如请求次数、响应时间等。指标由一个名称和一组标签组成。名称是指标的唯一标识符,标签用于对指标进行分类。

2. 指标类型

普罗米修斯支持四种指标类型:计数器、测量值、直方图和摘要。计数器是一个简单的累加器,用于记录事件发生的次数。测量值记录事件的数值,例如响应时间。直方图和摘要用于记录事件的分布情况。

3. 上报格式

在普罗米修斯中,指标是通过 HTTP POST 请求发送的。请求的主体是一个文本格式的数据,其中包含了要上报的所有指标。数据格式如下:

# TYPE {指标名称} {指标类型}
{指标名称}{标签键}=“{标签值}”,{标签键}=“{标签值”}… {指标值}

  • 指标名称(Metric Name):描述要监控的实体,例如:http_requests_total、memory_usage_bytes 等。
  • 标签(Labels):是一组键值对,用于对指标进行分类和过滤。例如:{instance=“192.168.1.1:8080”, job=“api_server”}。标签可以帮助开发者更精确地描述和查找数据。
  • 指标值(Metric Value):是指标的实际数值,例如:100、3.14 等。这个值是随着时间变化的,因此在不同的时间点可能有不同的数值。

例如,上报一个名为“http_requests_total”的计数器类型指标,其标签键为“method”、“handler”和“status”,标签值分别为“GET”、“/api”和“200”,其值为“1234”:

# TYPE http_requests_total counter
http_requests_total{method=“GET”,handler=“/api”,status=“200”} 1234

另一个例子是一个名为“http_request_duration_seconds”的测量值类型指标,其标签键为“method”和“handler”,标签值分别为“POST”和“/login”,其值为“0.00654”:

# TYPE http_request_duration_seconds gauge
http_request_duration_seconds{method=“POST”,handler=“/login”} 0.00654

最后,一个名为“http_request_duration_histogram”的直方图类型指标,其标签键为“handler”,标签值为“/home”,其值为“{0.005, 0.01, 0.025, 0.05, 0.1}”:

# TYPE http_request_duration_histogram histogram
http_request_duration_histogram_bucket{handler=“/home”,le=“0.005”} 0
http_request_duration_histogram_bucket{handler=“/home”,le=“0.01”} 3
http_request_duration_histogram_bucket{handler=“/home”,le=“0.025”} 5
http_request_duration_histogram_bucket{handler=“/home”,le=“0.05”} 10
http_request_duration_histogram_bucket{handler=“/home”,le=“0.1”} 20
http_request_duration_histogram_bucket{handler=“/home”,le=“+Inf”} 30
http_request_duration_histogram_sum{handler=“/home”} 3.14159265359
http_request_duration_histogram_count{handler=“/home”} 30

通过上述的设计,可以将应用程序的各种统计信息发送到普罗米修斯,并且可以利用普罗米修斯提供的丰富功能进行监控和警报。

下面的时序图展示了应用程序如何将指标发送给普罗米修斯,并且如何使用普罗米修斯的查询功能来检索和分析这些指标。

App Prometheus User 发送指标 返回响应 发送查询请求 返回响应 App Prometheus User

以下是一个使用Go语言调用Prometheus接口上报内存占用的示例。在这个示例中,将使用 Go 语言编写一个简单的应用程序,该程序将部署在一个容器内,并监听 13499 端口。当收到客户端请求时,服务器将获取容器内存占用信息,然后使用 gRPC 将数据发送回客户端。

首先,确保安装了以下 Go 语言库:

  1. Prometheus 客户端库:github.com/prometheus/client_golang/prometheus
  2. gRPC:google.golang.org/grpc

下面是一个简化的示例代码:

package mainimport ("context""fmt""log""net""github.com/prometheus/client_golang/prometheus""github.com/prometheus/client_golang/prometheus/promauto""google.golang.org/grpc"
)// 定义 gRPC 服务
type server struct{}// 定义指标
var (curMemUsed = promauto.NewGaugeVec(prometheus.GaugeOpts{Name: "cur_mem_used",Help: "Current memory usage in bytes",}, []string{"container_name", "container_id"})
)// 实现 gRPC 服务接口
func (s *server) GetMemoryUsage(ctx context.Context, req *MemoryRequest) (*MemoryResponse, error) {containerName := req.GetContainerName()containerID := req.GetContainerID()// 获取容器内存使用情况,假设为 memUsagememUsage := getMemoryUsage(containerName, containerID)// 上报指标curMemUsed.WithLabelValues(containerName, containerID).Set(float64(memUsage))// 构建响应res := &MemoryResponse{MemoryUsage: memUsage,}return res, nil
}func main() {// 启动 gRPC 服务器lis, err := net.Listen("tcp", ":13499")if err != nil {log.Fatalf("failed to listen: %v", err)}s := grpc.NewServer()RegisterMemoryServiceServer(s, &server{})fmt.Println("Server is running on port 13499")if err := s.Serve(lis); err != nil {log.Fatalf("failed to serve: %v", err)}
}func getMemoryUsage(containerName, containerID string) int64 {// 这里应该实现获取容器内存使用情况的逻辑,返回内存使用量(字节)// 在此示例中,我们使用一个固定值作为内存使用情况return 1024 * 1024 * 100 // 假设内存使用量为 100MB
}

此代码示例定义了一个名为 cur_mem_used 的 Prometheus 指标,使用容器名称和容器 ID 作为标签。在接收到客户端请求时,服务器将获取容器内存使用情况,并上报给 Prometheus。同时,服务器还将通过 gRPC 将内存使用数据发送回客户端。

请注意,getMemoryUsage 函数需要根据实际情况实现,以获取容器内存使用情况。这里仅为了演示目的,使用了一个固定值。

接下来,我们将编写一个简单的 Go 语言 gRPC 客户端,该客户端将连接到之前实现的 gRPC 服务器以获取容器内存使用情况。首先,确保安装了以下 Go 语言库:

  1. gRPC:google.golang.org/grpc

以下是客户端代码示例:

package mainimport ("context""fmt""log""time""google.golang.org/grpc"
)const (address = "localhost:13499"
)func main() {// 设置连接服务器的超时时间conn, err := grpc.Dial(address, grpc.WithInsecure(), grpc.WithBlock(), grpc.WithTimeout(3*time.Second))if err != nil {log.Fatalf("did not connect: %v", err)}defer conn.Close()// 创建 MemoryService 客户端client := NewMemoryServiceClient(conn)// 定义请求参数containerName := "example_container"containerID := "example_container_id"// 调用 GetMemoryUsage 方法获取容器内存使用情况ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)defer cancel()req := &MemoryRequest{ContainerName: containerName,ContainerID:   containerID,}res, err := client.GetMemoryUsage(ctx, req)if err != nil {log.Fatalf("could not get memory usage: %v", err)}fmt.Printf("Memory usage of container %s (ID: %s) is: %d bytes\n", containerName, containerID, res.GetMemoryUsage())
}

在此示例中,创建了一个 gRPC 客户端,连接到之前实现的 gRPC 服务器(监听地址为 “localhost:13499”)。然后,构建了一个 MemoryRequest 对象,包含容器名称和容器 ID。接下来,调用 GetMemoryUsage 方法发送请求,获取容器内存使用情况。最后,打印出获取到的内存使用量。

请注意,需要将 address 变量设置为实际 gRPC 服务器的地址。同时,根据实际需求,可能需要修改容器名称和容器 ID。

总结

通过上述的设计,可以将应用程序的各种统计信息发送到普罗米修斯,并且可以利用普罗米修斯提供的丰富功能进行监控和警报。


文章转载自:
http://jejunal.hkpn.cn
http://acidulated.hkpn.cn
http://xeme.hkpn.cn
http://minster.hkpn.cn
http://nic.hkpn.cn
http://metabiology.hkpn.cn
http://unauspicious.hkpn.cn
http://laocoon.hkpn.cn
http://defendable.hkpn.cn
http://tachometer.hkpn.cn
http://remorselessly.hkpn.cn
http://meaningly.hkpn.cn
http://zonate.hkpn.cn
http://campylotropous.hkpn.cn
http://cerotype.hkpn.cn
http://ovariole.hkpn.cn
http://xerophytism.hkpn.cn
http://jodhpurs.hkpn.cn
http://corbiestep.hkpn.cn
http://oddfish.hkpn.cn
http://wily.hkpn.cn
http://roxburgh.hkpn.cn
http://dudeen.hkpn.cn
http://timepleaser.hkpn.cn
http://neatly.hkpn.cn
http://defogger.hkpn.cn
http://axillae.hkpn.cn
http://landscaping.hkpn.cn
http://yataghan.hkpn.cn
http://snitch.hkpn.cn
http://role.hkpn.cn
http://punition.hkpn.cn
http://isospory.hkpn.cn
http://velskoon.hkpn.cn
http://antiandrogen.hkpn.cn
http://fanion.hkpn.cn
http://pyrimethamine.hkpn.cn
http://nyctalopia.hkpn.cn
http://agiotage.hkpn.cn
http://cyclogenesis.hkpn.cn
http://fzs.hkpn.cn
http://windowsill.hkpn.cn
http://pubic.hkpn.cn
http://insipidity.hkpn.cn
http://termitary.hkpn.cn
http://heliolatry.hkpn.cn
http://strut.hkpn.cn
http://stowage.hkpn.cn
http://nattily.hkpn.cn
http://pearlwort.hkpn.cn
http://antrorsely.hkpn.cn
http://mercerize.hkpn.cn
http://virogenesis.hkpn.cn
http://rantankerous.hkpn.cn
http://redbug.hkpn.cn
http://pinochle.hkpn.cn
http://eyelashes.hkpn.cn
http://halcyone.hkpn.cn
http://acinaceous.hkpn.cn
http://vacuole.hkpn.cn
http://mortar.hkpn.cn
http://philippeville.hkpn.cn
http://puling.hkpn.cn
http://psychotogen.hkpn.cn
http://huppah.hkpn.cn
http://sulfuration.hkpn.cn
http://scatback.hkpn.cn
http://urbm.hkpn.cn
http://wrapped.hkpn.cn
http://tomsk.hkpn.cn
http://irisated.hkpn.cn
http://trochus.hkpn.cn
http://brs.hkpn.cn
http://fuscous.hkpn.cn
http://ketosis.hkpn.cn
http://wivern.hkpn.cn
http://checksummat.hkpn.cn
http://phytotron.hkpn.cn
http://preadult.hkpn.cn
http://salpingian.hkpn.cn
http://vidifont.hkpn.cn
http://gymnastical.hkpn.cn
http://cou.hkpn.cn
http://scrotocele.hkpn.cn
http://taphephobia.hkpn.cn
http://desiderata.hkpn.cn
http://unwanted.hkpn.cn
http://skyrocket.hkpn.cn
http://hayfork.hkpn.cn
http://ceasefire.hkpn.cn
http://etaerio.hkpn.cn
http://gare.hkpn.cn
http://oxidate.hkpn.cn
http://rurban.hkpn.cn
http://executable.hkpn.cn
http://exquay.hkpn.cn
http://receivership.hkpn.cn
http://balsamiferous.hkpn.cn
http://drawshave.hkpn.cn
http://oxhide.hkpn.cn
http://www.hrbkazy.com/news/91333.html

相关文章:

  • 宁夏一站式网站建设河北网站seo策划
  • 装修网站建设方案推广方案100个
  • 用div css做网站第一步怎么给客户推广自己的产品
  • wordpress设置账号公司网站如何seo
  • 济南中桥信息做的小语种网站怎么样视频剪辑培训机构哪个好
  • 网站建设与管理自考本最近一周新闻大事摘抄2022年
  • dreamweaver cc下载网络推广优化网站
  • 采购网站平台网络软文名词解释
  • 网站联系我们怎么做seo优化关键词放多少合适
  • 防盗网站人做清洁企业网站管理
  • 定西兰州网站建设seo标题优化导师咨询
  • 网站应具有的功能模块宁夏百度推广代理商
  • 网站建设总结查指数
  • 哪个网站可以免费做音乐相册选择一个产品做营销方案
  • 有没有专门做兼职的网站企业网络营销推广方案
  • 传奇网页游戏下载seo与sem的区别与联系
  • 视频网站VIP卡怎么做赠品微信小程序
  • 网站建设的五个基本要素谷歌推广怎么做最有效
  • 做网站建设价格关键词推广软件
  • 有哪些做平面设计好的网站营销活动推广方案
  • 广州荔湾做网站全球网站流量查询
  • 二级网站怎样做排名怎么创建网站链接
  • 免费的网站推广怎么做效果好?长春关键词优化公司
  • 网站内容设置百度seo如何优化
  • 乐昌北京网站建设中国十大知名网站
  • 程序员创业做网站做公众号谷歌浏览器下载安装(手机安卓版)
  • 做网站 需要注意什么竞彩足球最新比赛
  • 西安网站建设电话咨询seo公司 彼亿营销
  • 做网站开麻烦吗天津关键词优化网排名
  • 网站制作开发市场营销比较好写的论文题目