已配置 prometheus-operator 以捕获 springboot pod 指标(通过执行器)。
能够在 prometheus 图形 UI 上查询指标http_server_requests_seconds_count
kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1 | jq . | grep http_s
但http_server_requests_seconds_count
查询时看不到相同的指标custom-metrics api
适配器的 cm 输出描述
Namespace: custom-metrics
Labels: <none>
Annotations: <none>
Data
====
config.yaml:
----
rules:
- seriesQuery: 'http_server_requests_seconds_count{job="kubernetes-pods", app="eperfall-priceservices"}'
seriesFilters: []
resources:
overrides:
kubernetes_pod_name:
resource: pod
kubernetes_namespace:
resource: namespace
name:
matches: http_server_requests_seconds_count
as: requests_per_second
metricsQuery: rate(http_server_requests_seconds_count{job="kubernetes-pods", app="eperfall-priceservices", uri="/priceservices/actuator/prometheus", <<.LabelMatchers>>}[5m])
Events: <none>
描述 prometheus-adapter pod
Name: custom-metrics-apiserver-7496cc665f-v9mrd
Namespace: custom-metrics
Priority: 0
PriorityClassName: <none>
Node: ip-10-157-198-239.ec2.internal/10.157.198.239
Start Time: Mon, 30 Sep 2019 03:46:00 +0000
Labels: app=custom-metrics-apiserver
pod-template-hash=7496cc665f
Annotations: kubernetes.io/psp: eks.privileged
Status: Running
IP: 10.157.218.96
Controlled By: ReplicaSet/custom-metrics-apiserver-7496cc665f
Containers:
custom-metrics-apiserver:
Container ID: docker://6f4f1224403a290c403712341f263765409404d3b86900622a02b5cdb08bd7b1
Image: directxman12/k8s-prometheus-adapter-amd64
Image ID: docker-pullable://directxman12/k8s-prometheus-adapter-amd64@sha256:ad5b5da5c5630c3b57cc5986d04067548c6ecf5407fd5e789cf34715b9dd31d3
Port: 6443/TCP
Host Port: 0/TCP
Args:
/adapter
--secure-port=6443
--tls-cert-file=/var/run/serving-cert/serving.crt
--tls-private-key-file=/var/run/serving-cert/serving.key
--logtostderr=true
--prometheus-url=http://prom-prometheus-operator-prometheus.monitoring.svc.cluster.local:9090/
--metrics-relist-interval=1m
--v=10
--config=/etc/adapter/config.yaml
State: Running
Started: Mon, 30 Sep 2019 03:47:35 +0000
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/etc/adapter/ from config (ro)
/tmp from tmp-vol (rw)
/var/run/secrets/kubernetes.io/serviceaccount from custom-metrics-apiserver-token-t7bmh (ro)
/var/run/serving-cert from volume-serving-cert (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
volume-serving-cert:
Type: Secret (a volume populated by a Secret)
SecretName: cm-adapter-serving-certs
Optional: false
config:
Type: ConfigMap (a volume populated by a ConfigMap)
Name: adapter-config
Optional: false
tmp-vol:
Type: EmptyDir (a temporary directory that shares a pod's lifetime)
Medium:
custom-metrics-apiserver-token-t7bmh:
Type: Secret (a volume populated by a Secret)
SecretName: custom-metrics-apiserver-token-t7bmh
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events: <none>