自主可控存储解决方案白皮书:天硕TOPSSD如何以全栈自研保障军用嵌入式计算机SSD数据一致
2025/12/17 1:24:23
导入proemtheus-community源
[root@ip-172-31-26-146 ~]# helm repo add prometheus-community https://prometheus-community.github.io/helm-charts "prometheus-community" already exists with the same configuration, skipping自定义values.yaml
config:modules:http_2xx:prober:httptimeout:5shttp:valid_http_versions:["HTTP/1.1","HTTP/2.0"]follow_redirects:truepreferred_ip_protocol:"ip4"serviceMonitor:enabled:falsedefaults:labels:release:kube-prometheus# 在这里把你的域名都列出来,它们会合并进同一个 ServiceMonitortargets:-name:parasail-homepageurl:https://a.networkinterval:1mscrapeTimeout:10smodule:http_2xx-name:starboard-venturesurl:https://b.venturesinterval:1mscrapeTimeout:10smodule:http_2xx-name:spacescope-iourl:https://c.iointerval:1mscrapeTimeout:10smodule:http_2xx部署blackbox-exporter
[root@ip-172-31-26-146 ~]# helm install blackbox prometheus-community/prometheus-blackbox-exporter -n monitoring -f values.yamlNAME: blackbox LAST DEPLOYED: Tue Dec1607:34:182025NAMESPACE: monitoring STATUS: deployed REVISION:1TEST SUITE: None NOTES: See https://github.com/prometheus/blackbox_exporter/forhow to configure Prometheus and the Blackbox Exporter.1. Get the application URL by running these commands:exportPOD_NAME=$(kubectl get pods --namespace monitoring -l"app.kubernetes.io/name=prometheus-blackbox-exporter,app.kubernetes.io/instance=blackbox"-ojsonpath="{.items[0].metadata.name}")exportCONTAINER_PORT=$(kubectl get pod --namespace monitoring $POD_NAME -ojsonpath="{.spec.containers[0].ports[0].containerPort}")echo"Visit http://127.0.0.1:8080 to use your application"kubectl --namespace monitoring port-forward$POD_NAME8080:$CONTAINER_PORTubectl--namespace default port-forward$POD_NAME8080:$CONTAINER_PORT编写ServiceMonitor
apiVersion:monitoring.coreos.com/v1kind:ServiceMonitormetadata:name:blackbox-exporter# 只有一个名字namespace:monitoringlabels:release:kube-prometheus# 确保这与你的 Prometheus Operator 匹配spec:# 1. 这里非常关键:我们要选择 Blackbox Exporter 的 Service# 这样 Prometheus 才知道要把请求发给谁selector:matchLabels:app.kubernetes.io/instance:blackbox-parasailapp.kubernetes.io/name:prometheus-blackbox-exporter# 2. 这里定义“我们要监控谁”# 所有的域名都写在 endpoints 列表里,但它们属于同一个 ServiceMonitor 对象endpoints:# --- 第 1 个域名 ----port:httppath:/probeinterval:1mscrapeTimeout:10sparams:module:["http_2xx"]target:["https://parasail.network"]# 目标写在这里metricRelabelings:# 可选:为了让图表好看,把 target 重命名为 instance-sourceLabels:[__param_target]targetLabel:instance# --- 第 2 个域名 ----port:httppath:/probeinterval:1mscrapeTimeout:10sparams:module:["http_2xx"]target:["https://starboard.ventures"]# --- 第 3 个域名 ----port:httppath:/probeinterval:1mscrapeTimeout:10sparams:module:["http_2xx"]target:["https://spacescope.io"]部署ServiceMonitor
[root@ip-172-31-26-146 prometheus-blackbox-exporter]# kubectl apply -f servicemonitor.yamlservicemonitor.monitoring.coreos.com/blackbox-exporter created[root@ip-172-31-26-146 prometheus-blackbox-exporter]# helm list -n monitoringNAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION blackbox monitoring42025-12-16 09:16:24.838617309 +0000 UTC deployed prometheus-blackbox-exporter-11.6.1 v0.28.0