opentelemetry实践

场景描述

根据 open-telemetry 提供的exampleshttps://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/examples/demo

假设我们有两个服务,一个是demo-server,一个是demo-client,demo-client会周期性调用demo-server,我们希望可以采集到demo-server与demo-client之间的监控数据,包括请求延迟和请求数统计(demo里面也提供了如何把数据接入到分布式调用链系统上,比如jaegre)

服务架构图

基于opentelemetry我们实现的架构图大概如下

如果是我们直接使用Promutheus的话,可能是如下的架构图

 

 

如果我们想Demo-Server和Demo-Client使用推数据的方式的话,可以使用PushGateway,如下

这里补充下,那这样的话,使用Opentelemetry的好处式啥呢?其实就是标准化了,比如我们现在想接入jaegre来做分布式调用链分析,如果有Opentelemetry的话,我们也是一样Demo-Server和Demo-Client直接上报给Opentelemetry Collector就可以了,也不用引入新的SDK;没有opentelemetry的话,我们就需要俩套SDK,而且也没有一个标准化

 

Docker 部署

Opentelemetry项目提供了一个docker-compose的启动方案,具体可以参考:https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/examples/demo

部署之后,我们可以通过访问promutheus,看到相应的数据收集

k8s 部署

基于官网提供的dmeo (https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/examples/demo),适配到k8s。

代码地址:https://github.com/khalid-jobs/khalid.project/tree/main/opentelemetry-k8s

为了方便,下面的服务暴露都使用nodePort进行暴露

1. 在k8s上搭建promutheus + grafna

cd promutheus_grafna
# 部署promutheus
kubectl apply -f prometheus-sa.yaml
kubectl apply -f prometheus-cm.yaml
kubectl apply -f prometheus-deployment.yaml
kubectl apply -f prometheus-service.yaml
# 部署grafna
kubectl apply -f grafna.yaml
kubectl apply -f grafna-service.yaml

2. 在k8s 部署collector

kubectl apply -f otel-collector/deploy.yaml

3. 部署demo-server 和 demo-client

# 部署demo-server
cd server
make image
kubectl apply -f deploy.yaml # 注意配置好节点和镜像地址
# 部署demo-client也是类似

4. promutheus收集collector

 

 

参考

1. Opentelemetry Collector的配置和使用 - charlieroro - 博客园 定义的推送

2. 例子说明:https://www.cnblogs.com/charlieroro/p/13883602.html (collector 包含了exporter之类的)

3. Getting Started | OpenTelemetry

4. promutheus+grafana

  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值