简体   繁体   English

使用Prometheus操作员进行自定义监控

[英]custom monitoring with prometheus operator

I have 6 replica of nginx in each of namespaces of k8s (stg,pre and production). 我在k8s的每个命名空间(stg,pre和production)中都有6个nginx副本。 now I want to scrap all nginx status code like 200,300,400,500 and count them and show in prometheus and grafana. 现在,我想废弃所有的nginx状态代码(例如200,300,400,500),并对其进行计数,并显示在prometheus和grafana中。 is there any way to add custom monitoring spces in operator? 有什么方法可以在操作员中添加自定义监视spces?

It should be as simple as adding additionalServiceMonitors in values.yaml , of course, I am assuming your Nginx already expose these metrics with information about status codes. 它应该是如添加简单additionalServiceMonitorsvalues.yaml ,当然,我假设你已经Nginx的有关状态代码的信息揭露这些指标。

Example: 例:

k apply -f -<<EOF
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  annotations:
  labels:
    release: prom
  name: kafka-exporter
spec:
  endpoints:
  - port: metrics
  selector:
    matchLabels:
      app: kafka-exporter
EOF
k apply -f -<<EOF
apiVersion: v1
kind: Service
metadata:
  labels:
    app: kafka-exporter
    role: kafka
  name: kafka
spec:
  ports:
  - name: server
    port: 9093
    protocol: TCP
    targetPort: 9093
  - name: metrics
    port: 9182
    protocol: TCP
    targetPort: 9182
  selector:
    role: kafka
EOF

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM