Red Hat Developer Hub 中的审计日志


Red Hat Developer Hub 1.6

使用 Red Hat Developer Hub 审计日志跟踪用户活动、系统事件和数据更改

Red Hat Customer Content Services

摘要

作为 Red Hat Developer Hub 管理员,您可以使用 Developer Hub 审计日志跟踪用户活动、系统事件和数据更改。

第 1 章 Red Hat Developer Hub 中的审计日志

审计日志是记录用户活动、系统事件和数据更改的记录集,影响您的 Red Hat Developer Hub 用户、管理员或组件。管理员可以查看 OpenShift Container Platform Web 控制台中的 Developer Hub 审计日志,以监控构建器事件、对 RBAC 系统的更改,以及对 Catalog 数据库的更改。审计日志包括以下信息:

  • 审计事件的名称
  • 触发审计事件的操作者,如终端、端口、IP 地址或主机名
  • 事件元数据,如日期、时间
  • 事件状态,如 成功失败
  • 严重性级别,如 infodebugwarnerror

您可以使用审计日志中的信息来实现以下目标:

增强安全性
跟踪活动,包括由自动化系统和软件模板启动到其源的活动。了解何时执行软件模板,以及应用程序和组件安装、更新、配置更改和删除的详细信息。
自动化合规性
使用简化的流程查看指定时间点的日志数据,以满足审计目的或持续合规维护。
调试问题
使用访问记录和活动详情来修复软件模板或插件的问题。
注意

默认情况下,审计日志不会转发到内部日志存储,因为这不提供安全存储。您需要自己确保转发审计日志的系统符合您所在机构及政府的相关要求,并具有适当的安全性。

第 2 章 在 OpenShift Container Platform 上为 Developer Hub 配置审计日志

使用 OpenShift Container Platform Web 控制台将以下 OpenShift Container Platform 日志记录组件配置为使用 Developer Hub 的审计日志记录:

日志记录部署
配置日志记录环境,包括每个日志记录组件的 CPU 和内存限值。如需更多信息,请参阅 Red Hat OpenShift Container Platform - 配置日志记录部署
日志记录收集器
配置 ClusterLogging 自定义资源(CR)中的 spec.collection 小节,以使用支持的对日志收集器的修改,并从 STDOUT 收集日志。如需更多信息,请参阅 Red Hat OpenShift Container Platform - 配置日志记录收集器
日志转发
通过在 ClusterLogForwarder CR 中指定输出和管道的组合,将日志发送到 OpenShift Container Platform 集群内部和外部的特定端点。如需更多信息,请参阅 Red Hat OpenShift Container Platform - 启用 JSON 日志转发Red Hat OpenShift Container Platform - 配置日志转发

2.1. 将 Red Hat Developer Hub 审计日志转发到 Splunk

您可以使用 Red Hat OpenShift Logging (OpenShift Logging) Operator 和 ClusterLogForwarder 实例从 Developer Hub 实例捕获流的审计日志,并将它们转发到与 Splunk 实例关联的 HTTPS 端点。

先决条件

  • 您有一个在受支持的 OpenShift Container Platform 版本上运行的集群。
  • 有具有 cluster-admin 权限的帐户。
  • 您有一个 Splunk Cloud 帐户或 Splunk Enterprise 安装。

