前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Prometheus基于自动服务发现获取peer/orderer监控数据

Prometheus基于自动服务发现获取peer/orderer监控数据

原创
作者头像
小亮
发布2019-06-11 19:37:15
1.5K0
发布2019-06-11 19:37:15
举报
文章被收录于专栏:腾讯云区块链腾讯云区块链

Fabric 1.4支持通过pometheus获取到Fabric网络中的一些状态数据。当Fabric部署在K8s环境中的时候,prometheus可以配置成基于自动服务发现获取到所有的Fabric peer和 orderer的状态数据。

具体配置步骤如下 :

1. 配置ClusterRole并设置相应的权限

apiVersion: rbac.authorization.k8s.io/v1

kind: ClusterRole

metadata:

name: fabricprometheus

rules:

- apiGroups: [""]

resources:

- pods

verbs: ["get", "list", "watch"]

2. 创建ServiceAccount

apiVersion: v1

kind: ServiceAccount

metadata:

name: fabricprometheus

namespace: default

3. ServiceAccount ClusterRole绑定

apiVersion: rbac.authorization.k8s.io/v1

kind: ClusterRoleBinding

metadata:

name: fabricprometheus

roleRef:

apiGroup: rbac.authorization.k8s.io

kind: ClusterRole

name: fabricprometheus

subjects:

- kind: ServiceAccount

name: fabricprometheus

namespace: default

4. ConfigMap配置prometheus配置文件

apiVersion: v1

kind: ConfigMap

metadata:

name: fabric-prometheus-config

namespace: default

data:

prometheus.yml: |

global:

scrape_interval: 15s

evaluation_interval: 15s

scrape_configs:

- job_name: 'fabric-kubernetes-pods'

kubernetes_sd_configs:

- role: pod

relabel_configs:

- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]

action: keep

regex: true

- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]

action: replace

target_label: __metrics_path__

regex: (.+)

- source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]

action: replace

regex: ([^:]+)(?::\d+)?;(\d+)

replacement: $1:$2

target_label: __address__

- action: labelmap

regex: __meta_kubernetes_pod_label_(.+)

- source_labels: [__meta_kubernetes_namespace]

action: replace

target_label: kubernetes_namespace

- source_labels: [__meta_kubernetes_pod_name]

action: replace

target_label: kubernetes_pod_name

- source_labels: [__meta_kubernetes_pod_name]

action: replace

target_label: pod_name

5. Prometheus deploy 配置

apiVersion: apps/v1beta2

kind: Deployment

metadata:

labels:

name: fabric-prometheus-deployment

name: fabric-prometheus

namespace: default

spec:

replicas: 1

selector:

matchLabels:

app: fabric-prometheus

template:

metadata:

labels:

app: fabric-prometheus

spec:

containers:

- image: prom/prometheus:latest

name: fabric-prometheus

command:

- "/bin/prometheus"

args:

- "--config.file=/etc/prometheus/prometheus.yml"

- "--storage.tsdb.path=/prometheus"

- "--storage.tsdb.retention=24h"

ports:

- containerPort: 9090

protocol: TCP

volumeMounts:

- mountPath: "/prometheus"

name: data

- mountPath: "/etc/prometheus"

name: config-volume

resources:

requests:

cpu: 100m

memory: 100Mi

limits:

cpu: 500m

memory: 2500Mi

serviceAccountName: fabricprometheus

volumes:

- name: data

emptyDir: {}

- name: config-volume

configMap:

name: fabric-prometheus-config

6. Service配置

kind: Service

apiVersion: v1

metadata:

labels:

app: fabric-prometheus

name: fabric-prometheus

namespace: default

spec:

type: ClusterIP

ports:

- port: 9090

protocol: TCP

targetPort: 9090

selector:

app: fabric-prometheus

7. 在需要查询的peer/orderer节点增加如下配置

template:

metadata:

annotations:

prometheus.io/path: /metrics

prometheus.io/port: "9443"

prometheus.io/scrape: "true"

8. 查询prometheus数据

curl http://xx.xx.xx.xx:9090/api/v1/query -X POST -H "application/x-www-form-urlencoded" -d 'query=up'

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
容器服务
腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档