namespace: monitoring spec: selector: matchLabels: app: prometheus-blackbox-exporter replicas: 1 template: metadata: labels: app: prometheus-blackbox-exporter spec name: prometheus-blackbox-exporter namespace: monitoring annotations: prometheus.io/scrape : 'true' spec: #type: NodePort selector: app: prometheus-blackbox-exporter ports: - name: name: prometheus-blackbox-exporter namespace: monitoring spec: endpoints: - interval: 30s
环境准备 在使用之前,须确保你的 k8s集群内已经部署了 prometheus operator和prometheus-blackbox-exporter,如果没有安装,可使用 helm命令直接部署。 prometheus-community/prometheus-operator # 安装 blackbox-exporter helm install prometheus-community/prometheus-blackbox-exporter 提示:可以在prometheus-blackbox-exporter的 helm values 中配置。
PrometheusRule CRD 做示例了, 示例如下: apiVersion: monitoring.coreos.com/v1 kind: PrometheusRule metadata: name: prometheus-blackbox-exporter spec: groups: - name: prometheus-blackbox-exporter rules: - alert: BlackboxSslCertificateWillExpireSoon
linux 软件包直接部署# apt install prometheus-blackbox-exporter 二进制部署# # 下载安装 wget https://github.com/prometheus
prometheus-community.github.io/helm-charts 安装blackbox,指定helm chart版本为9.1.0,观察日志无异常则安装完成 helm install kube prometheus-community/prometheus-blackbox-exporter
to prometheus.yml # must be a string so you have to add a | after extraScrapeConfigs: # example adds prometheus-blackbox-exporter scrape config extraScrapeConfigs: # - job_name: 'prometheus-blackbox-exporter' # metrics_path: param_target] # target_label: instance # - target_label: __address__ # replacement: prometheus-blackbox-exporter
prometheus-community.github.io/helm-charts helm repo update # Install chart helm install [RELEASE_NAME] prometheus-community/prometheus-blackbox-exporter
Downloads cached for licensed users color-quantizer 0.7.4.4 [Approved] Downloads cached for licensed users prometheus-blackbox-exporter