1

为了发送我的 spring-boot 应用程序的指标端点(/metric),我在 metricbeat 中使用了 http 模块,我按照 elastic.io 网站上的官方文档来安装和配置 metricbeat,但不言而喻,指标的传输尽管已建立连接,但不正确。.我更改了 fields.yml 文件以仅为 http 模块创建特定模板

字段.yml

- key: http
  title: "HTTP"
  description: >
    HTTP module
  release: beta
  settings: ["ssl"]
  fields:
    - name: http
      type: group
      description: >
      fields:
        - name: request
          type: group
          description: >
              HTTP request information
          fields:
            - name: header
              type: object
              description: >
                The HTTP headers sent
            - name: method
              type: keyword
              description: >
                The HTTP method used
            - name: body
              type: keyword
              description: >
                The HTTP payload sent
        - name: response
          type: group
          description: >
              HTTP response information
          fields:
            - name: header
              type: object
              description: >
                The HTTP headers received
            - name: code
              type: keyword
              description: >
                The HTTP status code
              example: 404
            - name: phrase
              type: keyword
              example: Not found
              description: >
                The HTTP status phrase
            - name: body
              type: keyword
              description: >
                The HTTP payload received
        - name: json
          type: group
          description: >
            json metricset
          release: beta
          fields:

        - name: server
          type: group
          description: >
            server
          release: experimental
          fields:

metricbeat.yml

    metricbeat.config.modules:
      # Glob pattern for configuration loading
      path: ${path.config}/modules.d/*.yml
      # Set to true to enable config reloading
      reload.enabled: false
metricbeat.modules:

    #------------------------------- HTTP Module -------------------------------
    - module: http
      metricsets: ["json"]
      period: 10s
      hosts: ["http://localhost:8080/metrics"]
      namespace: "test_metrics"
      method: "GET" 
      enabled: true
      setup.template.overwrite: true
      output.elasticsearch:
         hosts: ["localhost:9200"]

我的应用指标显示:( http://localhost:8080/metrics )

    {
  "mem": 199405,
  "mem.free": 74297,
  "processors": 4,
  "instance.uptime": 45240231,
  "uptime": 45254636,
  "systemload.average": -1,
  "heap.committed": 154624,
  "heap.init": 131072,
  "heap.used": 80326,
  "heap": 1842688,
  "nonheap.committed": 45888,
  "nonheap.init": 2496,
  "nonheap.used": 44781,
  "nonheap": 0,
  "threads.peak": 31,
  "threads.daemon": 25,
  "threads.totalStarted": 35,
  "threads": 27,
  "classes": 6659,
  "classes.loaded": 6659,
  "classes.unloaded": 0,
  "gc.ps_scavenge.count": 24,
  "gc.ps_scavenge.time": 999,
  "gc.ps_marksweep.count": 1,
  "gc.ps_marksweep.time": 71,
  "httpsessions.max": -1,
  "httpsessions.active": 0,
  "gauge.response.metrics": 20,
  "gauge.response.unmapped": 6005,
  "gauge.response.login": 1,
  "gauge.response.star-star.favicon.ico": 1878,
  "counter.status.200.star-star.favicon.ico": 1,
  "counter.status.200.metrics": 30,
  "counter.status.302.unmapped": 3,
  "counter.status.200.login": 2
}

以前,我使用httpbeat,一切都很好,elasticsearch 索引中的字段名称是兼容的......,因为我已经开始使用 http 模块,所以一切都已更改,我正在使用它来获取 kibana 中的预定义仪表板。

请问有什么帮助吗?

4

0 回答 0