分类 prometheus 中的文章

Prometheus监控k8s(三)——业务指标采集

背景 由于容器化和微服务的大力发展,Kubernetes基本已经统一了容器管理方案,当我们使用Kubernetes来进行容器化管理的时候,全面监控Kubernetes也就成了我们第一个需要探索的问题。我们需要监控kubernetes的ingress、service、deployment、pod……等等服务,以达到随时掌握Kubernetes集群的内部状况。 此文章也是Prometheus监控系列的第三篇,具体描述了在Kubernetes中使用Prometheus来采集业务指标。多数为思想指导,会列出两个例子。第一个例子是针对部署在Kubernetes中的服务,另外一个例子是非Kubernetes部署的服务。前者为使用“动态采集”,后者使用“静态采集”。 概念 要使用Prometheus实现自动采集业务指标数据真的非常简单,只需要2步 1、业务侧实现一个接口,返回Prometheus规范化数据,如下: traefik_entrypoint_requests_total{code="302",entrypoint="https",method="HEAD",protocol="http"} 1 traefik_entrypoint_requests_total{code="302",entrypoint="https",method="POST",protocol="http"} 1 traefik_entrypoint_requests_total{code="304",entrypoint="http",method="GET",protocol="http"} 15 traefik_entrypoint_requests_total{code="304",entrypoint="https",method="GET",protocol="http"} 5951 traefik_entrypoint_requests_total{code="400",entrypoint="https",method="GET",protocol="http"} 149 traefik_entrypoint_requests_total{code="403",entrypoint="http",method="GET",protocol="http"} 2 traefik_entrypoint_requests_total{code="403",entrypoint="https",method="HEAD",protocol="http"} 2 traefik_entrypoint_requests_total{code="404",entrypoint="http",method="GET",protocol="http"} 680 traefik_entrypoint_requests_total{code="404",entrypoint="http",method="HEAD",protocol="http"} 15 traefik_entrypoint_requests_total{code="404",entrypoint="http",method="POST",protocol="http"} 674 每行代表一个监控项,以KEY VALUE形式返回,KEY可以带上0个或多个属性,多个属性以 “,”分隔。在Prometheus中查询数据的时候,可以用这些属性作为筛选条件。 Key中不能包含 “-” 等特殊字符,最好使用 “_” 。 2、运维侧部署的时候,在svc上带上3个标签……

阅读全文

Prometheus监控k8s(二)——监控部署

背景 由于容器化和微服务的大力发展,Kubernetes基本已经统一了容器管理方案,当我们使用Kubernetes来进行容器化管理的时候,全面监控Kubernetes也就成了我们第一个需要探索的问题。我们需要监控kubernetes的ingress、service、deployment、pod……等等服务,已达到随时掌握Kubernetes集群的内部状况。 此文章是Prometheus监控系列的第二篇,基于上一篇讲解了怎么对Kubernetes集群实施Prometheus监控。 Prometheus部署 在k8s上部署Prometheus十分简单,下面给的例子中将Prometheus部署到prometheus命名空间。 部署——监控数据采集 Prometheus 将kube-state-metrics和prometheus分开部署,先部署prometheus。 prometheus-rbac.yaml apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRole metadata: name: prometheus rules: - apiGroups: [""] resources: - nodes - nodes/proxy - services - endpoints - pods verbs: ["get", "list", "watch"] - apiGroups: - extensions resources: - ingresses verbs: ["get", "list", "watch"] - nonResourceURLs: ["/metrics"] verbs: ["get"] --- apiVersion: v1 kind: ServiceAccount metadata: name: prometheus namespace: prometheus --- apiVersion: rbac.……

阅读全文

Prometheus监控k8s(一)——监控框架调研

背景 由于容器化和微服务的大力发展,Kubernetes基本已经统一了容器管理方案,当我们使用Kubernetes来进行容器化管理的时候,全面监控Kubernetes也就成了我们第一个需要探索的问题。我们需要监控kubernetes的ingress、service、deployment、pod……等等服务,已达到随时掌握Kubernetes集群的内部状况。 此文章是Prometheus监控系列的第一篇,目的也很明确,旨在于寻找一套能够胜任kubernetes集群监控的架构。 k8s监控方案调研 1、cAdvisor + InfluxDB + Grafana 2、Heapster + InfluxDB + Grafana [x] 3、Promethus + kube-state-metrics + Grafana……

阅读全文