第 6 章 Insights 客户端数据重做


Red Hat Insights 使用 Insights 核心集合处理数据收集。为了进行 redaction,核心集合会替换一个有限的 JSON-file (.cache.json 和 .uploader.json)和 shell 脚本数据收集方法。另外,内核集合:

  • 与 Insights 客户端 3.0 及更新版本兼容。
  • 使用 YAML 文件来确定要红色的命令和文件。
  • 使用强大的 Python 数据清理进程。
  • 通过使用 数据源 支持复杂数据收集,并避免使用 JSON 文件(如 uploader.json 和 shell 脚本)可能的限制。
  • 允许您使用更容易维护的数据源,以了解属于 insights-core 的数据源。

有关 Red Hat Insights 客户端核心集合、数据源和集合规则的更多信息,请参阅以下资源:

重要

红帽不再支持使用 .cache.json 和 uploader.json 文件进行红色数据。改为使用 Datasources

防止个人 Identifiable Information (PII)的集合

Red Hat Insights for Red Hat Enterprise Linux 会收集最少的数据,包括可能包含个人可识别信息(PII)的数据。要防止 PII (或其他配置数据)被收集,请应用数据重做。

有关如何 Red Hat Insights for Red Hat Enterprise Linux 处理数据收集的信息,请参阅 Red Hat Insights 数据和应用程序安全性

6.1. 创建并配置所需的红色 YAML 文件

要重新定义 Red Hat Insights 中的数据,您需要 Insights 客户端 3.0 和以下 YAML 配置文件来控制红色操作操作:

  • file-redaction.yaml
  • file-content-redaction.yaml

您可以根据您要进行发布的内容,使用一个或多个文件。

要查找 redact 的项目,Insights 客户端使用 insights-client.conf 配置文件的默认配置来调用 file-redaction.yamlfile-content-redaction.yaml 文件。以下示例显示了 insights-client.conf 文件中 redaction 的默认配置示例:

# Location of the redaction file for commands, files, and components
#redaction_file=/etc/insights-client/file-redaction.yaml

# Location of the redaction file for patterns and keywords
#content_redaction_file=/etc/insights-client/file-content-redaction.yaml

虽然您不需要更改 insights-client.conf 文件的配置,但您需要创建 YAML 文件。

重要

红帽不再支持使用 remove.conf 配置文件来红色数据。

YAML 文件的工作方式

Insights 客户端 /etc/insights-client/file-redaction.yaml 文件列出了您要激活的命令和文件。Python 数据清理进程在 file-redaction.yaml 文件上运行,并重新定义列出的命令和文件。

注意

当 Python 数据清理进程运行时,它会在将指定内容添加到存档文件之前将其重新处理。

/etc/insights-client/file-content-redaction.yaml 定义模式 redaction 和 keyword 替换。对于模式 redaction,进程红色模式或正则表达式,与 YAML 文件中指定的匹配。对于关键字替换,进程会将指定的关键字替换为通用标识符。

6.1.1. 配置 file-redaction.yaml 以 redact 命令和系统文件

您可以创建 /etc/insights-client/file-redaction.yaml 文件,并包括您要重新设计的命令和系统文件列表。当数据 redaction 发生时,Python 数据清理进程运行并分析 YAML 文件的内容。

注意

列出的命令或文件的输出不会包含在上传的存档文件中。

先决条件

  • 您必须熟悉 YAML 语法的基础知识。有关 YAML 的更多信息,请参阅 yaml.org
  • 您必须具有系统的根级别访问权限。

