Closed TheLordDrake closed 4 years ago
Hi! As I understand you need to place script consul2zabbix.py
to /opt/scripts/
directory of container there zabbix agent installed. In you case it can be easy to place in container with zabbix it it have zabbix agent. Also you need to change this line to match address of your consul agent http interface.
https://github.com/dmitriy-myz/zabbix-templates/blob/master/consul2zabbix/consul2zabbix.py#L19
Hi, thanks for getting back to me so quickly. I have added the /opt/scripts/consul2zabbix.py
script to my zabbix agent container, and updated that line to use the Linux host machine's IP address. (Consul's container is using the host network) I still don't seem to be getting anything back.
Let me break down my current setup for you a little more clearly, hopefully that will make this easier. I am running Zabbix Server, a Zabbix Agent, and Consul as docker containers on Ubuntu.
Consul is running using host networking, so it does not have it's own IP address. It is running and has a couple services registered and reporting their status.
On the Agent container I have added the python script and set the IP address on line 19 to the Ubuntu Host's IP.
On the server I have Added my agent as a host, and added the Consul and Linux OS templates to that host. I am receiving data about things covered by the Linux OS template. Looking at "latest data" in the Zabbix UI, I don't seem to be receiving any data for the Consul Status field added by the Consul template.
Hm... Look like valid configuration. I guess I found reason why it not working.
It assume that zabbix agent runned on same host as consul so it use current node hostname to pull info from consul.
In you current configuration you can replace in line 19 consul url to match hostname of consul docker image
url = 'http://consul_ip:8500/v1/health/node/node_name'
node_name can be retrieved from consul api like this (in qoutes)
curl -s consul_ip:8500/v1/catalog/nodes | grep Node
I thought about full cluster monitoring using one consul endpoint, but didn't implement it. In my case it more clear to have consul and zabbix agent on same host.
I gave that a shot. I'm still not receiving anything on the Server's end. I ran the script manually and it does work, it's returning the correct values. So the script either isn't being run or its response isn't being picked up by the server. Also when I check the "Latest Data" section of Zabbix the field for Consul Status
is grayed out. At this point I'm unsure if perhaps this is a configuration problem with Zabbix itself.
I figured out the issue. When the script was copied it wasn't given executable permission so the zabbix user couldn't run it. I ran added that permission to the python script and now data is coming through just fine. Thank you for the assistance! Would you mind if I opened a PR to update the installation instructions to include some of this new information?
~I gave that a shot. I'm still not receiving anything on the Server's end. I ran the script manually and it does work, it's returning the correct values. So the script either isn't being run or its response isn't being picked up by the server. Also when I check the "Latest Data" section of Zabbix the field for
Consul Status
is grayed out. At this point I'm unsure if perhaps this is a configuration problem with Zabbix itself.~I figured out the issue. When the script was copied it wasn't given executable permission so the zabbix user couldn't run it. I ran added that permission to the python script and now data is coming through just fine. Thank you for the assistance! Would you mind if I opened a PR to update the installation instructions to include some of this new information?
Yes, this would be great!
I have created a PR with the updates.
Hi, I'm pretty new to Zabbix and Consul and I'm having some problems trying to figure out how to connect the two.
I have Consul and Zabbix running in docker containers on a Linux host. Based on your reply to another issue here I placed the python script in the
/opts/scripts/
directory on my consul container. I've also installed the consul template and created a host using that template in zabbix with the IP of the Linux host machine (Consul container is using the host network)I'm having a hard time figuring out how Zabbix is supposed to collect information from Consul. I did add the line from the .conf file to a zabbix agent's configuration. That agent is reporting other data, like Ping and CPU load. I'm unsure how to check if it's actually getting anything from consul though.