Apache ActiveMQ

Apache ActiveMQ 集成会写入日志并收集存储空间用量和消息指标。存储指标包括内存和磁盘用量。 消息指标包括等待消息数、平均等待时间和过期消息数。

如需详细了解 ActiveMQ,请参阅 Apache ActiveMQ 文档。

前提条件

如需收集 ActiveMQ 遥测数据,您必须安装 Ops Agent:

  • 对于指标,请安装 2.11.0 版或更高版本。
  • 对于日志,请安装 2.15.0 版或更高版本。

此集成支持 ActiveMQ Classic 5.8.x 版到 5.16.x 版。

配置 ActiveMQ 实例

您必须在 ActiveMQ 代理配置中启用 JMX 支持。

为 ActiveMQ 配置 Ops Agent

按照配置 Ops Agent 指南,添加从 ActiveMQ 实例收集遥测数据所需的元素并重启代理。

配置示例

以下命令会创建相关配置来收集和注入 ActiveMQ 的遥测数据:

# Configures Ops Agent to collect telemetry from the app. You must restart the agent for the configuration to take effect.

set -e

# Check if the file exists
if [ ! -f /etc/google-cloud-ops-agent/config.yaml ]; then
  # Create the file if it doesn't exist.
  sudo mkdir -p /etc/google-cloud-ops-agent
  sudo touch /etc/google-cloud-ops-agent/config.yaml
fi

# Create a back up of the existing file so existing configurations are not lost.
sudo cp /etc/google-cloud-ops-agent/config.yaml /etc/google-cloud-ops-agent/config.yaml.bak

# Configure the Ops Agent.
sudo tee /etc/google-cloud-ops-agent/config.yaml > /dev/null << EOF
metrics:
  receivers:
    activemq:
      type: activemq
  service:
    pipelines:
      activemq:
        receivers:
          - activemq
EOF

为使这些更改生效,您必须重启 Ops Agent:

Linux

  1. 要重启代理,请在您的实例上运行以下命令:
    sudo systemctl restart google-cloud-ops-agent
    
  2. 如需确认代理已重启,请运行以下命令并验证“Metrics Agent”和“Logging Agent”组件是否已启动:
    sudo systemctl status "google-cloud-ops-agent*"
    

Windows

  1. 使用 RDP 或类似工具连接到您的实例,然后登录到 Windows。
  2. 右键点击 PowerShell 图标并选择 Run as Administrator,以管理员权限打开 PowerShell 终端
  3. 如需重启代理,请运行以下 PowerShell 命令:
    Restart-Service google-cloud-ops-agent -Force
    
  4. 如需确认代理已重启,请运行以下命令并验证“Metrics Agent”和“Logging Agent”组件是否已启动:
    Get-Service google-cloud-ops-agent*
    

收集日志

ActiveMQ 将日志写入 syslog,默认情况下由 Ops Agent 捕获。无需进行额外的用户配置。

配置指标收集

如需从 ActiveMQ 注入指标,您必须为 ActiveMQ 生成的指标创建接收器,然后为新的接收器创建流水线。

此接收器不支持在配置中使用多个实例,例如,监控多个端点。所有这些实例都会写入相同的时序,并且 Cloud Monitoring 无法区分它们。

如需为 activemq 指标配置接收器,请指定以下字段:

字段 默认值 说明
collection_interval 60s 时长值,例如 30s 或 5m。
endpoint http://localhost:1099 要监控的节点的网址。
password 将 JMX 配置为需要身份验证时配置的密码。
type 该值必须为 activemq。
username 将 JMX 配置为需要身份验证时配置的用户名。

监控的内容

下表提供了 Ops Agent 从 ActiveMQ 实例收集的指标列表。

指标类型
种类、类型
受监控的资源
标签
workload.googleapis.com/activemq.connection.count
GAUGE、INT64
gce_instance
 
workload.googleapis.com/activemq.consumer.count
GAUGE、INT64
gce_instance
broker
destination
workload.googleapis.com/activemq.disk.store_usage
GAUGE、DOUBLE
gce_instance
 
workload.googleapis.com/activemq.disk.temp_usage
GAUGE、DOUBLE
gce_instance
 
workload.googleapis.com/activemq.memory.usage
GAUGE、DOUBLE
gce_instance
broker
destination
workload.googleapis.com/activemq.message.current
GAUGE、INT64
gce_instance
broker
destination
workload.googleapis.com/activemq.message.dequeued
CUMULATIVE、INT64
gce_instance
broker
destination
workload.googleapis.com/activemq.message.enqueued
CUMULATIVE、INT64
gce_instance
broker
destination
workload.googleapis.com/activemq.message.expired
CUMULATIVE、INT64
gce_instance
broker
destination
workload.googleapis.com/activemq.message.wait_time.avg
GAUGE、DOUBLE
gce_instance