如何使用带有值文件的 Helm 图表在 Prometheus 中配置 ingress-nginx-controller-metrics?
How to configure ingress-nginx-controller-metrics in Prometheus using Helm chart with values file?
我想让我的 nginx-ingress 指标添加到 Prometheus 中,这样我就可以看到我的应用程序日志显示在 loki 中。然而,我并没有取得太大的成功。我一直在关注本指南 here 但我想为 nginx-ingress 执行此操作,该指南适用于大使入口。
使用以下命令安装 Nginx-Ingress:
NGINX_CHART_VERSION="4.0.6";
helm upgrade ingress-nginx ingress-nginx/ingress-nginx --version "$NGINX_CHART_VERSION" --namespace ingress-nginx -f "03-setup-ingress-controller/assets/manifests/nginx-values-v${NGINX_CHART_VERSION}.yaml" --set controller.metrics.enabled=true --set-string controller.podAnnotations."prometheus\.io/scrape"="true" --set-string controller.podAnnotations."prometheus\.io/port"="10254"
所以我在我的 k8 集群中公开了我的 nginx-ingress 指标,如您所见:
kubectl get svc -n ingress-nginx
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
ingress-nginx-controller LoadBalancer 10.245.57.3 <REDACTED> 80:31150/TCP,443:31740/TCP 9d
ingress-nginx-controller-admission ClusterIP 10.245.186.61 <none> 443/TCP 9d
ingress-nginx-controller-metrics ClusterIP 10.245.240.243 <none> 10254/TCP 20h
我使用包含我的 ingress-nginx-controller-metrics 的值文件对 Helm 进行了升级:
HELM_CHART_VERSION="27.2.1";
helm upgrade kube-prom-stack prometheus-community/kube-prometheus-stack \
--version "${HELM_CHART_VERSION}" --namespace monitoring \
-f "04-setup-prometheus-stack/assets/manifests/prom-stack-values-v${HELM_CHART_VERSION}.yaml"
我用值文件更新了它以包含,从 git repo 配置定制)为:
## Starter Kit components service monito
#
additionalServiceMonitors:
- name: "ingress-nginx-monitor"
selector:
matchLabels:
service: "ingress-nginx-controller
namespaceSelector:
matchNames:
- ingress-nginx
endpoints:
- port: "ingress-nginx-controller-me
path: /metrics
scheme: http
但是,当我检查 Prometheus 目标时,我没有看到那里有 nginx 入口。
kube-prom-stack 的 additionalServiceMonitors 应该是:
additionalServiceMonitors:
- name: "ingress-nginx-monitor"
selector:
matchLabels:
app.kubernetes.io/name: ingress-nginx
namespaceSelector:
matchNames:
- ingress-nginx
endpoints:
- port: "metrics"
我想让我的 nginx-ingress 指标添加到 Prometheus 中,这样我就可以看到我的应用程序日志显示在 loki 中。然而,我并没有取得太大的成功。我一直在关注本指南 here 但我想为 nginx-ingress 执行此操作,该指南适用于大使入口。
使用以下命令安装 Nginx-Ingress:
NGINX_CHART_VERSION="4.0.6";
helm upgrade ingress-nginx ingress-nginx/ingress-nginx --version "$NGINX_CHART_VERSION" --namespace ingress-nginx -f "03-setup-ingress-controller/assets/manifests/nginx-values-v${NGINX_CHART_VERSION}.yaml" --set controller.metrics.enabled=true --set-string controller.podAnnotations."prometheus\.io/scrape"="true" --set-string controller.podAnnotations."prometheus\.io/port"="10254"
所以我在我的 k8 集群中公开了我的 nginx-ingress 指标,如您所见:
kubectl get svc -n ingress-nginx
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
ingress-nginx-controller LoadBalancer 10.245.57.3 <REDACTED> 80:31150/TCP,443:31740/TCP 9d
ingress-nginx-controller-admission ClusterIP 10.245.186.61 <none> 443/TCP 9d
ingress-nginx-controller-metrics ClusterIP 10.245.240.243 <none> 10254/TCP 20h
我使用包含我的 ingress-nginx-controller-metrics 的值文件对 Helm 进行了升级:
HELM_CHART_VERSION="27.2.1";
helm upgrade kube-prom-stack prometheus-community/kube-prometheus-stack \
--version "${HELM_CHART_VERSION}" --namespace monitoring \
-f "04-setup-prometheus-stack/assets/manifests/prom-stack-values-v${HELM_CHART_VERSION}.yaml"
我用值文件更新了它以包含,从 git repo 配置定制)为:
## Starter Kit components service monito
#
additionalServiceMonitors:
- name: "ingress-nginx-monitor"
selector:
matchLabels:
service: "ingress-nginx-controller
namespaceSelector:
matchNames:
- ingress-nginx
endpoints:
- port: "ingress-nginx-controller-me
path: /metrics
scheme: http
但是,当我检查 Prometheus 目标时,我没有看到那里有 nginx 入口。
kube-prom-stack 的 additionalServiceMonitors 应该是:
additionalServiceMonitors:
- name: "ingress-nginx-monitor"
selector:
matchLabels:
app.kubernetes.io/name: ingress-nginx
namespaceSelector:
matchNames:
- ingress-nginx
endpoints:
- port: "metrics"