apache / apache/hertzbeat

[Question] How to collect information from containers with multiple port mappings and data volumes?

Open
#2,695 0 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Java
Stars
7.4k
Forks
1.3k
Avg merge
1d 20h
Merged PRs (30d)
32

Description

### Question

According to the Docker monitoring template , I added indicators for the collection container mapping port and data volume, but only one port mapping and one data volume were collected, how can I collect information from containers with multiple port mappings and data volumes?

My Docker monitoring template:
fields:
- field: privateport
i18n:
zh-CN: 私有端口
en-US: privateport
type: 1
- field: publicport
i18n:
zh-CN: 公有端口
en-US: publicport
type: 1
- field: mountssource
i18n:
zh-CN: 挂载源
en-US: mountssource
type: 1
- field: mountsdestination
i18n:
zh-CN: 挂载目标
en-US: mountsdestination
type: 1
- field: volumename
i18n:
zh-CN: 数据卷名
en-US: volumename
type: 1
aliasFields:
- Id
- $.Names[0]
- Image
- Command
- $.HostConfig.NetworkMode
- $.NetworkSettings.Networks.*.IPAddress
- $.Ports[0].PrivatePort
- $.Ports[0].PublicPort
- $.Mounts[0].Type
- $.Mounts[0].Source
- $.Mounts[0].Destination
- $.Mounts[0].Name
- State
- Status
calculates:
- id = Id
- name=#`$.Names[0]`
- image = Image
- command = Command
- networkmode = $.HostConfig.NetworkMode
- ipaddress = $.NetworkSettings.Networks.*.IPAddress
- privateport = $.Ports[0].PrivatePort
- publicport = $.Ports[0].PublicPort
- mountstype = $.Mounts[0].Type
- mountssource = $.Mounts[0].Source
- mountsdestination = $.Mounts[0].Destination
- volumename = $.Mounts[0].Name
- state = State
- status = Status
# Protocols used for monitoring and collection eg: sql, ssh, http, telnet, wmi, snmp, sdk
# 监控采集使用协议 eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: http
# When the protocol is the http protocol, the specific collection configuration
# 当protocol为http协议时具体的采集配置
http:
# Host host: ipv4 ipv6 domain name
# 主机host: ipv4 ipv6 域名
host: ^_^host^_^
# port
# 端口
port: ^_^port^_^
# url request interface path
# url请求接口路径
url: /containers/json?all=true
# # request method GET POST PUT DELETE PATCH
# 请求方式 GET POST PUT DELETE PATCH
method: GET
# Whether to enable ssl/tls, that is, http or https, the default is false
# 是否启用ssl/tls,即是http还是https,默认false
ssl: ^_^ssl^_^
# Response data analysis method: default-system rules, jsonPath-jsonPath script, website-api usability metric monitoring
# 响应数据解析方式: default-系统规则,jsonPath-jsonPath脚本,website-api可用性指标监控
parseType: jsonPath
parseScript: '$.*'

Contributor guide

Open the contributing guide

Research direction

The issue names the Docker monitoring template and its /containers/json?all=true response, but no repository file or test. Start by examining the aliasFields and calculates entries for Ports and Mounts, then determine and verify how repeated mappings should be represented so all port and volume information is collected.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker
Domain
observability
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.