Skip to content

Integrations


Configure security log parsing rules in Security Monitoring > Integrations. When an application places the login account, action, and status in a single piece of raw text, you can extract this information into separate fields, then search by account and status, or pass it to detection rules to count the number of failed logins.

First, find a target log from Security Logs in the receiving workspace, and confirm its source and format. If the required fields already exist, you can query them directly. If the fields are still in the raw text, follow the steps below to prepare samples, configure parsing, and verify with new logs.

Prepare Log Samples

Select a representative log and record the following information.

  • Source. Record the log's source value, such as audit.demo, to set the processing scope of the rule.
  • Content to parse. Confirm the field that actually contains the raw text, such as message, and note whether its format is JSON or plain text.
  • Target fields. First determine what needs to be extracted from subsequent queries or detection conditions. For example, to count failed logins, you need the action and status; to trace back, you also need the account and source IP.

Log formats may differ across sources or versions. In addition to a normal sample, prepare a sample with missing fields or a different format to check whether the script matches the actual data format.

Use Official Templates

If a template matches the source and format, you can reuse it first. For example, if the raw text is JSON, confirm that the template reads the field that stores the JSON.

  1. Go to Security Monitoring > Integrations, click Official Template Library, and find a template applicable to the target log.
  2. View the rule description and parsing script, and verify the input format and output fields.
  3. Clone the template, enter the rule name and description, and change Source to the log source to process.
  4. Adjust the script according to the log format, then test and enable the rule.

Create a Custom Parsing Rule

If the logs contain custom fields, you can create a rule.

Go to Security Monitoring > Integrations and click Create Parsing Rule. In Basic Settings, enter a name and description, and use Source to specify the log scope.

  • For Source, you can select an existing source or use wildcards. * matches any number of characters, and ? matches a single character. For example, audit.* matches audit.demo and audit.prod. Before using wildcards, confirm that the matching sources use the same log format.
  • If you only need to parse a specific source, enter the Source and leave Set as Default Parsing Rule cleared. Before setting it as the default, confirm that the script is suitable for generic log formats.

Extract JSON Fields for Login Events

This example uses a login log written through API ingestion. Select audit.demo for Source, and click Fetch Sample to retrieve an existing record. Alternatively, in Test Sample, select JSON format and paste the following content. In the sample, message is the raw text string, and the inner double quotation marks must be escaped.

{
  "source": "audit.demo",
  "message": "{\"event_id\":\"security-log-example\",\"actor\":\"alice\",\"action\":\"login\",\"status\":\"failure\",\"ip\":\"203.0.113.10\"}"
}

Paste the following script in Manual > Source Code.

json(_, actor)
json(_, action)
json(_, status)
json(_, ip)

_ represents the original log text message, and json() extracts the specified fields from the raw text. For parameter usage, see the json() function.

During testing, verify that the account, action, status, and source IP are output as the following fields.

{
  "actor": "alice",
  "action": "login",
  "status": "failure",
  "ip": "203.0.113.10"
}

For plain text, use grok() to extract fields. When you need to compare values numerically, use cast() to convert types.

Generate a Script with AI

Switch to AI Generation, and describe the content to extract and the field names based on the sample. For example, extract the account, action, status, and IP from message and write them to actor, action, status, and ip, respectively. Click Generate Parsing Rule, then test the generated script with actual samples. Adjust it based on the output and save it.

Test and Enable the Rule

  1. Click Add Sample to add logs, up to 3. You can use samples with complete and missing fields to compare the output.
  2. Click Validate Syntax to check the syntax, and then click Start Test to check the actual output of the script for the samples. Click View Results to reopen the test results.
  3. After verifying the output for each sample, click Save. Return to the Integrations list and confirm that the rule is enabled.
  4. Verify that it takes effect using a newly written log from the target source. In Security Monitoring > Security Logs, select the corresponding time range and search for this log by source:audit.demo. Open the details to verify the extracted fields and values.

Use Parsed Fields

After the fields are verified, search in Security Logs for source:audit.demo AND action:login AND status:failure. Confirm that the filtered records are indeed login failures, then use actor or ip to narrow the scope. For details, see Query Security Logs.

To continuously detect anomalous logins, create detection rules using the same source and fields. When a rule is triggered, view the results in Signals, and then use the time or object to trace back to the raw text.

Troubleshoot Parsing Results

Symptom
Check
The target log cannot be found in Security Logs Check the receiving workspace, data ingestion status, and query time range. First confirm that the log has been written, and then check the parsing rule.
The log exists but does not have the target fields Check whether the rule is enabled and whether the source of the new log matches the rule.
The test reports a script error Review the validation or test message, and check the fields and function parameters read by the script. If the script reads message, confirm that the sample contains this field.
Fields are missing or values do not match Check the sample structure, JSON path, or Grok pattern. Replace the example with an actual log and compare the expected value and test result field by field.
The test result meets expectations, but the actual log fields still do not match Check the save and enable status, and then verify with a new log. The source and format of the new log should match the test sample.
No detection is triggered after extraction Search logs by detection time and filter conditions, and check the field types and conditions. For details, see Execution Logs.

Logs that match a parsing rule are counted toward Central Pipeline usage based on the original data size. For details, see Integration Parsing Billing.