首页 > 其他分享 >使用Prometheus和Grafana监控Envoy Mesh

使用Prometheus和Grafana监控Envoy Mesh

时间:2022-10-24 11:44:25浏览次数:60  
标签:http name Envoy envoy Grafana Prometheus filters address type

环境说明

  • 宿主机地址为:192,.168.174.103
  • envoy:Front Proxy,地址为172.31.10.2
  • webserver01:第一个后端服务
  • webserver01-sidecar:第一个后端服务的Sidecar Proxy,地址为172.31.10.11
  • webserver02:第二个后端服务
  • webserver02-sidecar:第二个后端服务的Sidecar Proxy,地址为172.31.10.12
  • statsd_exporter: 地址为172.31.10.20
  • prometheus: 地址为172.31.10.22
  • grafana: 地址为172.31.10.23

准备配置文件

front-envoy.yaml

node:
id: front-envoy
cluster: mycluster

admin:
profile_path: /tmp/envoy.prof
access_log_path: /tmp/admin_access.log
address:
socket_address:
address: 0.0.0.0
port_value: 9901

layered_runtime:
layers:
- name: admin
admin_layer: {}

stats_sinks:
- name: envoy.stat_sinks.statsd
typed_config:
"@type": type.googleapis.com/envoy.config.metrics.v3.StatsdSink
tcp_cluster_name: statsd_exporter
prefix: front-envoy

static_resources:
listeners:
- name: listener_0
address:
socket_address: { address: 0.0.0.0, port_value: 80 }
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
stat_prefix: ingress_http
codec_type: AUTO
route_config:
name: local_route
virtual_hosts:
- name: service
domains: ["*"]
routes:
- match:
prefix: "/"
route:
cluster: wgs
retry_policy:
retry_on: "5xx"
num_retries: 3
timeout: 1s
http_filters:
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router

clusters:
- name: wgs
connect_timeout: 0.25s
type: strict_dns
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: wgs
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: myservice
port_value: 80

- name: statsd_exporter
connect_timeout: 0.25s
type: strict_dns
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: statsd_exporter
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: statsd_exporter
port_value: 9125

envoy-sidecar-proxy-01.yaml

node:
id: webserver01
cluster: mycluster

stats_sinks:
- name: envoy.stat_sinks.statsd
typed_config:
"@type": type.googleapis.com/envoy.config.metrics.v3.StatsdSink
tcp_cluster_name: statsd_exporter
prefix: webserver01

admin:
profile_path: /tmp/envoy.prof
access_log_path: /tmp/admin_access.log
address:
socket_address:
address: 0.0.0.0
port_value: 9901

layered_runtime:
layers:
- name: admin
admin_layer: {}

static_resources:
listeners:
- name: listener_0
address:
socket_address: { address: 0.0.0.0, port_value: 80 }
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
stat_prefix: ingress_http
codec_type: AUTO
route_config:
name: local_route
virtual_hosts:
- name: service
domains: ["*"]
routes:
- match:
prefix: "/"
route:
cluster: webserver-01
http_filters:
- name: envoy.filters.http.fault
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.fault.v3.HTTPFault
max_active_faults: 100
abort:
http_status: 503
percentage:
numerator: 10
denominator: HUNDRED
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router


clusters:
- name: webserver-01
connect_timeout: 0.25s
type: strict_dns
lb_policy: round_robin
load_assignment:
cluster_name: webserver-01
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: 127.0.0.1
port_value: 8080

- name: statsd_exporter
connect_timeout: 0.25s
type: strict_dns
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: statsd_exporter
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: statsd_exporter
port_value: 9125

envoy-sidecar-proxy-02.yaml

node:
id: webserver02
cluster: mycluster

stats_sinks:
- name: envoy.stat_sinks.statsd
typed_config:
"@type": type.googleapis.com/envoy.config.metrics.v3.StatsdSink
tcp_cluster_name: statsd_exporter
prefix: webserver02

admin:
profile_path: /tmp/envoy.prof
access_log_path: /tmp/admin_access.log
address:
socket_address:
address: 0.0.0.0
port_value: 9901

layered_runtime:
layers:
- name: admin
admin_layer: {}

static_resources:
listeners:
- name: listener_0
address:
socket_address: { address: 0.0.0.0, port_value: 80 }
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
stat_prefix: ingress_http
codec_type: AUTO
route_config:
name: local_route
virtual_hosts:
- name: service
domains: ["*"]
routes:
- match:
prefix: "/"
route:
cluster: webserver-02
http_filters:
- name: envoy.filters.http.fault
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.fault.v3.HTTPFault
max_active_faults: 100
delay:
fixed_delay: 2s
percentage:
numerator: 10
denominator: HUNDRED
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router


clusters:
- name: webserver-02
connect_timeout: 0.25s
type: strict_dns
lb_policy: round_robin
load_assignment:
cluster_name: webserver-02
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: 127.0.0.1
port_value: 8080

- name: statsd_exporter
connect_timeout: 0.25s
type: STRICT_DNS
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: statsd_exporter
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: statsd_exporter
port_value: 9125

prometheus配置文件

global:
scrape_interval: 15s
evaluation_interval: 15s

scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']

- job_name: 'grafana'
static_configs:
- targets: ['grafana:3000']

- job_name: 'statsd'
scrape_interval: 5s
static_configs:
- targets: ['statsd_exporter:9102']
labels:
group: 'services'

grafana.ini

instance_name = "grafana"

[security]
admin_user = admin
admin_password = admin

