We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
通过 Minikube 来安装 Kubernetes 测试环境。
$ minikube start --cpus 4 --memory 8192 --vm-driver hyperkit $ helm repo add prometheus-community https://prometheus-community.github.io/helm-charts $ helm repo add stable https://kubernetes-charts.storage.googleapis.com/ $ helm repo update $ helm install prometheus prometheus-community/kube-prometheus-stack
可以使用 kubectl 查看安装好的各组件。
mongodb.yaml
apiVersion: apps/v1 kind: Deployment metadata: name: mongodb-deployment labels: app: mongodb spec: replicas: 1 selector: matchLabels: app: mongodb template: metadata: labels: app: mongodb spec: containers: - name: mongodb image: mongo ports: - containerPort: 27017 --- apiVersion: v1 kind: Service metadata: name: mongodb-service spec: selector: app: mongodb ports: - protocol: TCP port: 27017 targetPort: 27017
安装:
$ kubectl apply -f mongodb.yaml
Exporter 是什么:将要采集数据的应用数据转换成 Prometheus 能理解的 metrics。
工作流程:1)Exporter 从目标应用获取 metrics 数据。2)转换为正确格式。3)在 /metrics 端点暴露 metrics。4)Promettheus 的 Retrieval 拉取 metrics 数据。5)Promettheus 将 metrics 数据存储到时序数据库。6)Promettheus 的 HTTP Server 提供从数据库获取数据的 API,可以通过 PromQL 来查询数据。
/metrics
需要安装 3 个组件:
可以通过 Helm 来安装。
先添加 repo:
$ helm repo add prometheus-community https://prometheus-community.github.io/helm-charts $ helm repo update
查看 chart 的 values:
$ helm show values prometheus-community/prometheus-mongodb-exporter
有几个值需要指定:
values.yaml
mongodb: uri: "mongodb://mongodb-service:27017" # 指定 MongoDB SVC endpoint serviceMonitor: additionalLabels: release: prometheus # ServiceMonitor 标签,使其可以被 Prometheus 发现
helm install mongodb-exporter prometheus-community/prometheus-mongodb-exporter -f values.yaml
检查 SVC 及 ServiceMonitor 是否正常:
$ kubectl port-forward service/mongodb-exporter-prometheus-mongodb-exporter 9216 $ curl localhost:9216 $ kubectl get servicemonitor
$ kubectl port-forward deployment/prometheus-grafana 3000
用户名 admin,获取密码:
$ kubectl get secret prometheus-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
浏览器访问 http://localhost:3000/,登录后即可在 Manage 中查看 MongoDB 的 CPU、内存等的使用情况了。
http://localhost:3000/
The text was updated successfully, but these errors were encountered:
No branches or pull requests
0. 安装 Prometheus 和 Grafana 等组件
通过 Minikube 来安装 Kubernetes 测试环境。
可以使用 kubectl 查看安装好的各组件。
1. 安装 MongoDB
mongodb.yaml
安装:
2. 安装 Exporter
Exporter 是什么:将要采集数据的应用数据转换成 Prometheus 能理解的 metrics。
工作流程:1)Exporter 从目标应用获取 metrics 数据。2)转换为正确格式。3)在
/metrics
端点暴露 metrics。4)Promettheus 的 Retrieval 拉取 metrics 数据。5)Promettheus 将 metrics 数据存储到时序数据库。6)Promettheus 的 HTTP Server 提供从数据库获取数据的 API,可以通过 PromQL 来查询数据。需要安装 3 个组件:
/metrics
端点可以通过 Helm 来安装。
先添加 repo:
查看 chart 的 values:
有几个值需要指定:
values.yaml
安装:
检查 SVC 及 ServiceMonitor 是否正常:
3. 使用 Grafana 查看数据
用户名 admin,获取密码:
浏览器访问
http://localhost:3000/
,登录后即可在 Manage 中查看 MongoDB 的 CPU、内存等的使用情况了。The text was updated successfully, but these errors were encountered: