[ZBX-21119] Kubernetes: Get state metrics gives timeout Created: 2022 May 26  Updated: 2022 Jun 02  Resolved: 2022 Jun 02

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Templates (T)
Affects Version/s: 6.0.4
Fix Version/s: None

Type: Problem report Priority: Trivial
Reporter: Wladimir Assignee: Zabbix Support Team
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: Ubuntu 20.04
Kubernetes version: 1.21.5
Kubespray version: 2.17.1
Zabbix Version: 6.0.4


Attachments: PNG File image-2022-05-26-14-04-26-328.png     File kube_state_metrics.log     File proxy.log    

 Description   

Steps to reproduce:

  1. Install Zabbix 6.0.4
  2. Install Kubernetes Cluster by Kubespray 2.17.1, kubernetes version 1.21.6 or 1.21.5
  3. Install Zabbix Helm Chart by instruction: https://git.zabbix.com/projects/ZT/repos/kubernetes-helm/browse?at=refs%2Fheads%2Frelease%2F6.0
  4. Create a new host, apply the template "Kubernetes cluster state by HTTP", change macros adding the URL and authorization key
  5. Test "Get state metrics"

Result: 

{"error":"Error: cannot get URL: Timeout was reached."}

 

I first tried it on my existing cluster. After some experimenting, I tried to install comletely new cluster and completely new zabbix server - the same result.

Also I need to mention that if I open the pod in Kubernetes Lens and click on the URL, it opens correctly in the browser and gives me the metrics.

All the other items are working correctly.

Tell me if you need any other information. Thanks in advance.



 Comments   
Comment by Alexey Pustovalov [ 2022 May 26 ]

Could you check the host and port availability from Zabbix proxy side? Do you have running kube-apiserver pod?

Comment by Wladimir [ 2022 May 26 ]

Alexey, yes, the pod kube-apiserver is running. Host and port are available; also, other units work well. Also, the template "Kubernetes nodes by HTTP" works without problems.

Comment by Alexey Pustovalov [ 2022 May 26 ]

Did you try to increase timeout then?

Comment by Wladimir [ 2022 May 27 ]

Yes, of course. With the same result.

Comment by Alexey Pustovalov [ 2022 May 27 ]

Is kube-state-metrics running? Please check endpoint of the service.

Comment by Wladimir [ 2022 May 27 ]

Yes, it is running (from zabbix helm chart). The endpoit is zabbix-kube-state-metrics (as it is in the template). Also, I mentioned that I can get to the web-interface of kube-state-metrics through lens (I think it's using port-forwarding, but the most important - yes, kube-state-metrics are functioning).

Actually, I also tried to install kube-state-metrics apart, and it neither worked. It was giving the same result.

Comment by Alexey Pustovalov [ 2022 May 27 ]

in this case please enable debug for Zabbix proxy, check again, then attach debug log to the issue.

Comment by Wladimir [ 2022 May 31 ]

As I mentioned, this is a helm installation. If I understand right, you need logs from zabbix-proxy pod. I tried to see how to increase its logs here: https://git.zabbix.com/projects/ZT/repos/kubernetes-helm/browse?at=refs%2Fheads%2Frelease%2F6.0

But there's nothing. Then I just tried to run a command:
zabbix_proxy -R log_level_increase
inside the container. Then I run a couple of times the check, and uploaded the container logs to the text file.

I'm not so sure if you really need the zabbix-proxy deployment logs, as the monitoring is going from the zabbix server to kubernetes API.

Also I decided to attach the logs of zabbix-kube-state-metrics. Maybe it would help.

Proxy: proxy.log

Kube-state-metrics: kube_state_metrics.log

Comment by Alexey Pustovalov [ 2022 May 31 ]

I think the proxy is misconfigured. I do not think it is available for Zabbix server (Administration->Proxies->Last seen):

** Updating '/etc/zabbix/zabbix_proxy.conf' parameter "Server": '127.0.0.1'...updated
** Updating '/etc/zabbix/zabbix_proxy.conf' parameter "ServerPort": '10051'...added

Also the host you added is monitoring by proper "zabbix-proxy" proxy?

Comment by Wladimir [ 2022 May 31 ]

> I do not think it is available for Zabbix server

Neither I do. I don't know, I didn't configure it, I just did what documentation says: installed the helm and deleted {{securityContext. }}But anyway, what should it do with a proxy, if it's an HTTP monitoring from the zabbix server by kubernetes API? Also, the insteresting thing is that everything else works without problems.

Also, please note the warnings/errors in kube-state-metrics logs. Can't it be a reason of the problem? As I mentioned, I use kubernetes v 1.25 and 1.26

> the host you added is monitoring by proper "zabbix-proxy" proxy?

This "host" is a kubernetes cluster. As I already mentioned, I've installed it following the documentation from here: https://www.zabbix.com/integrations/kubernetes

Besides other things, it installs a zabbix-proxy deployment. I'm not sure if zabbix-proxy is critical, and if I should configure it at all - the documentation doesn't mention it. I think the problem is not related to zabbix-proxy.

If you mean that you need zabbix logs, I could install a new proxy on a virtual machine, route the Kubernetes Cluster monitoring there and give you the result. Would you like me to do this? Or should I configure the proxy from the helm in another way not mentioned in the documentation?

Comment by Alexey Pustovalov [ 2022 May 31 ]

It is documented:

Change the values according to the environment in the file $HOME/zabbix_values.yaml.

So you need to configure Zabbix server location before installing helm.

Comment by Alexey Pustovalov [ 2022 Jun 01 ]

did you specify Zabbix server IP / DNS after my suggestion?

Comment by Wladimir [ 2022 Jun 01 ]

Hello again!

Sorry, I didn't have a chance to check it before. Today I could finally get it working.

There are a couple of things I didn't understand from the documentation:

1) It's necessary to monitor the cluster through zabbix-proxy (as the template is called "Kubernetes cluster state by HTTP", I thought it's enough to have a http access to it from the zabbix-server);

2) It's necessary to change values.yaml, at least writing the server address and the proxy name.

We can consider the issue closed; but I'd like to collaborate a little. Can I write a document based on the official instruction, but adding the proxy configuration steps? Or I could write a how-to about the configuration. I can just make a document and attach it here, then you can add it to the official documentation if you like. Do you think it's a good idea, or it's not necessary, to change the documentation? Thanks in advance.

Comment by Alexey Pustovalov [ 2022 Jun 02 ]

1. Yes, if you do not want to monitor through proxy, you have to open metrics / objects monitoring outside of Kubernetes.
2. Of course

Hm... i do not think it is neccessary, because if you install Zabbix proxy it is always needed to configure it.

Generated at Wed May 21 06:24:57 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.