-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Closed
Description
What did you do?
I am trying to monitor Nginx ingress controller with Prometheus operator.
I have installed Nginx ingress controller using the official helm chart and I have enabled metrics, stats, and I have enabled the following annotations for metrics:
prometheus.io/scrape: "true"
prometheus.io/port: "10254"
The ingress controller will create the following services:
nginx-ingress-controller LoadBalancer 100.67.71.32 myloadbalancer.elb.amazonaws.com 80:30794/TCP,443:30883/TCP 2d
nginx-ingress-controller-metrics ClusterIP 100.66.15.57 <none> 9913/TCP 2d
nginx-ingress-controller-stats ClusterIP 100.68.130.105 <none> 18080/TCP 2d
nginx-ingress-default-backend ClusterIP 100.65.98.230 <none> 80/TCP 2d
Environment
- Prometheus Operator version:
v0.25.0
- Kubernetes version information:
v1.10.6
- Kubernetes cluster kind:
Kops, AWS EKS
- Manifests:
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: nginx-ingress-controller-metrics
labels:
app: nginx-ingress
spec:
endpoints:
- interval: 30s
port: metrics
selector:
matchLabels:
app: nginx-ingress
release: nginx-ingress
namespaceSelector:
matchNames:
- default
- Prometheus Operator Logs:
level=info ts=2018-11-12T09:33:19.529074046Z caller=operator.go:956 component=prometheusoperator msg="sync prometheus" key=default/prometheus-operator-prometheus
level=info ts=2018-11-12T09:33:27.037554394Z caller=operator.go:956 component=prometheusoperator msg="sync prometheus" key=default/prometheus-operator-prometheus
level=info ts=2018-11-12T09:33:34.543325319Z caller=operator.go:956 component=prometheusoperator msg="sync prometheus" key=default/prometheus-operator-prometheus
level=info ts=2018-11-12T09:33:42.052934524Z caller=operator.go:956 component=prometheusoperator msg="sync prometheus" key=default/prometheus-operator-prometheus
level=info ts=2018-11-12T09:33:49.563343133Z caller=operator.go:956 component=prometheusoperator msg="sync prometheus" key=default/prometheus-operator-prometheus
level=info ts=2018-11-12T09:33:57.065484489Z caller=operator.go:956 component=prometheusoperator msg="sync prometheus" key=default/prometheus-operator-prometheus
level=info ts=2018-11-12T09:34:04.572233431Z caller=operator.go:956 component=prometheusoperator msg="sync prometheus" key=default/prometheus-operator-prometheus
I think I am doing something wrong with the ServiceMonitor manifest file. Can someone help?
Thanks in advance
Activity
metalmatze commentedon Nov 12, 2018
Is everything running in the
default
namespace?Looking at the services you posted, could make sure that the metrics port is 9913 and the labels are the same?
Feel free to paste your output of
kubectl -n default describe service nginx-ingress-controller-metrics
here so we can debug further.ArjonBu commentedon Nov 12, 2018
@metalmatze Yes, everything is running in the default namespace.
Here is the output of the service:
ArjonBu commentedon Nov 15, 2018
Any update on this?
metalmatze commentedon Nov 15, 2018
I still do not really get why you have
Port: metrics 9913/TCP
when it everywhere says10254
. Are you able to change the port in the Service to10254
as well? Else I can't really see anything wrong.ArjonBu commentedon Nov 16, 2018
I changed the port to 10254/tcp and it still doesn't show anything. Is prometheus config automatically reloaded after every servicemonitor change?
squat commentedon Nov 16, 2018
@ArjonBu yes, the Prometheus configuration is automatically re-generated and reloaded after every change to a ServiceMonitor that it is watching. It is possible that your Prometheus is not selecting this ServiceMonitor for some reason. Can you please share the Prometheus manifest?
ArjonBu commentedon Nov 16, 2018
@squat I installed prometheus operator using the official helm chart. If you meant the serviceoperator. I have pasted it in the first post.
squat commentedon Nov 16, 2018
@ArjonBu the helm charts are not maintained by this team, plus there are many ways to configure the chart to have different behaviors. Can you please share the output of
kubectl get prometheus -n default prometheus-operator-prometheus -o yaml
ArjonBu commentedon Nov 16, 2018
@squat Here is it:
squat commentedon Nov 17, 2018
@ArjonBu thanks, that's super helpful. It appears to me that indeed your Prometheus is not selecting your ServiceMonitors due to mismatched labels. Notice that your Prometheus objects has:
but the only labels on your Ingress Controller ServiceMonitor are:
In order to select your Ingress Controller ServiceMonitor, you will need to add:
to the ServiceMonitor's labels so that it looks like:
ArjonBu commentedon Nov 19, 2018
Works! Thank you
squat commentedon Nov 19, 2018
@ArjonBu, I’m very glad this solved the issue for you. I’ll close this now since everything is working.