流程

  1. 登录您的 OpenShift Container Platform 集群。
  2. openshift-logging 命名空间中安装 OpenShift Logging Operator 并切换到命名空间:

    切换到命名空间的命令示例

    oc project openshift-logging
    Copy to Clipboard

  3. 创建名为 log-collectorserviceAccount,并将 collect-application-logs 角色绑定到 serviceAccount

    创建 serviceAccount的命令示例

    oc create sa log-collector
    Copy to Clipboard

    将角色绑定到 serviceAccount的命令示例

    oc create clusterrolebinding log-collector --clusterrole=collect-application-logs --serviceaccount=openshift-logging:log-collector
    Copy to Clipboard

  4. 在 Splunk 实例中生成 hecToken
  5. openshift-logging 命名空间中创建 key/value secret 并验证 secret:

    使用 hecToken创建键/值 secret 的命令示例

    oc -n openshift-logging create secret generic splunk-secret --from-literal=hecToken=<HEC_Token>
    Copy to Clipboard

    验证 secret 的命令示例

    oc -n openshift-logging get secret/splunk-secret -o yaml
    Copy to Clipboard

  6. 创建一个基本的 'ClusterLogForwarder' 资源 YAML 文件,如下所示:

    'ClusterLogForwarder'resource YAML 文件示例

    apiVersion: logging.openshift.io/v1
    kind: ClusterLogForwarder
    metadata:
      name: instance
      namespace: openshift-logging
    Copy to Clipboard

    如需更多信息,请参阅创建日志转发器

  7. 使用 OpenShift Web 控制台或 OpenShift CLI 定义以下 ClusterLogForwarder 配置:

    1. 在 YAML 文件中将 log-collector 指定为 serviceAccount

      serviceAccount 配置示例

      serviceAccount:
        name: log-collector
      Copy to Clipboard

    2. 配置 输入 以指定要转发的日志的类型和源。以下配置可让转发器从提供命名空间中的所有应用程序捕获日志:

      输入 配置示例

      inputs:
        - name: my-app-logs-input
          type: application
          application:
            includes:
              - namespace: my-rhdh-project
            containerLimit:
              maxRecordsPerSecond: 100
      Copy to Clipboard

      如需更多信息,请参阅 从特定 pod 转发应用程序日志

    3. 配置输出,以指定发送捕获的日志的位置。在这一步中,着重介绍 mvapich 类型。如果 Splunk 端点使用自签名 TLS 证书(不推荐)或使用 Secret 提供证书链,您可以使用 tls.insecureSkipVerify 选项。

      输出 配置示例

      outputs:
        - name: splunk-receiver-application
          type: splunk
          splunk:
            authentication:
              token:
                key: hecToken
                secretName: splunk-secret
            index: main
            url: 'https://my-splunk-instance-url'
            rateLimit:
              maxRecordsPerSecond: 250
      Copy to Clipboard

      如需更多信息,请参阅 OpenShift Container Platform 文档中的 将日志转发到 Splunk

    4. 可选:过滤日志以只包含审计日志:

      过滤器 配置示例

      filters:
        - name: audit-logs-only
          type: drop
          drop:
            - test:
              - field: .message
                notMatches: isAuditEvent
      Copy to Clipboard

      如需更多信息,请参阅 OpenShift Container Platform 文档中的 按内容 过滤日志。

    5. 配置管道,将日志从特定输入路由到指定的输出。使用定义的输入和输出的名称为每个管道指定多个 inputRefsoutputRefs

      管道 配置示例

      pipelines:
        - name: my-app-logs-pipeline
          detectMultilineErrors: true
          inputRefs:
            - my-app-logs-input
          outputRefs:
            - splunk-receiver-application
          filterRefs:
            - audit-logs-only
      Copy to Clipboard

  8. 运行以下命令以应用 ClusterLogForwarder 配置:

    应用 ClusterLogForwarder 配置示例

    oc apply -f <ClusterLogForwarder-configuration.yaml>
    Copy to Clipboard

  9. 可选: 要降低日志丢失的风险,请使用以下选项配置 ClusterLogForwarder pod:

    1. 为日志收集器定义资源请求和限值,如下所示:

      收集器 配置示例

      collector:
        resources:
          requests:
            cpu: 250m
            memory: 64Mi
            ephemeral-storage: 250Mi
          limits:
            cpu: 500m
            memory: 128Mi
            ephemeral-storage: 500Mi
      Copy to Clipboard

    2. 定义日志交付的 调优选项,包括 交付压缩RetryDuration。可以根据需要按输出应用调优。

      调优 配置示例

      tuning:
        delivery: AtLeastOnce 
      1
      
        compression: none
        minRetryDuration: 1s
        maxRetryDuration: 10s
      Copy to Clipboard

      1
      AtLeastOnce 交付模式意味着,如果日志转发器崩溃或重启,任何在崩溃前读取的日志都会重新发送到其目的地。有些日志可能会在崩溃后重复。

验证

  1. 通过在 Splunk 仪表板中查看日志,以确认日志被转发到 Splunk 实例。
  2. 根据需要使用 OpenShift Container Platform 和 Splunk 日志排除任何问题。

第 3 章 在 Developer Hub 中查看审计日志

管理员可以从 Red Hat OpenShift Container Platform Web 控制台查看、搜索、过滤和管理日志数据。您可以使用 isAuditEvent 字段过滤其他日志类型的审计日志。

先决条件

  • 在 OpenShift Container Platform Web 控制台中以管理员身份登录。

流程

  1. 从 OpenShift Container Platform Web 控制台的 Developer 视角中,点 Topology 选项卡。
  2. Topology 视图中,点击您要查看审计日志数据的 pod。
  3. 在 pod 面板中点 Resources 选项卡。
  4. Resources 选项卡的 Pods 部分中,单击 View logs
  5. Logs 视图中,在 Search 字段中输入 isAuditEvent,以过滤来自其他日志类型的审计日志。您可以使用箭头浏览包含 isAuditEvent 字段的日志。

法律通告

Copyright © 2025 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat