3

I have Prometheus setup for Windows containers which scrapes the metrics supported by the wmi_exporter. But I wanted some metrics that track the pod restarts, etc which are not part of that. I believe kube-state-metrics offers this functionality. But I could not find any way to install it on Windows containers. All the helm charts I found online have images that only work with Linux containers. So, is there any way to install it on Windows containers?

Is there any other better way to have alerts for pod/container restarts?

Rico
  • 58,485
  • 12
  • 111
  • 141

1 Answers1

3

You can use kube-state-metrics like you said. From the Kubernetes control plane point of view, a pod/container restart is no different whether you are using Linux or Windows containers.

Keep in mind that the control plane is only supported on Linux so in case you only have Windows nodes on your cluster you can run the kube-state-metrics pod/container in your master(s), otherwise, you will need a Linux node. Alternatively, you can build the kube-state-metrics Windows Go binary and run it on a Windows pod/container, but that could be more troublesome.

You can use something like this with Alertmanager as an alert.

Rico
  • 58,485
  • 12
  • 111
  • 141
  • Thanks Rico :) So, when we run kube-state-metrics on the master, does it need any annotations on the pods inorder to scrape metrics or does it just work out of the box. – sai guru datt manchikanti Apr 23 '19 at 07:46
  • 1
    You just need the `prometheus.io/scrape: 'true'` annotation on the kube-state-metrics Kubernetes deployment. Hope it helps! – Rico Apr 23 '19 at 16:03
  • Hi Rico. When I installed it on the master, I can see some response when I do curl http://localhost:8080/metrics from within the master, but not able to see anything when I try to access master_ip:8080/metrics from the browser. Also, inorder for prometheus to scrape metrics from this as well, we need to add the master ip statically to the prometheus config ?? – sai guru datt manchikanti Apr 26 '19 at 23:45
  • It probably means that your master server might be blocking some connections from your browser. Do you have any firewall rules in them? Yes. prometheus usually needs to know the targets to scrape. – Rico Apr 26 '19 at 23:59
  • I'll check on the firewall rules. For the target scraping, if we annotate the pod to allow prometheus scrape just like other nodes that are scheduled on the worker nodes where it works perfectly, prometheus should be able to identify that pod right ? – sai guru datt manchikanti Apr 27 '19 at 00:29