流程

  1. 使用编辑器创建 /etc/insights-client/file-redaction.yaml 文件。
  2. 在 YAML 文件中的单独行中 输入字符串files: 和 command:。

    files:
    
    
    commands:
  3. 输入您要激活的文件和命令。

    1. 在下面的行中 输入您要激活的文件。使用 Datasources 目录中 的信息来识别要指定的文件和命令。例如,如果要重新处理 auditd.conf 文件,这是如何查找:

      files:
        - /etc/audit/auditd.conf
    2. 在以下命令中 输入您要激活的命令。使用 Datasources 目录中 的信息来识别要指定的命令。例如,如果要重新处理 ethtool -i 命令,这是如何查找:

      commands:
        - ethtool_i
  4. 将 YAML 文件保存到 /etc/insights-client/ 中。
  5. 在命令行中仅通过以 root 用户身份运行 ll file-redaction.yaml 来验证 file-redaction.yaml 文件权限是否为 root 用户。

    [root@insights]# ll file-redaction.yaml
    -rw-------. 1 root root 145 Sep 25 17:39 file-redaction.yaml

带有注释的 file-redaction.yaml 文件示例

以下示例显示了一个示例 file-redaction.yaml 文件,其中包含要红色的命令和文件。注释(以 hash 符号前)前的行也提供了帮助您配置 YAML 文件的指导。

# file-redaction.yaml
---
# Redact the entire output of commands
# Specify commands by either full command or by the "symbolic_name" like “ethtool_i.”
# Refer to the “Datasource Catalog” and “General Datasources” at https://insights-core.readthedocs.io/en/latest/specs_catalog.html#general-datasource for a full list of available symbolic_names, and the commands and files they correspond to.

 commands:
- /bin/rpm -qa
- /bin/ls
- ethtool_i

# Redact the entire output of files
# Specify files either by full filename or
by the "symbolic_name" for example, “cluster_conf.”
# Refer to the “Datasource Catalog” and “General Datasources” at https://insights-core.readthedocs.io/en/latest/specs_catalog.html#general-datasource for a full list of available symbolic_names, and the commands and files they correspond to.

files:
- /etc/audit/auditd.conf
- cluster_conf

验证步骤

要验证您的红色文件是否正常工作,您可以使用- no-upload 选项运行 insights- client 命令,然后查看控制台或终端上的输出信息。

  1. 在命令行中,使用-- no-upload 选项输入 insights- client 命令,然后按 Enter 键。

    [root@insights]# insights-client --no-upload
  2. 命令运行并显示信息。以下示例显示了 dmesg 命令和 cluster.conf 文件的 redaction。

    WARNING: Excluding data from files
    Starting to collect Insights data for I-HOST
    WARNING: Skipping command /bin/dmesg
    WARNING: Skipping file /etc/cluster/cluster.conf
    Archive saved at /var/tmp/qsINM9/insights-ITC-4-20190925180232.tar.gz

生成的存档文件会保存到 /var/tmp 中,但该文件不会上传到红帽。

6.1.2. 配置 YAML 模式和关键字 redaction

/etc/insights-client/file-content-redaction.yaml 文件使用两种方法: pattern redaction 和 keyword 替换。pattern redaction 使用模式匹配或正则表达式匹配。在关键字替换中,Python 数据清理过程会将关键字替换为通用标识符。

先决条件

  • 您必须熟悉 YAML 语法的基础知识。解释 YAML 超出了此流程范围。
  • 您必须具有系统的根级别访问权限。

流程

  1. 使用编辑器创建 /etc/insights-client/file-content-redaction.yaml 文件。

    示例

    # file-content-redaction.yaml
    ---
    # Pattern redaction per matching line
    #  Lines that match a pattern are excluded from files and command output.
    #  Patterns are processed in the order that they are listed.
    # Example
    
    patterns:
     - "a_string_1"
     - "a_string_2"
    
    # Regular expression pattern redaction per line
    #  Use "regex:" to wrap patterns with regular expressions"
    # Example
    
    patterns:
     regex:
     - "abc.*def"
     - "localhost[[:digit:]]"
    
    
    # Keyword replacement redaction
    #  Replace keywords in files and command output with generic identifiers
    #  Keyword does not support regex
    # Example
    
    keywords:
    - "1.1.1.1"
    - "My Name"
    - "a_name"

  2. 确保只为 root 所有者设置 file-content-redaction.yaml 文件权限。

    [root@insights]# ll file-content-redaction.yaml
    -rw-------. 1 root root 145 Sep 25 17:39 file-content-redaction.yaml
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.