HTTP json 度量集

编辑

这是 HTTP 模块的 json 度量集。

功能和配置

编辑

HTTP 端点返回的 JSON 结构将被添加到提供的 namespace 字段中,如下例所示

{
  "@timestamp": "2017-05-01T13:00:24.745Z",
  "beat": {
    "hostname": "mbp",
    "name": "mbp",
    "version": "6.0.0-alpha1"
  },
  "http": {
    "http_json_namespace": {
      "date": "05-01-2017",
      "milliseconds_since_epoch": 1493643625474.000000,
      "time": "01:00:25 PM"
    }
  },
  "metricset": {
    "host": "date.jsontest.com",
    "module": "http",
    "name": "json",
    "namespace": "http_json_namespace",
    "rtt": 238397
  },
  "type": "metricsets"
}

此处,来自 date.jsontest.com 的响应在配置的 http_json_namespace 命名空间中返回。

{
      "date": "05-01-2017",
      "milliseconds_since_epoch": 1493643625474.000000,
      "time": "01:00:25 PM"
}

需要在通用模块配置部分设置命名空间。

json.is_array

编辑

启用此配置后,json 度量集期望 HTTP 端点返回的 JSON 结构为数组。此外,它为数组中的每个元素创建单独的事件。

request.enabled

编辑

启用此配置后,将包含有关请求的其他信息。这包括以下信息:

  • HTTP 头
  • HTTP 方法
  • 主体/有效负载

示例

{
  "@timestamp": "2017-05-01T13:00:24.745Z",
  "beat": {
    "hostname": "mbp",
    "name": "mbp",
    "version": "6.0.0-alpha1"
  },
  "http": {
    "http_json_namespace": {
      "date": "05-01-2017",
      "milliseconds_since_epoch": 1493643625474.000000,
      "time": "01:00:25 PM"
    },
    "request": {
      "body": "",
      "headers": {
        "Accept": "application/json"
      },
      "method": "GET"
    }
  },
  "metricset": {
    "host": "date.jsontest.com",
    "module": "http",
    "name": "json",
    "namespace": "http_json_namespace",
    "rtt": 238397
  },
  "type": "metricsets"
}

response.enabled

编辑

启用此配置后,将包含有关响应的其他信息。这包括以下信息:

  • HTTP 头
  • HTTP 状态码

示例

{
  "@timestamp": "2017-05-01T13:00:24.745Z",
  "beat": {
    "hostname": "mbp",
    "name": "mbp",
    "version": "6.0.0-alpha1"
  },
  "http": {
    "http_json_namespace": {
      "date": "05-01-2017",
      "milliseconds_since_epoch": 1493643625474.000000,
      "time": "01:00:25 PM"
    },
    "response": {
      "headers": {
        "Access-Control-Allow-Origin": "*",
        "Content-Length": "100",
        "Content-Type": "application/json; charset=ISO-8859-1",
        "Date": "Mon, 01 May 2017 13:08:38 GMT",
        "Server": "Google Frontend",
        "X-Cloud-Trace-Context": "3f532d170112fc5b2a0b94fcbd6493b3"
      },
      "code": 200
    }
  },
  "metricset": {
    "host": "date.jsontest.com",
    "module": "http",
    "name": "json",
    "namespace": "http_json_namespace",
    "rtt": 238397
  },
  "type": "metricsets"
}

dedot.enabled

编辑

启用此配置后,JSON 字段名称中的点将替换为 _ 字符。

示例

{
  "@timestamp": "2017-05-01T13:00:24.745Z",
  "beat": {
    "hostname": "mbp",
    "name": "mbp",
    "version": "6.0.0-alpha1"
  },
  "http": {
    "http_json_namespace": {
      "date": "05-01-2017",
      "milliseconds_since_epoch": 1493643625474.000000,
      "time": "01:00:25 PM"
    },
    "response": {
      "headers": {
        "Access-Control-Allow-Origin": "*",
        "Content-Length": "100",
        "Content-Type": "application/json; charset=ISO-8859-1",
        "Date": "Mon, 01 May 2017 13:08:38 GMT",
        "Server": "Google Frontend",
        "X-Cloud-Trace-Context": "3f532d170112fc5b2a0b94fcbd6493b3"
      },
      "code": 200
    }
  },
  "metricset": {
    "host": "date.jsontest.com",
    "module": "http",
    "name": "json",
    "namespace": "http_json_namespace",
    "rtt": 238397
  },
  "type": "metricsets"
}

公开字段、仪表盘、索引等

编辑

由于这是一个通用模块,可以针对任何公开 JSON 结构的应用程序进行定制,因此它没有公开字段描述、仪表盘或索引模式。

字段

有关度量集中每个字段的描述,请参阅导出字段部分。

以下是由此度量集生成的示例文档。

{
    "@timestamp": "2019-03-01T08:05:34.853Z",
    "event": {
        "dataset": "http.test",
        "duration": 115000,
        "module": "http"
    },
    "http": {
        "test": {
            "hello": "world"
        }
    },
    "metricset": {
        "name": "json",
        "period": 10000
    },
    "service": {
        "address": "127.0.0.1:55555",
        "type": "http"
    }
}