New

The executive guide to generative AI

Read more

配置指标的 HTTP 端点

编辑

此功能处于技术预览阶段,可能会在未来的版本中更改或删除。Elastic 将努力解决任何问题,但技术预览版中的功能不受官方 GA 功能的支持 SLA 的约束。

Metricbeat 可以通过 HTTP 端点公开内部指标。这些指标对于监视 Beat 的内部状态非常有用。出于安全原因,默认情况下禁用该端点,因为你可能希望避免暴露此信息。

HTTP 端点具有以下配置设置

http.enabled
(可选)启用 HTTP 端点。默认为 false
http.host
(可选)绑定到此主机名、IP 地址、Unix 套接字 (unix:///var/run/metricbeat.sock) 或 Windows 命名管道 (npipe:///metricbeat)。建议仅使用 localhost。默认为 localhost
http.port
(可选)HTTP 端点将绑定的端口。默认为 5066
http.named_pipe.user
(可选)用于创建命名管道的用户,仅在 Windows 上有效,默认为当前用户。
http.named_pipe.security_descriptor
(可选)以 SDDL 格式定义的 Windows 安全描述符字符串。默认为当前用户的读写权限。
http.pprof.enabled
(可选)在提供 HTTP 服务时启用 /debug/pprof/ 端点。建议仅在 localhost 上启用此功能,因为这些端点可能会泄露数据。默认为 false
http.pprof.block_profile_rate
(可选)block_profile_rate 控制在 /debug/pprof/block 中提供的阻塞配置文件中报告的 goroutine 阻塞事件的比例。分析器旨在对每个 rate 纳秒阻塞事件平均采样一个阻塞事件。要在配置文件中包含每个阻塞事件,请传递 rate = 1。要完全关闭分析,请传递 rate ⇐ 0。默认为 0。
http.pprof.mem_profile_rate
(可选)mem_profile_rate 控制在 /debug/pprof/heap 中提供的内存配置文件中记录和报告的内存分配比例。分析器旨在对每个 mem_profile_rate 字节分配平均采样一次分配。要在配置文件中包含每个已分配的块,请将 mem_profile_rate 设置为 1。要完全关闭分析,请将 mem_profile_rate 设置为 0。默认为 524288。
http.pprof.mutex_profile_rate
(可选)mutex_profile_rate 控制在 /debug/pprof/mutex 中提供的互斥锁配置文件中报告的互斥锁争用事件的比例。平均报告 1/rate 事件。要完全关闭分析,请传递 rate 0。默认值为 0。

这是你可以访问的路径列表。要获得漂亮的 JSON 输出,请在 URL 中附加 ?pretty

你可以使用 cURL 命令和 --unix-socket 标志查询 Unix 套接字。

curl -XGET --unix-socket '/var/run/{beatname_lc}.sock' 'http:/stats/?pretty'

信息

编辑

/ 提供来自 Metricbeat 的基本信息。示例

curl -XGET 'localhost:5066/?pretty'
{
  "beat": "metricbeat",
  "hostname": "example.lan",
  "name": "example.lan",
  "uuid": "34f6c6e1-45a8-4b12-9125-11b3e6e89866",
  "version": "8.17.0"
}

统计信息

编辑

/stats 报告内部指标。示例

curl -XGET 'localhost:5066/stats?pretty'
{
  "beat": {
    "cpu": {
      "system": {
        "ticks": 1710,
        "time": {
          "ms": 1712
        }
      },
      "total": {
        "ticks": 3420,
        "time": {
          "ms": 3424
        },
        "value": 3420
      },
      "user": {
        "ticks": 1710,
        "time": {
          "ms": 1712
        }
      }
    },
    "info": {
      "ephemeral_id": "ab4287c4-d907-4d9d-b074-d8c3cec4a577",
      "uptime": {
        "ms": 195547
      }
    },
    "memstats": {
      "gc_next": 17855152,
      "memory_alloc": 9433384,
      "memory_total": 492478864,
      "rss": 50405376
    },
    "runtime": {
      "goroutines": 22
    }
  },
  "libbeat": {
    "config": {
      "module": {
        "running": 0,
        "starts": 0,
        "stops": 0
      },
      "scans": 1,
      "reloads": 1
    },
    "output": {
      "events": {
        "acked": 0,
        "active": 0,
        "batches": 0,
        "dropped": 0,
        "duplicates": 0,
        "failed": 0,
        "total": 0
      },
      "read": {
        "bytes": 0,
        "errors": 0
      },
      "type": "elasticsearch",
      "write": {
        "bytes": 0,
        "errors": 0
      }
    },
    "pipeline": {
      "clients": 6,
      "events": {
        "active": 716,
        "dropped": 0,
        "failed": 0,
        "filtered": 0,
        "published": 716,
        "retry": 278,
        "total": 716
      },
      "queue": {
        "acked": 0
      }
    }
  },
  "system": {
    "cpu": {
      "cores": 4
    },
    "load": {
      "1": 2.22,
      "15": 1.8,
      "5": 1.74,
      "norm": {
        "1": 0.555,
        "15": 0.45,
        "5": 0.435
      }
    }
  }
}

实际输出可能包含更多特定于 Metricbeat 的指标

Was this helpful?
Feedback