zabbix / zabbix-docker

Official Zabbix Dockerfiles
https://www.zabbix.com
GNU Affero General Public License v3.0
2.39k stars 1.38k forks source link

docker metrics unknown #1310

Closed fcaputomobeats closed 7 months ago

fcaputomobeats commented 7 months ago
SUMMARY

Some docker metrics used in Docker by Zabbix Agent 2 are unknown. this metrics aren't added

Other metrics like Docker.info work as expected

OS / ENVIRONMENT / Used docker-compose files

Im using this setup:

   server    <-           proxy (active)         <->             agent
(On premise) <- (AWS EC2 instance public subnet) <-> (AWS EC2 instance private subnet)

This is the docker-compose.yml for the proxy:

services:
  zabbix-proxy:
    container_name: zabbix-proxy
    environment:
      - DB_SERVER_HOST=mysql
      - MYSQL_USER=mysql
      - MYSQL_PASSWORD=password
      - ZBX_HOSTNAME=xxxx-proxy
      - ZBX_SERVER_HOST=XXX.XXX.XXX.139:10055 #Public IP server
      - ZBX_PROXYMODE=0
    image: zabbix/zabbix-proxy-mysql:6.2.6-alpine
    ports:
      - "10051:10051"
  mysql:
    container_name: mysql
    image: mysql:8.0
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: rootpassword
      MYSQL_DATABASE: zabbix_proxy
      MYSQL_USER: mysql
      MYSQL_PASSWORD: password
    ports:
      - "3306:3306"
    volumes:
      - zabbix-proxy-db:/var/lib/mysql
    deploy:
          resources:
            limits:
              cpus: '1'
              memory: 800m

volumes:
  zabbix-proxy-db:

and this is the agent:

services:
    zabbix-agent:
        restart: always
        container_name: zabbix-agent
        ports:
            - 10050:10050
        volumes:
            - /proc:/host/proc:ro
            - /sys:/host/sys:ro
            - /dev:/host/dev:ro
            - /etc:/host/etc:ro
            - /:/rootfs:ro
            - /var/run/docker.sock:/var/run/docker.sock
        environment:
            - ZBX_HOSTNAME=xxxx
            - ZBX_SERVER_HOST=10.1.10.223 #Private IP proxy
            - ZBX_SERVER_PORT=10051
        privileged: true
        image: zabbix/zabbix-agent2
        deploy:
          resources:
            limits:
              cpus: '2'
              memory: 100m
        user: root

The proxy and agent are green and receiving metrics in the GUI.

STEPS TO REPRODUCE

enter the docker proxy container and run zabbix_get command:

#docker exec -it zabbix-proxy bash
#zabbix_get -s XXX.XXX.XXX.XXX -k docker.container_stats.cpu_usage.total.rate["/zabbix-agent"]
EXPECTED RESULTS

The cpu_usage rate

ACTUAL RESULTS
ZBX_NOTSUPPORTED: Unknown metric docker.container_stats.cpu_pct_usage
fcaputomobeats commented 7 months ago

I tested multiple metrics and mixed them up.

The actual output for the given steps to reproduce is:

ZBX_NOTSUPPORTED: Unknown metric docker.container_stats.cpu_usage.total.rate
dotneft commented 7 months ago

The item key is not Zabbix agent key. Please check carefully template where it comes from.