收集 Microsoft SQL Server 日志
本文档介绍了如何使用 Bindplane 将 Microsoft SQL Server 日志注入 Google Security Operations。解析器可处理结构化(JSON、键值对)和半结构化 (syslog) Microsoft SQL Server 日志。它会提取字段、标准化时间戳、根据 SourceModuleType 和 Message 内容(包括审核日志、登录和数据库事件)处理不同的日志格式,并将其映射到 UDM。它还会对审核记录、登录尝试和数据库操作执行特定的解析逻辑,从而为数据添加额外的上下文和严重级别信息。它使用 syslog 转发器 (NXLog) 从 Windows 事件日志中收集 SQL Server 审核和错误日志,并将其发送到 BindPlane 代理,以便传递到 Google SecOps。
准备工作
请确保满足以下前提条件:
- Google SecOps 实例
- 运行 Microsoft SQL Server 的 Windows Server 2016 或更高版本主机
- 安装和配置 BindPlane 代理和 NXLog 的管理员访问权限
- 如果在代理后面运行,请确保按照 Bindplane 代理要求打开防火墙端口
获取 Bindplane 代理的 Google SecOps 凭据
如需向 Google SecOps 验证 Bindplane 代理,请选择以下方法之一:
- 新部署:使用 Chronicle API(选项 1)。
- 旧版部署:继续使用数据注入身份验证文件(方法 2),直到 Ingestion API 于 2027 年 7 月 20 日停用。
方法 1:为 Chronicle API 创建服务账号(推荐)
- 登录 Google Cloud 控制台,然后选择与您的 Google SecOps 实例关联的 Google Cloud 项目。
- 前往 IAM 和管理 > 服务账号。
- 点击创建服务账号。
- 提供以下配置详细信息:
- 服务账号名称:输入账号的名称(例如
bindplane-ingest)。 - 服务账号说明:输入说明(例如
Bindplane agent log ingestion)。
- 服务账号名称:输入账号的名称(例如
- 点击创建并继续。
- 在向此服务账号授予对项目的访问权限部分,点击选择角色,然后选择 Chronicle Editor。
- 点击继续,然后点击完成。
- 点击您创建的服务账号,然后前往密钥标签页。
- 依次点击添加密钥 > 创建新密钥。
- 选择 JSON,然后点击创建。密钥文件会下载到您的计算机上。
- 将密钥文件另存为 Bindplane 收集器目录(在 Linux 上为
/opt/observiq-otel-collector/ingestion-auth.json,在 Windows 上为C:\Program Files\observIQ OpenTelemetry Collector\ingestion-auth.json)中的ingestion-auth.json,或更新config.yaml中的creds_file_path以与您保存密钥文件的路径相匹配。 - 前往 IAM 和管理 > 设置,然后复制项目编号。您需要此信息才能配置导出器。
方法 2:下载数据注入身份验证文件(旧版)
- 登录 Google SecOps 控制台。
- 依次前往 SIEM 设置 > 收集代理。
- 下载数据注入身份验证文件。
- 将文件安全地保存在将安装 Bindplane 代理的系统上。
获取 Google SecOps 客户 ID
- 登录 Google SecOps 控制台。
- 前往 SIEM 设置 > 个人资料。
- 复制并保存组织详细信息部分中的客户 ID。
安装 Bindplane 代理
根据以下说明在 Windows 或 Linux 操作系统上安装 Bindplane 代理。
Windows 安装
- 以管理员身份打开命令提示符或 PowerShell。
运行以下命令:
msiexec /i "https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi" /quiet
其他安装资源
如需了解其他安装选项,请参阅安装指南。
配置 Bindplane 代理以注入 Syslog 并发送到 Google SecOps
- 访问配置文件:
- 找到
config.yaml文件。在 Windows 上,它通常位于 `C:\Program Files\observIQ\bindplane-agent` 目录中。 - 使用文本编辑器(例如
nano、vi或记事本)打开该文件。
- 找到
按如下方式修改
config.yaml文件:receivers: udplog: # Replace the port and IP address as required listen_address: "0.0.0.0:1514" exporters: chronicle/chronicle_w_labels: protocol: https # Region of your instance, for example us, europe, asia-southeast1 location: <LOCATION> # Project number of the Google Cloud project linked to the instance project: '<PROJECT_NUMBER>' compression: gzip # Adjust the path to the credentials file you downloaded in Step 1 creds_file_path: '/path/to/ingestion-authentication-file.json' # Replace with your actual customer ID from Step 2 customer_id: <YOUR_CUSTOMER_ID> endpoint: chronicle.googleapis.com # Add optional ingestion labels for better organization log_type: 'MICROSOFT_SQL' raw_log_field: body ingestion_labels: service: pipelines: logs/source0__chronicle_w_labels-0: receivers: - udplog exporters: - chronicle/chronicle_w_labels- 根据您基础设施的需要替换端口和 IP 地址。
- 将
<LOCATION>替换为 Google SecOps 实例所在的区域(例如us、europe或asia-southeast1)。导出工具会为此值添加chronicle.googleapis.com前缀。 - 将
<PROJECT_NUMBER>替换为 IAM 和管理 > 设置中的项目编号。 - 将
<customer_id>替换为实际的客户 ID。 - 将
/path/to/ingestion-authentication-file.json更新为获取 Bindplane 代理的 Google SecOps 凭据部分中保存服务账号密钥文件(选项 1)的路径。
旧版提取 API 导出工具
如果您使用选项 2 中的提取身份验证文件,请将
exporters代码块替换为以下内容。将creds_file_path设置为提取身份验证文件的路径,如果您的实例位于美国境外,请将malachiteingestion-pa.googleapis.com替换为您的区域端点(例如europe-malachiteingestion-pa.googleapis.com)。exporters: chronicle/chronicle_w_labels: compression: gzip # Adjust the path to the credentials file you downloaded in Step 1 creds_file_path: '/path/to/ingestion-authentication-file.json' # Replace with your actual customer ID from Step 2 customer_id: <YOUR_CUSTOMER_ID> endpoint: malachiteingestion-pa.googleapis.com # Add optional ingestion labels for better organization log_type: 'MICROSOFT_SQL' raw_log_field: body ingestion_labels:
重启 Bindplane 代理以应用更改
如需在 Windows 中重启 Bindplane 代理,您可以使用服务控制台,也可以输入以下命令:
net stop BindPlaneAgent && net start BindPlaneAgent
在 Windows 事件日志中启用 SQL Server 审核
您可以使用 SQL Server Management Studio (SSMS) GUI 或 T-SQL 命令启用 SQL Server 审核。请选择最适合您环境的选项。
选项 1:通过 SSMS GUI 启用 SQL Server 审核
在 SQL Server Management Studio 界面中创建服务器审核
- 打开 SQL Server Management Studio (SSMS) 并连接到 SQL Server 实例。
- 在对象资源管理器中,展开服务器实例。
- 展开安全文件夹。
- 右键点击 Audits,然后选择 New Audit。
- 在创建审核对话框中,提供以下配置详细信息:
- 审核名称:输入
ChronicleAudit。 - 队列延迟时间(以毫秒为单位):输入
1000。 - 审核日志失败时:选择继续。
- 审核目标位置:选择应用日志。
- 审核名称:输入
- 点击确定以创建审核。
- 在对象资源管理器中,右键点击新建的 ChronicleAudit,然后选择启用审核。
通过 SSMS GUI 创建服务器审核规范
- 在对象资源管理器中,展开安全性。
- 右键点击服务器审核规范,然后选择新建服务器审核规范。
- 在创建服务器审核规范对话框中,提供以下配置详细信息:
- 名称:输入
ChronicleAuditSpec。 - 审核:从菜单中选择 ChronicleAudit。
- 名称:输入
- 在审核操作类型部分,点击添加,然后选择以下审核操作组(选择每个操作组后,点击添加,单独添加每个操作组):
- FAILED_LOGIN_GROUP
- SUCCESSFUL_LOGIN_GROUP
- LOGOUT_GROUP
- SERVER_ROLE_MEMBER_CHANGE_GROUP
- DATABASE_OBJECT_CHANGE_GROUP
- DATABASE_PRINCIPAL_CHANGE_GROUP
- SCHEMA_OBJECT_CHANGE_GROUP
- DATABASE_PERMISSION_CHANGE_GROUP
- 点击确定以创建审核规范。
- 在对象资源管理器中,右键点击新创建的 ChronicleAuditSpec,然后选择启用服务器审核规范。
验证审核配置
- 在对象资源管理器中,依次展开安全性 > 审核。
- 右键点击 ChronicleAudit,然后选择属性。
- 验证状态是否显示为已启动或已启用。
- 依次展开安全性 > 服务器审核规范。
- 右键点击 ChronicleAuditSpec,然后选择属性。
- 验证是否列出了所有八个审核操作组,并且规范已启用。
方法 2:使用 T-SQL 启用 SQL Server 审核
- 打开 SQL Server Management Studio (SSMS) 并连接到 SQL Server 实例。
执行以下 T-SQL 命令,创建写入 Windows 应用日志的服务器审核:
USE master; GO CREATE SERVER AUDIT ChronicleAudit TO APPLICATION_LOG WITH (QUEUE_DELAY = 1000, ON_FAILURE = CONTINUE); GO ALTER SERVER AUDIT ChronicleAudit WITH (STATE = ON); GO创建审核规范以捕获相关安全性事件:
CREATE SERVER AUDIT SPECIFICATION ChronicleAuditSpec FOR SERVER AUDIT ChronicleAudit ADD (FAILED_LOGIN_GROUP), ADD (SUCCESSFUL_LOGIN_GROUP), ADD (LOGOUT_GROUP), ADD (SERVER_ROLE_MEMBER_CHANGE_GROUP), ADD (DATABASE_OBJECT_CHANGE_GROUP), ADD (DATABASE_PRINCIPAL_CHANGE_GROUP), ADD (SCHEMA_OBJECT_CHANGE_GROUP), ADD (DATABASE_PERMISSION_CHANGE_GROUP); GO ALTER SERVER AUDIT SPECIFICATION ChronicleAuditSpec WITH (STATE = ON); GO
此配置可确保将身份验证事件、权限更改和对象修改记录到 Windows 事件日志中。
安装并配置 NXLog,以将事件转发到 Bindplane
- 从 nxlog.co/downloads 下载 NXLog Community Edition。
- 运行安装程序并完成安装向导。
打开位于以下位置的 NXLog 配置文件:
C:\Program Files\nxlog\conf\nxlog.conf将内容替换为以下配置:
define ROOT C:\Program Files\nxlog Moduledir %ROOT%\modules CacheDir %ROOT%\data Pidfile %ROOT%\data\nxlog.pid SpoolDir %ROOT%\data LogFile %ROOT%\data\nxlog.log <Extension _json> Module xm_json </Extension> <Input in_eventlog> Module im_msvistalog Query <QueryList>\ <Query Id="0">\ <Select Path="Application">*[System[Provider[@Name='MSSQLSERVER']]]</Select>\ </Query>\ </QueryList> </Input> <Output out_syslog> Module om_udp Host 127.0.0.1 Port 1514 Exec to_json(); </Output> <Route r1> Path in_eventlog => out_syslog </Route>- 将主机的当前值
127.0.0.1替换为 Bindplane 代理的 IP 地址。 - 确保 Port 值与之前配置的 Bindplane
udplog接收器端口一致。
- 将主机的当前值
保存文件并重启 NXLog 服务:
net stop nxlog && net start nxlog
UDM 映射表
| 日志字段 | UDM 映射 | 逻辑 |
|---|---|---|
AccountName |
principal.user.userid |
如果日志中存在“正在启动数据库”或“日志已备份”等内容,则用于 principal.user.userid。 |
AgentDevice |
additional.fields |
以键值对的形式添加到 additional.fields,键为“AgentDevice”。 |
AgentLogFile |
additional.fields |
作为键值对添加到 additional.fields,键为“AgentLogFile”。 |
agent.hostname |
observer.asset.hostname |
映射到观察方主机名。 |
agent.id |
observer.asset_id |
与 agent.type 串联以形成 observer.asset_id。 |
agent.type |
observer.asset_id |
与 agent.id 串联以形成 observer.asset_id。 |
agent.version |
observer.platform_version |
映射到观察者平台版本。 |
ApplicationName |
principal.application |
映射到主要应用。 |
application_name |
target.application |
映射到目标应用。 |
client_address |
principal.ip |
如果与主机不同,且不是本地或命名管道,则用于主 IP。 |
client_ip |
principal.ip |
映射到主体 IP。 |
computer_name |
about.hostname |
映射到有关主机名。 |
correlationId |
security_result.detection_fields |
以键值对的形式添加到 security_result.detection_fields,键为“correlationId”。 |
Date |
metadata.event_timestamp |
与 Time 结合使用以创建事件时间戳。 |
database_name |
target.resource_ancestors.name |
用于目标资源祖先名称(如果存在于审核日志中)。 |
durationMs |
network.session_duration.seconds |
从毫秒转换为秒并进行映射。 |
ecs.version |
metadata.product_version |
映射到产品版本。 |
error |
security_result.detection_fields |
以键值对的形式添加到 security_result.detection_fields,键为“error”。 |
err_msg |
security_result.description |
映射到安全结果说明。 |
EventID |
metadata.product_event_type |
用于在其他字段不可用时构建商品事件类型,以“EventID: ”为前缀。 |
event.action |
Source |
用作来源(如果存在)。 |
event.code |
metadata.product_event_type |
与 event.provider 结合形成 metadata.product_event_type。 |
event.provider |
metadata.product_event_type |
与event.code组合形成metadata.product_event_type。 |
EventReceivedTime |
metadata.ingested_timestamp |
解析并用作提取时间戳。 |
event_time |
metadata.event_timestamp |
解析并用作事件时间戳。 |
file_name |
principal.process.file.full_path |
映射到主体进程文件完整路径。 |
file_path |
target.file.full_path |
用于目标文件完整路径(如果在备份日志中找到)。 |
first_lsn |
target.resource.attribute.labels |
以键值对的形式添加到 target.resource.attribute.labels,键为“First LSN”。 |
host |
principal.hostname,observer.hostname |
如果不是 IP,则用于主体或观测者主机名。还用于目标主机名或 IP(具体取决于是否为 IP)。 |
host.ip |
principal.ip |
已合并到主要 IP。 |
host.name |
host |
用作主机(如果存在)。 |
Hostname |
principal.hostname,target.hostname |
用于主账号或目标主机名(如果存在)。 |
hostinfo.architecture |
principal.asset.hardware.cpu_platform |
映射到主要资产硬件 CPU 平台。 |
hostinfo.os.build |
additional.fields |
以键值对的形式添加到 additional.fields 中,键为“os_build”。 |
hostinfo.os.kernel |
principal.platform_patch_level |
映射到主要平台补丁级别。 |
hostinfo.os.name |
additional.fields |
以键值对的形式添加到 additional.fields 中,键为“os_name”。 |
hostinfo.os.platform |
principal.platform |
大写并映射到主要平台。 |
hostinfo.os.version |
principal.platform_version |
映射到主要平台版本。 |
last_lsn |
target.resource.attribute.labels |
以键值对的形式添加到 target.resource.attribute.labels 中,键为“Last LSN”。 |
level |
security_result.severity |
如果为“Informational”,则将 security_result.severity 设置为“INFORMATIONAL”。 |
log.level |
security_result.severity_details |
映射到安全结果严重程度详情。 |
LoginName |
principal.user.userid |
如果 KV 日志中存在,则用于主体用户 ID。 |
login_result |
security_result.action |
确定安全结果操作(ALLOW 或 BLOCK)。 |
logon_user |
principal.user.userid |
用于主用户 ID(如果登录日志中存在)。 |
logstash.process.host |
intermediary.hostname |
映射到中间主机名。 |
Message |
metadata.description,security_result.description |
用于事件说明或安全结果说明,具体取决于日志类型。 |
msg |
metadata.description |
用于活动说明(如果有)。 |
ObjectName |
target.resource.name |
映射到目标资源名称。 |
object_name |
target.resource.name |
用于目标资源名称(如果存在于审核日志中)。 |
ObjectType |
target.resource.type |
映射到目标资源类型。 |
operationId |
security_result.detection_fields |
以键值对的形式添加到 security_result.detection_fields,键为“operationId”。 |
operationName |
metadata.product_event_type |
映射到商品事件类型。 |
operationVersion |
additional.fields |
以键值对的形式添加到 additional.fields,键为“operationVersion”。 |
ProcessInfo |
additional.fields |
以键值对的形式添加到 additional.fields,键为“ProcessInfo”。 |
properties.apiVersion |
metadata.product_version |
映射到产品版本。 |
properties.appId |
target.resource.product_object_id |
映射到目标资源产品对象 ID。 |
properties.clientAuthMethod |
extensions.auth.auth_details |
用于确定身份验证详细信息。 |
properties.clientRequestId |
additional.fields |
以键值对的形式添加到 additional.fields,键为“clientRequestId”。 |
properties.durationMs |
network.session_duration.seconds |
转换为秒并进行映射。 |
properties.identityProvider |
security_result.detection_fields |
以键值对的形式添加到 security_result.detection_fields,键为“identityProvider”。 |
properties.ipAddress |
principal.ip,principal.asset.ip |
已解析 IP 并合并到主体 IP 和主体资产 IP 中。 |
properties.location |
principal.location.name |
映射到主营业地点名称。 |
properties.operationId |
security_result.detection_fields |
以键值对的形式添加到 security_result.detection_fields,键为“operationId”。 |
properties.requestId |
metadata.product_log_id |
映射到产品日志 ID。 |
properties.requestMethod |
network.http.method |
映射到网络 HTTP 方法。 |
properties.requestUri |
target.url |
映射到目标网址。 |
properties.responseSizeBytes |
network.received_bytes |
转换为无符号整数并进行映射。 |
properties.responseStatusCode |
network.http.response_code |
已转换为整数并映射。 |
properties.roles |
additional.fields |
以键值对的形式添加到 additional.fields,键为“roles”。 |
properties.servicePrincipalId |
principal.user.userid |
如果 properties.userId 不存在,则用于主用户 ID。 |
properties.signInActivityId |
network.session_id |
映射到网络会话 ID。 |
properties.tenantId |
metadata.product_deployment_id |
映射到商品部署 ID。 |
properties.tokenIssuedAt |
additional.fields |
以键值对的形式添加到 additional.fields,键为“tokenIssuedAt”。 |
properties.userAgent |
network.http.user_agent |
映射到网络 HTTP 用户代理。 |
properties.userId |
principal.user.userid |
用于主用户 ID(如果存在)。 |
properties.wids |
security_result.detection_fields |
以键值对的形式添加到 security_result.detection_fields 中,键为“wids”。 |
reason |
security_result.summary |
用于登录事件中的安全结果摘要。 |
resourceId |
target.resource.attribute.labels |
作为键值对添加到 target.resource.attribute.labels,键为“Resource ID”。 |
schema_name |
target.resource_ancestors.resource_subtype |
用于目标资源祖先子类型(如果审核日志中存在)。 |
security_result.description |
metadata.description |
如果不是审核事件,则用于事件说明。 |
security_result.severity |
security_result.severity |
如果存在,则直接映射。对于 KV 日志,设置为“LOW”;对于某些出错提示,设置为“INFORMATIONAL”;派生自 level 或 Severity 字段。 |
security_result.severity_details |
security_result.severity_details |
直接映射(如果存在)。 |
security_result.summary |
security_result.summary |
如果存在,则直接映射。对于登录事件,设置为“使用 Windows 身份验证建立的连接”或登录事件中的特定原因;对于审核事件,设置为“SQL Server 审核记录”。 |
security_result_action |
security_result.action |
已合并到 security_result.action。对于大多数事件,设置为“ALLOW”;对于登录事件,则派生自 login_result。 |
server_instance_name |
target.hostname |
用于目标主机名(如果审核日志中存在)。 |
server_principal_name |
principal.user.userid |
用于审核日志中的主账号用户 ID(如果存在)。 |
server_principal_sid |
principal.asset_id |
用于构建主账号资产 ID,并以“server SID:”为前缀。 |
session_id |
network.session_id |
用于网络会话 ID(如果存在于审核日志中)。 |
sev |
security_result.severity |
用于确定安全结果的严重程度。 |
Severity |
security_result.severity |
用于确定安全结果严重程度。 |
Source |
additional.fields |
以键值对的形式添加到 additional.fields,键为“Source”。 |
source |
principal.resource.attribute.labels |
以键值对的形式添加到 principal.resource.attribute.labels,键为“source”。 |
SourceModuleType |
observer.application |
映射到观测器应用。 |
SourceModuleName |
additional.fields |
以键值对的形式添加到 additional.fields,键为“SourceModuleName”。 |
source_module_name |
observer.labels |
以键值对的形式添加到 observer.labels,键为“SourceModuleName”。 |
source_module_type |
observer.application |
映射到观察者应用。 |
SPID |
network.session_id |
映射到网络会话 ID。 |
statement |
target.process.command_line |
用于审核日志中存在的目标进程命令行。 |
TextData |
security_result.description,metadata.description |
如果不是登录事件,则用于安全结果说明;如果是登录事件,则用于事件说明。 |
time |
metadata.event_timestamp |
已解析并用作事件时间戳。 |
Time |
metadata.event_timestamp |
与 Date 结合使用以创建事件时间戳。 |
transaction_id |
target.resource.attribute.labels |
以键值对的形式添加到 target.resource.attribute.labels,键为“transaction_id”。 |
UserID |
principal.user.windows_sid |
用于主用户 Windows SID(如果存在且格式正确)。 |
user_id |
principal.user.userid |
用于主用户 ID(如果存在)。 |
metadata.log_type |
metadata.log_type |
硬编码为“MICROSOFT_SQL”。 |
metadata.vendor_name |
metadata.vendor_name |
硬编码为“Microsoft”。 |
metadata.product_name |
metadata.product_name |
硬编码为“SQL Server”。 |
metadata.event_type |
metadata.event_type |
根据日志内容设置为各种值,包括“USER_LOGIN”“USER_LOGOUT”“STATUS_STARTUP”“STATUS_SHUTDOWN”“NETWORK_HTTP”“GENERIC_EVENT”和默认值“STATUS_UNCATEGORIZED”。 |
extensions.auth.type |
extensions.auth.type |
对于登录和退出账号事件,设置为“MACHINE”。 |
更新日志
需要更多帮助?获得社区成员和 Google SecOps 专业人士的解答。