我目前在我的广告连播中运行指标服务器。数据在localhost:9090的pod中发送。我能够通过curl获取pod内部的数据。注释deploy.yaml可以抓取数据,但在pod中看不到任何新指标。我在做什么错了?
我在广告连播中看到的指标:
cpu_usage{process="COMMAND", pid="PID"} %CPU
cpu_usage{process="/bin/sh", pid="1"} 0.0
cpu_usage{process="sh", pid="8"} 0.0
cpu_usage{process="/usr/share/filebeat/bin/filebeat-god", pid="49"} 0.0
cpu_usage{process="/usr/share/filebeat/bin/filebeat", pid="52"} 0.0
cpu_usage{process="php-fpm:", pid="66"} 0.0
cpu_usage{process="php-fpm:", pid="67"} 0.0
cpu_usage{process="php-fpm:", pid="68"} 0.0
cpu_usage{process="nginx:", pid="69"} 0.0
cpu_usage{process="nginx:", pid="70"} 0.0
cpu_usage{process="nginx:", pid="71"} 0.0
cpu_usage{process="/bin/sh", pid="541"} 0.0
cpu_usage{process="bash", pid="556"} 0.0
cpu_usage{process="/bin/sh", pid="1992"} 0.0
cpu_usage{process="ps", pid="1993"} 0.0
cpu_usage{process="/bin/sh", pid="1994"} 0.0
deployment.yaml
template:
metadata:
labels:
app: supplier-service
annotations:
prometheus.io/path: /
prometheus.io/scrape: 'true'
prometheus.io/port: '9090'
ports:
- containerPort: 80
- containerPort: 443
- containerPort: 9090
prometheus.yml
global:
scrape_interval: 15s # By default, scrape targets every 15seconds. # Attach these labels to any time series or alerts when #communicating with external systems (federation, re$
external_labels:
monitor: 'codelab-monitor'
# Scraping Prometheus itself
scrape_configs:
- job_name: 'prometheus'
scrape_interval: 5s
static_configs:
- targets: ['localhost:9090']
- job_name: 'kubernetes-service-endpoints'
scrape_interval: 5s
kubernetes_sd_configs:
- role: endpoints
relabel_configs:
- action: labelmap
regex: __meta_kubernetes_service_label_(.+)
- source_labels: [__meta_kubernetes_namespace]
action: replace
target_label: kubernetes_namespace
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
action: keep
regex: true
- source_labels: [__address__]
action: replace
regex: ([^:]+)(?::\d+)?
replacement: $1:9090
target_label: __address__
- source_labels: [__meta_kubernetes_service_name]
action: replace
target_label: kubernetes_name
端口号正确。我在做什么错了?
答案 0 :(得分:0)
您的kubernetes_sd_configs
配置为查找由服务创建的endpoints
。您是否为服务创建了端点?您可以在名称空间中使用kubectl get endpoints
进行检查。如果您不想创建服务,我想您也可以配置Prometheus来抓取Pod目标,请查看the docs以获取更多信息。
此外,documentation for metrics and labels说度量标准名称必须与正则表达式[a-zA-Z_:][a-zA-Z0-9_:]*
匹配,因此度量标准名称中的破折号(-
)也可能是一个问题。