- Elasticsearch 指南其他版本
- 8.17 中的新功能
- Elasticsearch 基础
- 快速入门
- 设置 Elasticsearch
- 升级 Elasticsearch
- 索引模块
- 映射
- 文本分析
- 索引模板
- 数据流
- 摄取管道
- 别名
- 搜索您的数据
- 重新排名
- 查询 DSL
- 聚合
- 地理空间分析
- 连接器
- EQL
- ES|QL
- SQL
- 脚本
- 数据管理
- 自动缩放
- 监视集群
- 汇总或转换数据
- 设置高可用性集群
- 快照和还原
- 保护 Elastic Stack 的安全
- Watcher
- 命令行工具
- elasticsearch-certgen
- elasticsearch-certutil
- elasticsearch-create-enrollment-token
- elasticsearch-croneval
- elasticsearch-keystore
- elasticsearch-node
- elasticsearch-reconfigure-node
- elasticsearch-reset-password
- elasticsearch-saml-metadata
- elasticsearch-service-tokens
- elasticsearch-setup-passwords
- elasticsearch-shard
- elasticsearch-syskeygen
- elasticsearch-users
- 优化
- 故障排除
- 修复常见的集群问题
- 诊断未分配的分片
- 向系统中添加丢失的层
- 允许 Elasticsearch 在系统中分配数据
- 允许 Elasticsearch 分配索引
- 索引将索引分配过滤器与数据层节点角色混合,以在数据层之间移动
- 没有足够的节点来分配所有分片副本
- 单个节点上索引的分片总数已超过
- 每个节点的分片总数已达到
- 故障排除损坏
- 修复磁盘空间不足的数据节点
- 修复磁盘空间不足的主节点
- 修复磁盘空间不足的其他角色节点
- 启动索引生命周期管理
- 启动快照生命周期管理
- 从快照恢复
- 故障排除损坏的存储库
- 解决重复的快照策略失败问题
- 故障排除不稳定的集群
- 故障排除发现
- 故障排除监控
- 故障排除转换
- 故障排除 Watcher
- 故障排除搜索
- 故障排除分片容量健康问题
- 故障排除不平衡的集群
- 捕获诊断信息
- REST API
- API 约定
- 通用选项
- REST API 兼容性
- 自动缩放 API
- 行为分析 API
- 紧凑和对齐文本 (CAT) API
- 集群 API
- 跨集群复制 API
- 连接器 API
- 数据流 API
- 文档 API
- 丰富 API
- EQL API
- ES|QL API
- 功能 API
- Fleet API
- 图表探索 API
- 索引 API
- 别名是否存在
- 别名
- 分析
- 分析索引磁盘使用量
- 清除缓存
- 克隆索引
- 关闭索引
- 创建索引
- 创建或更新别名
- 创建或更新组件模板
- 创建或更新索引模板
- 创建或更新索引模板(旧版)
- 删除组件模板
- 删除悬挂索引
- 删除别名
- 删除索引
- 删除索引模板
- 删除索引模板(旧版)
- 存在
- 字段使用情况统计信息
- 刷新
- 强制合并
- 获取别名
- 获取组件模板
- 获取字段映射
- 获取索引
- 获取索引设置
- 获取索引模板
- 获取索引模板(旧版)
- 获取映射
- 导入悬挂索引
- 索引恢复
- 索引段
- 索引分片存储
- 索引统计信息
- 索引模板是否存在(旧版)
- 列出悬挂索引
- 打开索引
- 刷新
- 解析索引
- 解析集群
- 翻转
- 收缩索引
- 模拟索引
- 模拟模板
- 拆分索引
- 解冻索引
- 更新索引设置
- 更新映射
- 索引生命周期管理 API
- 推理 API
- 信息 API
- 摄取 API
- 许可 API
- Logstash API
- 机器学习 API
- 机器学习异常检测 API
- 机器学习数据帧分析 API
- 机器学习训练模型 API
- 迁移 API
- 节点生命周期 API
- 查询规则 API
- 重新加载搜索分析器 API
- 存储库计量 API
- 汇总 API
- 根 API
- 脚本 API
- 搜索 API
- 搜索应用程序 API
- 可搜索快照 API
- 安全 API
- 身份验证
- 更改密码
- 清除缓存
- 清除角色缓存
- 清除权限缓存
- 清除 API 密钥缓存
- 清除服务帐户令牌缓存
- 创建 API 密钥
- 创建或更新应用程序权限
- 创建或更新角色映射
- 创建或更新角色
- 批量创建或更新角色 API
- 批量删除角色 API
- 创建或更新用户
- 创建服务帐户令牌
- 委托 PKI 身份验证
- 删除应用程序权限
- 删除角色映射
- 删除角色
- 删除服务帐户令牌
- 删除用户
- 禁用用户
- 启用用户
- 注册 Kibana
- 注册节点
- 获取 API 密钥信息
- 获取应用程序权限
- 获取内置权限
- 获取角色映射
- 获取角色
- 查询角色
- 获取服务帐户
- 获取服务帐户凭据
- 获取安全设置
- 获取令牌
- 获取用户权限
- 获取用户
- 授予 API 密钥
- 具有权限
- 使 API 密钥失效
- 使令牌失效
- OpenID Connect 准备身份验证
- OpenID Connect 身份验证
- OpenID Connect 注销
- 查询 API 密钥信息
- 查询用户
- 更新 API 密钥
- 更新安全设置
- 批量更新 API 密钥
- SAML 准备身份验证
- SAML 身份验证
- SAML 注销
- SAML 失效
- SAML 完成注销
- SAML 服务提供商元数据
- SSL 证书
- 激活用户配置文件
- 禁用用户配置文件
- 启用用户配置文件
- 获取用户配置文件
- 建议用户配置文件
- 更新用户配置文件数据
- 具有用户配置文件权限
- 创建跨集群 API 密钥
- 更新跨集群 API 密钥
- 快照和还原 API
- 快照生命周期管理 API
- SQL API
- 同义词 API
- 文本结构 API
- 转换 API
- 使用情况 API
- Watcher API
- 定义
- 迁移指南
- 发行说明
- Elasticsearch 版本 8.17.0
- Elasticsearch 版本 8.16.1
- Elasticsearch 版本 8.16.0
- Elasticsearch 版本 8.15.5
- Elasticsearch 版本 8.15.4
- Elasticsearch 版本 8.15.3
- Elasticsearch 版本 8.15.2
- Elasticsearch 版本 8.15.1
- Elasticsearch 版本 8.15.0
- Elasticsearch 版本 8.14.3
- Elasticsearch 版本 8.14.2
- Elasticsearch 版本 8.14.1
- Elasticsearch 版本 8.14.0
- Elasticsearch 版本 8.13.4
- Elasticsearch 版本 8.13.3
- Elasticsearch 版本 8.13.2
- Elasticsearch 版本 8.13.1
- Elasticsearch 版本 8.13.0
- Elasticsearch 版本 8.12.2
- Elasticsearch 版本 8.12.1
- Elasticsearch 版本 8.12.0
- Elasticsearch 版本 8.11.4
- Elasticsearch 版本 8.11.3
- Elasticsearch 版本 8.11.2
- Elasticsearch 版本 8.11.1
- Elasticsearch 版本 8.11.0
- Elasticsearch 版本 8.10.4
- Elasticsearch 版本 8.10.3
- Elasticsearch 版本 8.10.2
- Elasticsearch 版本 8.10.1
- Elasticsearch 版本 8.10.0
- Elasticsearch 版本 8.9.2
- Elasticsearch 版本 8.9.1
- Elasticsearch 版本 8.9.0
- Elasticsearch 版本 8.8.2
- Elasticsearch 版本 8.8.1
- Elasticsearch 版本 8.8.0
- Elasticsearch 版本 8.7.1
- Elasticsearch 版本 8.7.0
- Elasticsearch 版本 8.6.2
- Elasticsearch 版本 8.6.1
- Elasticsearch 版本 8.6.0
- Elasticsearch 版本 8.5.3
- Elasticsearch 版本 8.5.2
- Elasticsearch 版本 8.5.1
- Elasticsearch 版本 8.5.0
- Elasticsearch 版本 8.4.3
- Elasticsearch 版本 8.4.2
- Elasticsearch 版本 8.4.1
- Elasticsearch 版本 8.4.0
- Elasticsearch 版本 8.3.3
- Elasticsearch 版本 8.3.2
- Elasticsearch 版本 8.3.1
- Elasticsearch 版本 8.3.0
- Elasticsearch 版本 8.2.3
- Elasticsearch 版本 8.2.2
- Elasticsearch 版本 8.2.1
- Elasticsearch 版本 8.2.0
- Elasticsearch 版本 8.1.3
- Elasticsearch 版本 8.1.2
- Elasticsearch 版本 8.1.1
- Elasticsearch 版本 8.1.0
- Elasticsearch 版本 8.0.1
- Elasticsearch 版本 8.0.0
- Elasticsearch 版本 8.0.0-rc2
- Elasticsearch 版本 8.0.0-rc1
- Elasticsearch 版本 8.0.0-beta1
- Elasticsearch 版本 8.0.0-alpha2
- Elasticsearch 版本 8.0.0-alpha1
- 依赖项和版本
查找字段结构 API
编辑查找字段结构 API
编辑查找 Elasticsearch 索引中字段的结构。
请求
编辑GET _text_structure/find_field_structure
先决条件
编辑- 如果启用了 Elasticsearch 安全功能,您必须具有
monitor_text_structure
或monitor
集群权限才能使用此 API。请参阅 安全权限。
描述
编辑此 API 为从已摄取到 Elasticsearch 中的日志消息中提取更多信息提供了一个起点。例如,如果您已将数据摄取到只有一个 @timestamp
和 message
字段的非常简单的索引中,则可以使用此 API 查看 message
字段中存在的常见结构。
API 的响应包含
- 示例消息。
- 统计信息,显示在文本中检测到的所有字段的最常用值以及数字字段的基本数字统计信息。
- 有关文本结构的信息,当您编写摄取配置以索引它或类似格式的文本时,此信息非常有用。
- 适用于 Elasticsearch 索引的映射,您可以使用它来摄取文本。
所有这些信息都可以由结构查找器在没有指导的情况下计算出来。但是,您可以选择通过指定一个或多个查询参数来覆盖有关文本结构的一些决策。
可以在示例中看到输出的详细信息。
如果结构查找器产生意外的结果,请指定 explain
查询参数,并且响应中将显示一个 explanation
。它有助于确定为什么选择返回的结构。
查询参数
编辑-
index
- (必需,字符串) 包含该字段的索引的名称。
-
field
- (必需,字符串) 要分析的字段的名称。
-
column_names
- (可选,字符串) 如果您已将
format
设置为delimited
,则可以在逗号分隔的列表中指定列名。如果未指定此参数,则结构查找器将使用文本的标题行中的列名。如果文本没有标题行,则列名为“column1”、“column2”、“column3”等。 -
delimiter
- (可选,字符串) 如果您已将
format
设置为delimited
,则可以指定用于分隔每行中值的字符。仅支持单个字符;分隔符不能有多个字符。默认情况下,API 会考虑以下可能性:逗号、制表符、分号和管道符 (|
)。在这种默认情况下,所有行必须具有相同数量的字段才能检测到分隔格式。如果您指定一个分隔符,则最多 10% 的行可以具有与第一行不同的列数。 -
documents_to_sample
- (可选,无符号整数) 要包含在结构分析中的文档数。最小值为 2;默认值为 1000。
-
explain
- (可选,布尔值) 如果为
true
,则响应将包含一个名为explanation
的字段,该字段是一个字符串数组,指示结构查找器如何生成其结果。默认值为false
。 -
format
- (可选,字符串) 文本的高级结构。有效值是
ndjson
、xml
、delimited
和semi_structured_text
。默认情况下,API 会选择格式。在这种默认情况下,所有行必须具有相同数量的字段才能检测到分隔格式。但是,如果format
设置为delimited
并且未设置delimiter
,则 API 最多容忍 5% 的行的列数与第一行不同。 -
grok_pattern
- (可选,字符串) 如果您已将
format
设置为semi_structured_text
,则可以指定一个 Grok 模式,该模式用于从文本中的每条消息中提取字段。Grok 模式中时间戳字段的名称必须与timestamp_field
参数中指定的名称匹配。如果未指定该参数,则 Grok 模式中时间戳字段的名称必须与“timestamp”匹配。如果未指定grok_pattern
,则结构查找器会创建一个 Grok 模式。 -
ecs_compatibility
- (可选,字符串) 与 ECS 兼容 Grok 模式的兼容模式。当结构查找器创建 Grok 模式时,使用此参数指定是否使用 ECS Grok 模式而不是旧模式。有效值是
disabled
和v1
。默认值为disabled
。当整个消息 Grok 模式(例如%{CATALINALOG}
)与输入匹配时,此设置主要会产生影响。如果结构查找器识别出一种常见的结构,但不知道其含义,则在grok_pattern
输出中使用通用字段名称,例如path
、ipaddress
、field1
和field2
,目的是让了解其含义的用户在使用它之前重命名这些字段。 -
quote
- (可选,字符串) 如果您已将
format
设置为delimited
,则可以指定一个字符,如果每行中的值包含换行符或分隔符字符,则可以使用该字符来引用这些值。仅支持单个字符。如果未指定此参数,则默认值为双引号 ("
)。如果您的分隔文本格式不使用引号,则一种解决方法是将此参数设置为样本中任何位置都不会出现的字符。 -
should_trim_fields
- (可选,布尔值) 如果您已将
format
设置为delimited
,则可以指定是否应从分隔符之间的值中删除空格。如果未指定此参数且分隔符是管道符 (|
),则默认值为true
。否则,默认值为false
。 -
timeout
- (可选,时间单位) 设置结构分析可能花费的最长时间。如果超时到期时分析仍在运行,则将停止分析。默认值为 25 秒。
-
timestamp_field
-
(可选,字符串) 包含文本中每条记录的主要时间戳的字段的名称。特别是,如果将文本摄取到索引中,则此字段将用于填充
@timestamp
字段。如果
format
为semi_structured_text
,则此字段必须与grok_pattern
中相应提取的名称匹配。因此,对于半结构化文本,最好不要指定此参数,除非也指定了grok_pattern
。对于结构化文本,如果您指定此参数,则该字段必须存在于文本中。
如果未指定此参数,则结构查找器会决定哪个字段(如果有)是主要时间戳字段。对于结构化文本,文本中不强制必须具有时间戳。
-
timestamp_format
-
(可选,字符串) 文本中时间戳字段的 Java 时间格式。
仅支持 Java 时间格式字母组的子集
-
a
-
d
-
dd
-
EEE
-
EEEE
-
H
-
HH
-
h
-
M
-
MM
-
MMM
-
MMMM
-
mm
-
ss
-
XX
-
XXX
-
yy
-
yyyy
-
zzz
此外,如果
S
字母组(小数秒)的长度为 1 到 9,则它们必须出现在ss
之后,并与ss
之间用.
、,
或:
分隔。还允许使用空格和标点符号,但?
、换行符和回车符以及单引号引起来的文本除外。例如,MM/dd HH.mm.ss,SSSSSS 'in' yyyy
是有效的替代格式。此参数的一个有价值的用例是,当格式为半结构化文本时,文本中有多种时间戳格式,并且您知道哪种格式与主要时间戳对应,但您不想指定完整的
grok_pattern
。另一个用例是当时间戳格式是结构查找器默认情况下不考虑的格式时。如果未指定此参数,则结构查找器会从内置集合中选择最佳格式。
如果指定特殊值
null
,则结构查找器不会在文本中查找主要时间戳。当格式为半结构化文本时,这将导致结构查找器将文本视为单行消息。下表提供了一些示例时间戳的适当
timeformat
值时间格式 表示 yyyy-MM-dd HH:mm:ssZ
2019-04-20 13:15:22+0000
EEE, d MMM yyyy HH:mm:ss Z
Sat, 20 Apr 2019 13:15:22 +0000
dd.MM.yy HH:mm:ss.SSS
20.04.19 13:15:22.285
有关日期和时间格式语法的更多信息,请参阅 Java 日期/时间格式文档。
-
示例
编辑分析 Elasticsearch 日志文件
编辑假设您的索引中有一个 Elasticsearch 日志消息列表。您可以使用 find_field_structure
端点分析它们,如下所示
resp = client.bulk( refresh=True, operations=[ { "index": { "_index": "test-logs" } }, { "message": "[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128" }, { "index": { "_index": "test-logs" } }, { "message": "[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]" }, { "index": { "_index": "test-logs" } }, { "message": "[2024-03-05T10:52:41,042][INFO ][o.e.p.PluginsService ] [laptop] loaded module [rest-root]" }, { "index": { "_index": "test-logs" } }, { "message": "[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-core]" }, { "index": { "_index": "test-logs" } }, { "message": "[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-redact]" }, { "index": { "_index": "test-logs" } }, { "message": "[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [ingest-user-agent]" }, { "index": { "_index": "test-logs" } }, { "message": "[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-monitoring]" }, { "index": { "_index": "test-logs" } }, { "message": "[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-s3]" }, { "index": { "_index": "test-logs" } }, { "message": "[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-analytics]" }, { "index": { "_index": "test-logs" } }, { "message": "[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-ent-search]" }, { "index": { "_index": "test-logs" } }, { "message": "[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-autoscaling]" }, { "index": { "_index": "test-logs" } }, { "message": "[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-painless]]" }, { "index": { "_index": "test-logs" } }, { "message": "[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-expression]" }, { "index": { "_index": "test-logs" } }, { "message": "[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-eql]" }, { "index": { "_index": "test-logs" } }, { "message": "[2024-03-05T10:52:43,291][INFO ][o.e.e.NodeEnvironment ] [laptop] heap size [16gb], compressed ordinary object pointers [true]" }, { "index": { "_index": "test-logs" } }, { "message": "[2024-03-05T10:52:46,098][INFO ][o.e.x.s.Security ] [laptop] Security is enabled" }, { "index": { "_index": "test-logs" } }, { "message": "[2024-03-05T10:52:47,227][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] Profiling is enabled" }, { "index": { "_index": "test-logs" } }, { "message": "[2024-03-05T10:52:47,259][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] profiling index templates will not be installed or reinstalled" }, { "index": { "_index": "test-logs" } }, { "message": "[2024-03-05T10:52:47,755][INFO ][o.e.i.r.RecoverySettings ] [laptop] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]" }, { "index": { "_index": "test-logs" } }, { "message": "[2024-03-05T10:52:47,787][INFO ][o.e.d.DiscoveryModule ] [laptop] using discovery type [multi-node] and seed hosts providers [settings]" }, { "index": { "_index": "test-logs" } }, { "message": "[2024-03-05T10:52:49,188][INFO ][o.e.n.Node ] [laptop] initialized" }, { "index": { "_index": "test-logs" } }, { "message": "[2024-03-05T10:52:49,199][INFO ][o.e.n.Node ] [laptop] starting ..." } ], ) print(resp) resp1 = client.text_structure.find_field_structure( index="test-logs", field="message", body=None, ) print(resp1)
response = client.bulk( refresh: true, body: [ { index: { _index: 'test-logs' } }, { message: '[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128' }, { index: { _index: 'test-logs' } }, { message: '[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]' }, { index: { _index: 'test-logs' } }, { message: '[2024-03-05T10:52:41,042][INFO ][o.e.p.PluginsService ] [laptop] loaded module [rest-root]' }, { index: { _index: 'test-logs' } }, { message: '[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-core]' }, { index: { _index: 'test-logs' } }, { message: '[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-redact]' }, { index: { _index: 'test-logs' } }, { message: '[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [ingest-user-agent]' }, { index: { _index: 'test-logs' } }, { message: '[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-monitoring]' }, { index: { _index: 'test-logs' } }, { message: '[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-s3]' }, { index: { _index: 'test-logs' } }, { message: '[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-analytics]' }, { index: { _index: 'test-logs' } }, { message: '[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-ent-search]' }, { index: { _index: 'test-logs' } }, { message: '[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-autoscaling]' }, { index: { _index: 'test-logs' } }, { message: '[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-painless]]' }, { index: { _index: 'test-logs' } }, { message: '[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-expression]' }, { index: { _index: 'test-logs' } }, { message: '[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-eql]' }, { index: { _index: 'test-logs' } }, { message: '[2024-03-05T10:52:43,291][INFO ][o.e.e.NodeEnvironment ] [laptop] heap size [16gb], compressed ordinary object pointers [true]' }, { index: { _index: 'test-logs' } }, { message: '[2024-03-05T10:52:46,098][INFO ][o.e.x.s.Security ] [laptop] Security is enabled' }, { index: { _index: 'test-logs' } }, { message: '[2024-03-05T10:52:47,227][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] Profiling is enabled' }, { index: { _index: 'test-logs' } }, { message: '[2024-03-05T10:52:47,259][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] profiling index templates will not be installed or reinstalled' }, { index: { _index: 'test-logs' } }, { message: '[2024-03-05T10:52:47,755][INFO ][o.e.i.r.RecoverySettings ] [laptop] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]' }, { index: { _index: 'test-logs' } }, { message: '[2024-03-05T10:52:47,787][INFO ][o.e.d.DiscoveryModule ] [laptop] using discovery type [multi-node] and seed hosts providers [settings]' }, { index: { _index: 'test-logs' } }, { message: '[2024-03-05T10:52:49,188][INFO ][o.e.n.Node ] [laptop] initialized' }, { index: { _index: 'test-logs' } }, { message: '[2024-03-05T10:52:49,199][INFO ][o.e.n.Node ] [laptop] starting ...' } ] ) puts response response = client.text_structure.find_field_structure( index: 'test-logs', field: 'message' ) puts response
const response = await client.bulk({ refresh: "true", operations: [ { index: { _index: "test-logs", }, }, { message: "[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128", }, { index: { _index: "test-logs", }, }, { message: "[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]", }, { index: { _index: "test-logs", }, }, { message: "[2024-03-05T10:52:41,042][INFO ][o.e.p.PluginsService ] [laptop] loaded module [rest-root]", }, { index: { _index: "test-logs", }, }, { message: "[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-core]", }, { index: { _index: "test-logs", }, }, { message: "[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-redact]", }, { index: { _index: "test-logs", }, }, { message: "[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [ingest-user-agent]", }, { index: { _index: "test-logs", }, }, { message: "[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-monitoring]", }, { index: { _index: "test-logs", }, }, { message: "[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-s3]", }, { index: { _index: "test-logs", }, }, { message: "[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-analytics]", }, { index: { _index: "test-logs", }, }, { message: "[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-ent-search]", }, { index: { _index: "test-logs", }, }, { message: "[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-autoscaling]", }, { index: { _index: "test-logs", }, }, { message: "[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-painless]]", }, { index: { _index: "test-logs", }, }, { message: "[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-expression]", }, { index: { _index: "test-logs", }, }, { message: "[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-eql]", }, { index: { _index: "test-logs", }, }, { message: "[2024-03-05T10:52:43,291][INFO ][o.e.e.NodeEnvironment ] [laptop] heap size [16gb], compressed ordinary object pointers [true]", }, { index: { _index: "test-logs", }, }, { message: "[2024-03-05T10:52:46,098][INFO ][o.e.x.s.Security ] [laptop] Security is enabled", }, { index: { _index: "test-logs", }, }, { message: "[2024-03-05T10:52:47,227][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] Profiling is enabled", }, { index: { _index: "test-logs", }, }, { message: "[2024-03-05T10:52:47,259][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] profiling index templates will not be installed or reinstalled", }, { index: { _index: "test-logs", }, }, { message: "[2024-03-05T10:52:47,755][INFO ][o.e.i.r.RecoverySettings ] [laptop] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]", }, { index: { _index: "test-logs", }, }, { message: "[2024-03-05T10:52:47,787][INFO ][o.e.d.DiscoveryModule ] [laptop] using discovery type [multi-node] and seed hosts providers [settings]", }, { index: { _index: "test-logs", }, }, { message: "[2024-03-05T10:52:49,188][INFO ][o.e.n.Node ] [laptop] initialized", }, { index: { _index: "test-logs", }, }, { message: "[2024-03-05T10:52:49,199][INFO ][o.e.n.Node ] [laptop] starting ...", }, ], }); console.log(response); const response1 = await client.textStructure.findFieldStructure({ index: "test-logs", field: "message", body: null, }); console.log(response1);
POST _bulk?refresh=true {"index":{"_index":"test-logs"}} {"message":"[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128"} {"index":{"_index":"test-logs"}} {"message":"[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]"} {"index":{"_index":"test-logs"}} {"message":"[2024-03-05T10:52:41,042][INFO ][o.e.p.PluginsService ] [laptop] loaded module [rest-root]"} {"index":{"_index":"test-logs"}} {"message":"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-core]"} {"index":{"_index":"test-logs"}} {"message":"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-redact]"} {"index":{"_index":"test-logs"}} {"message":"[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [ingest-user-agent]"} {"index":{"_index":"test-logs"}} {"message":"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-monitoring]"} {"index":{"_index":"test-logs"}} {"message":"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-s3]"} {"index":{"_index":"test-logs"}} {"message":"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-analytics]"} {"index":{"_index":"test-logs"}} {"message":"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-ent-search]"} {"index":{"_index":"test-logs"}} {"message":"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-autoscaling]"} {"index":{"_index":"test-logs"}} {"message":"[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-painless]]"} {"index":{"_index":"test-logs"}} {"message":"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-expression]"} {"index":{"_index":"test-logs"}} {"message":"[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-eql]"} {"index":{"_index":"test-logs"}} {"message":"[2024-03-05T10:52:43,291][INFO ][o.e.e.NodeEnvironment ] [laptop] heap size [16gb], compressed ordinary object pointers [true]"} {"index":{"_index":"test-logs"}} {"message":"[2024-03-05T10:52:46,098][INFO ][o.e.x.s.Security ] [laptop] Security is enabled"} {"index":{"_index":"test-logs"}} {"message":"[2024-03-05T10:52:47,227][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] Profiling is enabled"} {"index":{"_index":"test-logs"}} {"message":"[2024-03-05T10:52:47,259][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] profiling index templates will not be installed or reinstalled"} {"index":{"_index":"test-logs"}} {"message":"[2024-03-05T10:52:47,755][INFO ][o.e.i.r.RecoverySettings ] [laptop] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]"} {"index":{"_index":"test-logs"}} {"message":"[2024-03-05T10:52:47,787][INFO ][o.e.d.DiscoveryModule ] [laptop] using discovery type [multi-node] and seed hosts providers [settings]"} {"index":{"_index":"test-logs"}} {"message":"[2024-03-05T10:52:49,188][INFO ][o.e.n.Node ] [laptop] initialized"} {"index":{"_index":"test-logs"}} {"message":"[2024-03-05T10:52:49,199][INFO ][o.e.n.Node ] [laptop] starting ..."} GET _text_structure/find_field_structure?index=test-logs&field=message
如果请求未遇到错误,您将收到以下结果
{ "num_lines_analyzed" : 22, "num_messages_analyzed" : 22, "sample_start" : "[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128\n[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]\n", "charset" : "UTF-8", "format" : "semi_structured_text", "multiline_start_pattern" : "^\\[\\b\\d{4}-\\d{2}-\\d{2}[T ]\\d{2}:\\d{2}", "grok_pattern" : "\\[%{TIMESTAMP_ISO8601:timestamp}\\]\\[%{LOGLEVEL:loglevel} \\]\\[.*", "ecs_compatibility" : "disabled", "timestamp_field" : "timestamp", "joda_timestamp_formats" : [ "ISO8601" ], "java_timestamp_formats" : [ "ISO8601" ], "need_client_timezone" : true, "mappings" : { "properties" : { "@timestamp" : { "type" : "date" }, "loglevel" : { "type" : "keyword" }, "message" : { "type" : "text" } } }, "ingest_pipeline" : { "description" : "Ingest pipeline created by text structure finder", "processors" : [ { "grok" : { "field" : "message", "patterns" : [ "\\[%{TIMESTAMP_ISO8601:timestamp}\\]\\[%{LOGLEVEL:loglevel} \\]\\[.*" ], "ecs_compatibility" : "disabled" } }, { "date" : { "field" : "timestamp", "timezone" : "{{ event.timezone }}", "formats" : [ "ISO8601" ] } }, { "remove" : { "field" : "timestamp" } } ] }, "field_stats" : { "loglevel" : { "count" : 22, "cardinality" : 1, "top_hits" : [ { "value" : "INFO", "count" : 22 } ] }, "message" : { "count" : 22, "cardinality" : 22, "top_hits" : [ { "value" : "[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128", "count" : 1 }, { "value" : "[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]", "count" : 1 }, { "value" : "[2024-03-05T10:52:41,042][INFO ][o.e.p.PluginsService ] [laptop] loaded module [rest-root]", "count" : 1 }, { "value" : "[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [ingest-user-agent]", "count" : 1 }, { "value" : "[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-core]", "count" : 1 }, { "value" : "[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-redact]", "count" : 1 }, { "value" : "[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-painless]]", "count" : 1 }, { "value" : "[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-s3]", "count" : 1 }, { "value" : "[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-analytics]", "count" : 1 }, { "value" : "[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-autoscaling]", "count" : 1 } ] }, "timestamp" : { "count" : 22, "cardinality" : 14, "earliest" : "2024-03-05T10:52:36,256", "latest" : "2024-03-05T10:52:49,199", "top_hits" : [ { "value" : "2024-03-05T10:52:41,044", "count" : 6 }, { "value" : "2024-03-05T10:52:41,043", "count" : 3 }, { "value" : "2024-03-05T10:52:41,059", "count" : 2 }, { "value" : "2024-03-05T10:52:36,256", "count" : 1 }, { "value" : "2024-03-05T10:52:41,038", "count" : 1 }, { "value" : "2024-03-05T10:52:41,042", "count" : 1 }, { "value" : "2024-03-05T10:52:43,291", "count" : 1 }, { "value" : "2024-03-05T10:52:46,098", "count" : 1 }, { "value" : "2024-03-05T10:52:47,227", "count" : 1 }, { "value" : "2024-03-05T10:52:47,259", "count" : 1 } ] } } }
有关响应格式的详细描述,或有关摄取分隔文本(例如 CSV)或换行符分隔的 JSON 的其他示例,请参阅查找文本结构端点的示例。