docker-compose.yaml

version: '3.3'

services:
envoy:
image: envoyproxy/envoy:v1.23-latest
volumes:
- ./front-envoy.yaml:/etc/envoy/envoy.yaml
networks:
envoymesh:
ipv4_address: 172.31.10.2
aliases:
- front-proxy
expose:
- "80"
- "9901"
ports:
- "80:80"
- "9901:9901"

webserver01-sidecar:
image: envoyproxy/envoy:v1.23-latest
volumes:
- ./webserver01/envoy-sidecar-proxy-01.yaml:/etc/envoy/envoy.yaml
hostname: webserver01
networks:
envoymesh:
ipv4_address: 172.31.10.11
aliases:
- webserver01-sidecar
- myservice

webserver01:
image: tomcat:9.0-jre8-alpine
network_mode: "service:webserver01-sidecar"
depends_on:
- webserver01-sidecar

webserver02-sidecar:
image: envoyproxy/envoy:v1.23-latest
volumes:
- ./webserver02/envoy-sidecar-proxy-02.yaml:/etc/envoy/envoy.yaml
hostname: webserver02
networks:
envoymesh:
ipv4_address: 172.31.10.12
aliases:
- webserver02-sidecar
- myservice

webserver02:
image: tomcat:9.0-jre8-alpine
network_mode: "service:webserver02-sidecar"
depends_on:
- webserver02-sidecar

statsd_exporter:
image: prom/statsd-exporter:v0.22.8
networks:
envoymesh:
ipv4_address: 172.31.10.20
aliases:
- statsd_exporter
ports:
- 9125:9125
- 9102:9102

prometheus:
image: prom/prometheus:v2.37.1
volumes:
- "./prometheus/config.yaml:/etc/prometheus.yaml"
networks:
envoymesh:
ipv4_address: 172.31.10.22
aliases:
- prometheus
ports:
- 9090:9090
command: "--config.file=/etc/prometheus.yaml"

grafana:
image: grafana/grafana:9.1.5
volumes:
- "./grafana/grafana.ini:/etc/grafana/grafana.ini"
networks:
envoymesh:
ipv4_address: 172.31.10.23
aliases:
- grafana
ports:
- 3000:3000


networks:
envoymesh:
driver: bridge
ipam:
config:
- subnet: 172.31.10.0/24

运行服务

# docker-compose up

prometheus

访问Prometheus

使用Prometheus和Grafana监控Envoy Mesh_ide

查看envoy metrics

front_envoy

使用Prometheus和Grafana监控Envoy Mesh_.net_02

webserver01

使用Prometheus和Grafana监控Envoy Mesh_ide_03

webserver02

使用Prometheus和Grafana监控Envoy Mesh_后端服务_04

grafana

添加数据源

使用Prometheus和Grafana监控Envoy Mesh_后端服务_05

添加监控项

使用Prometheus和Grafana监控Envoy Mesh_.net_06

 



标签:http,name,Envoy,envoy,Grafana,Prometheus,filters,address,type
From: https://blog.51cto.com/u_4028786/5789190

相关文章

  • Envoy 分布式追踪
    追踪概述分布式跟踪允许开发人员在大型面向服务的架构中获得调用流的可视化。它对于理解序列化、并行性和延迟来源非常重要。Envoy支持与系统范围跟踪相关的三个功能:请求I......
  • Prometheus之Cadvisor实现pod资源监控
    一Cadvisor介绍GitHub地址:https://github.com/google/cadvisorcadvisor由谷歌开源,cadvisor不仅可以搜集一台机器上所有运行的容器信息,还提供基础查询界面和http接口,方便其......
  • Prometheus之Alertmanager介绍
    一告警功能概述Prometheus对指标的收集、存储同告警能力分属于PrometheusServer和Alertmanager连个独立的组件,前者仅负责基于告警规则生成告警通知,具体的告警操作则由后者......
  • Prometheus之blackbox_exporter使用帮助
    root@node-02:~#/usr/local/blackbox_exporter/blackbox_exporter--helpusage:blackbox_exporter[<flags>]Flags:-h,--help#显示上下文相关的帮助(也可以尝试-......
  • Prometheus之部署blackbox_exporter
    一blackboxexporter介绍GitHub地址:https://github.com/prometheus/blackbox_exporterblackbox_exporter是Prometheuse官方提供的一个exporter,可以通过HTTP、HTTPS、DNS、T......
  • Prometheus之blackbox exporter实现URL监控
    一URL监控配置1.1修改PrometheusServer配置文件root@prometheus-01:~#cat/usr/local/prometheus/prometheus.yml#网站监控-job_name:'http_status'metrics_pa......
  • grafana钉钉告警
    一设置钉钉机器人二设置grafana 三验证告警信息......
  • grafana邮件告警
    一修改grafana.ini~#cat/etc/grafana/grafana.ini####################################SMTP/Emailing##########################[smtp]enabled=truehost=smtp.......
  • Envoy部署
    部署Envoy的常用方法镜像方式部署Envoy项目为多种平台(例如amd64和arm64等)维护有相应的DockerImage,我们可按需猎取相应镜像后以容器形式运行Envoy,而且它们存在以下几种变化......
  • Envoy 状态统计
    Envoy状态统计Envoy运行过程中会生成大量的统计数据,这些统计数据大体可以分为三类下游:与传入Envoy的连接相关的统计信息,主要由侦听器、HTTP连接管理器和TCP代理过滤器等生成......