我正试着把我的nginx入口的数据传给普罗米修斯。我已经阅读了有关部署和配置的kubernetes.io自述文件。我的nginx运行正常,但重试后节点导出器失败。
我在提到的pod中有两个容器作为侧车,在我的环境中配置如下。
为什么nginx exporter总是失败?
我的nginx-ingress.yaml文件如下所示:
spec:
selector:
matchLabels:
app: nginx-ingress
template:
metadata:
labels:
app: nginx-ingress
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9113"
spec:
serviceAccountName: nginx-ingress
containers:
- image: nginx/nginx-ingress:edge
name: nginx-ingress
ports:
- name: http
containerPort: 80
hostPort: 80
- name: https
containerPort: 443
hostPort: 443
- name: stub
containerPort: 8080
hostPort: 8080
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
args:
- -nginx-configmaps=$(POD_NAMESPACE)/nginx-config
- -default-server-tls-secret=$(POD_NAMESPACE)/default-server-secret
- -enable-prometheus-metrics
#- -v=3 # Enables extensive logging. Useful for trooublshooting.
#- -report-ingress-status
#- -external-service=nginx-ingress
#- -enable-leader-election
- image: nginx/nginx-prometheus-exporter:0.4.2
name: nginx-prometheus-exporter
ports:
- name: prometheus
containerPort: 9113
args:
- -web.listen-address
- :9113
- -nginx.scrape-uri=http://127.0.0.1:8080/stub_status
- -nginx.retries=5
- -nginx.retry-interval=1Prometheus-cfg.yaml如下:
- job_name: 'ingress-nginx-endpoints'
kubernetes_sd_configs:
- role: pod
namespaces:
names:
- nginx-ingress
relabel_configs:
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
action: keep
regex: true
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scheme]
action: replace
target_label: __scheme__
regex: (https?)
- 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
target_label: __address__
regex: ([^:]+)(?::\d+)?;(\d+)
replacement: $1:$2
- source_labels: [__meta_kubernetes_service_name]
regex: prometheus-server
action: drop发布于 2019-10-23 16:06:08
您不需要向nginx-ingress添加导出器,请阅读有关您添加的注释的文档。
这些注释直接在入口导出器上激活导出器,使用您的配置打开端口9113 2次,删除prometheus导出器容器,它应该可以工作。
https://stackoverflow.com/questions/58517376
复制相似问题