根据定义,kube_pod_container_status_waiting_reason应该捕获处于 Waiting 状态的 pod 的原因。
我的 kubernetes 集群中有几个 Pod 位于 CrashLoopBackOff 中,但我没有看到kube_pod_container_status_waiting_reason. 它只捕获两个原因 - ErrImagePull 和 ContainerCreating。
~$ k get pods -o wide --show-all --all-namespaces | grep Crash
cattle-system cattle-cluster-agent-6f744c67cc-jlkjh 0/1 CrashLoopBackOff 2885 10d 10.233.121.247 k8s-4
cattle-system cattle-node-agent-6klkh 0/1 CrashLoopBackOff 2886 171d 10.171.201.127 k8s-2
cattle-system cattle-node-agent-j6r94 0/1 CrashLoopBackOff 2887 171d 10.171.201.110 k8s-3
cattle-system cattle-node-agent-nkfcq 0/1 CrashLoopBackOff 17775 171d 10.171.201.131 k8s-1
cattle-system cattle-node-agent-np76b 0/1 CrashLoopBackOff 2887 171d 10.171.201.89 k8s-4
cattle-system cattle-node-agent-pwn5v 0/1 CrashLoopBackOff 2859 171d 10.171.202.72 k8s-5 …Run Code Online (Sandbox Code Playgroud) kubernetes prometheus prometheus-operator prometheus-alertmanager kube-state-metrics
我定期看到容器 状态:已终止 - OOMKilled(退出代码:137)
但是被调度到内存充足的节点
$ k get statefulset -n metrics
NAME READY AGE
prometheus 0/1 232d
$ k get po -n metrics
prometheus-0 1/2 CrashLoopBackOff 147 12h
$ k get events -n metrics
LAST SEEN TYPE REASON OBJECT MESSAGE
10m Normal Pulled pod/prometheus-0 Container image "prom/prometheus:v2.11.1" already present on machine
51s Warning BackOff pod/prometheus-0 Back-off restarting failed container
k logs -f prometheus-0 -n metrics --all-containers=true
level=warn ts=2020-08-22T20:48:02.302Z caller=main.go:282 deprecation_notice="'storage.tsdb.retention' flag is deprecated use 'storage.tsdb.retention.time' instead."
level=info ts=2020-08-22T20:48:02.302Z caller=main.go:329 …Run Code Online (Sandbox Code Playgroud) 我尝试在 Kubernetes 上运行 Prometheus Operator,但在尝试在 Rancher-RBD 上保存数据后,出现错误:
level=info ts=2020-10-31T12:40:33.171Z caller=main.go:353 msg="Starting Prometheus" version="(version=2.22.0, branch=HEAD, revision=0a7fdd3b76960808c3a91d92267c3d815c1bc354)"
level=info ts=2020-10-31T12:40:33.171Z caller=main.go:358 build_context="(go=go1.15.3, user=root@6321101b2c50, date=20201015-12:29:59)"
level=info ts=2020-10-31T12:40:33.171Z caller=main.go:359 host_details="(Linux 4.14.35-1902.3.2.el7uek.x86_64 #2 SMP Tue Jul 30 03:59:02 GMT 2019 x86_64 prometheus-prometheus-0 (none))"
level=info ts=2020-10-31T12:40:33.171Z caller=main.go:360 fd_limits="(soft=1048576, hard=1048576)"
level=info ts=2020-10-31T12:40:33.171Z caller=main.go:361 vm_limits="(soft=unlimited, hard=unlimited)"
level=error ts=2020-10-31T12:40:33.173Z caller=query_logger.go:87 component=activeQueryTracker msg="Error opening query log file" file=/prometheus/queries.active err="open /prometheus/queries.active: permission denied"
panic: Unable to create mmap-ed active query log
goroutine 1 [running]:
github.com/prometheus/prometheus/promql.NewActiveQueryTracker(0x7fff711299c3, 0xb, 0x14, 0x30867c0, 0xc000e6f050, 0x30867c0)
/app/promql/query_logger.go:117 +0x4cf …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 helm 安装 kube-prometheus-stack 并尝试将持久卷与 hospath 一起使用,即使在指定 VolumeClaimTemplate 后创建的emptyDir 也是存储类型。
这些是我遵循的步骤:
kind: PersistentVolume
metadata:
name: prometheus-pv
labels:
app: prometheus
spec:
capacity:
storage: 50Gi
hostPath:
path: /data/prometheus/pv4
type: ''
accessModes:
- ReadWriteOnce
Run Code Online (Sandbox Code Playgroud)
resources: {}
# requests:
# memory: 400Mi
## Prometheus StorageSpec for persistent data
## ref: https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/user-guides/storage.md
##
storageSpec:
## Using PersistentVolumeClaim
##
volumeClaimTemplate:
spec:
storageClassName: ""
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 50Gi
selector:
matchLabels:
app: prometheus
Run Code Online (Sandbox Code Playgroud)
helm install --values Prometheus.yaml promethes prometheus-community/kube-prometheus-stack --namespace …Run Code Online (Sandbox Code Playgroud) 我正在尝试添加我自己的时间戳而不是普罗米修斯的时间戳。
例如:
节点值{端点=“https”,实例=“xx.xx.xx.xx”,作业=“普罗米修斯”,节点=“node1”}
489846@1610014796.199
489933@1610014826.199
要求:node_value(上面)是一个具有两个值和时间戳的指标(由普罗米修斯添加的抓取时间戳),我想添加我自己从第三方获取的时间戳,而不是抓取时间戳。我们有这方面的规定吗?
注意:我使用的是 golang prometheus 客户端。
下面是当我点击目标时 prometheus URL 中的显示。
cadvisor(0/1 向上)和节点导出器(0/1 向上)显示在 Prometheus URL 中
这是我的 filename.yml 文件
version: '3.2'
services:
prometheus:
image: prom/prometheus:latest
# container_name: monitoring_prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
volumes:
- /Prometheus/alert.rules:/etc/prometheus/alert.rules
- /Prometheus/container.yml:/etc/prometheus/container.yml
- /Prometheus/diskusage.yml:/etc/prometheus/diskusage.yml
- ./prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- 9090:9090
node-exporter:
image: prom/node-exporter:latest
# container_name: monitoring_node_exporter
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
ports:
- 9091:9091
command:
- '--path.procfs=/host/proc'
- '--path.sysfs=/host/sys'
- '--path.rootfs=/host'
- '--collector.filesystem.ignored-mount-points="^(/rootfs|/host|)/(sys|proc|dev|host|etc)($$|/)"'
- '--collector.filesystem.ignored-fs-types="^(sys|proc|auto|cgroup|devpts|ns|au|fuse\.lxc|mqueue)(fs|)$$"'
cadvisor:
image: google/cadvisor:latest
# container_name: monitoring_cadvisor
ports:
- 9092:9092
volumes: …Run Code Online (Sandbox Code Playgroud) docker prometheus prometheus-operator prometheus-alertmanager prometheus-node-exporter
错误:安装失败:呈现的清单包含已存在的资源。无法继续安装:命名空间“”中的 ClusterRole“prometheus-kube-state-metrics”存在,无法导入到当前版本中:所有权元数据无效;注释验证错误:键“meta.helm.sh/release-namespace”必须等于“monitoring”:当前值为“monitoring-kogito-poc”
如何解决这个问题我已经删除了命名空间并创建了新的命名空间,并尝试为 grafana 和 prometheus 安装 helm 图表。但它不允许我安装。我已删除以下所有内容的 ClusterRoleBinding,在此处输入图像描述
kubectl delete clusterrolebinding prometheus-kube-state-metrics [在此处输入图像描述][1]
但它仍然显示并值得注意安装 prometheus [1]:https://i.stack.imgur.com/QkNaS.png
kubernetes prometheus prometheus-operator prometheus-alertmanager prometheus-blackbox-exporter
如果我启动一个全新的、空的 minikube 和helm install最新stable/prometheus-operator的严格默认设置,我会看到四个活动的 Prometheus 警报。
在这个超级简化的场景中,我有一个干净的新 minikube,除了 Prometheus 之外什么都没有运行,应该没有问题,也没有警报。这些警报是假的还是坏了?我的设置有问题吗?或者我应该提交错误报告并暂时禁用这些警报?
以下是我的基本设置步骤:
minikube delete
# Any lower memory/cpu settings will experience problems
minikube start --memory 10240 --cpus 4 --kubernetes-version v1.12.2
eval $(minikube docker-env)
helm init
helm repo update
# wait a minute for Helm Tiller to start up.
helm install --name my-prom stable/prometheus-operator
Run Code Online (Sandbox Code Playgroud)
等待几分钟让一切启动,然后在 Prometheus 服务器和 Grafana 上运行端口转发:
kubectl port-forward service/my-prom-prometheus-operato-prometheus 9090:9090
kubectl port-forward service/my-prom-grafana 8080:80
Run Code Online (Sandbox Code Playgroud)
然后去http://localhost:9090/alerts看看:
DeadMansSwitch (1 active)
KubeControllerManagerDown (1 active)
KubeSchedulerDown (1 …Run Code Online (Sandbox Code Playgroud) 是否可以将标签的值拆分为指标?
\nrows_inserted_total{job_name="maejcc100-telemetry-vm-6c96c655c6", type="opentdb"}\nrows_inserted_total{job_name="vacocc100-telemetry-vm-5d49ff7d9b", type="graphite"}\nrows_inserted_total{pod_name="azaacc100-telemetry -vm-7475f44758", type="graphite"}\nrows_inserted_total{job_name="fl06cc200-telemetry-vm-6c99b4f4cb", type="opentsdbhttp"}
\n标签 job_name 具有长文本值。我只想使用 \xe2\x80\x9cmaejcc100\xe2\x80\x9d 中的 \xe2\x80\x9cmaejcc100-telemetry-vm-6c96c655c6\xe2\x80\x9d 的初始部分。我怎样才能实现这个目标?有没有办法分割标签值或使用子字符串仅获取长文本的一部分?
\n提前抱歉,因为这可能是一个非常容易回答的问题,我对 prometheus 和 grafana 还很陌生,我试图找出 prometheus 中的这个指标来自“container_cpu_usage_seconds_total”。
我在网上发现所有以“node_”开头的指标都来自节点导出器 pod。所以我只是想知道这个指标是否来自 prometheus 本身,或者这也来自节点导出器,因为我们目前在 pod 上没有设置注释,但正在 grafana 中获取这些指标。
提前致谢!
kubernetes prometheus prometheus-operator prometheus-node-exporter
prometheus ×8
kubernetes ×7
amazon-eks ×1
docker ×1
go ×1
minikube ×1
prometheus-blackbox-exporter ×1
promql ×1