Skip to content

Create



POST /api/v1/logging_query_rule/add

Overview

Create a log access rule.

Prerequisites and Usage Steps

First determine the data domain, roles, sources, and DQL conditions, then create the rule with a unique name. A new rule with status=0 is immediately enabled; a successful write does not prove that the source has data or that the final member permissions meet expectations.

This legacy endpoint does not accept regionCode. When it is not provided, an empty string is stored and interpreted by read/query operations according to the current site. This create endpoint does not support explicitly submitting regionCode; source sites are handled according to the actual rules of the current endpoint.

A write replaces the configuration, commits it to the database, then clears the rule cache and records an audit entry; cross-site validation may also read/update resource metadata. The steps are not a single atomic transaction. After a 500/timeout, first check the list/details to confirm whether the rule has been saved, to avoid blindly creating duplicates.

Saving a rule affects the data query scope/result masking for subsequently matching identities; it does not modify, delete, or backfill raw data, nor does it add basic query permissions to roles. Multiple roles and rules are merged according to query-side policies; final permissions cannot be inferred from a single rule. Owner is exempt. The administrator and workspace "Data Access Scope Restriction" setting changes how unmatched roles are handled. Acceptance should be performed using actual queries by a representative member. Saving invalidates the rule cache and cannot guarantee that all in-flight queries switch immediately.

Request Headers

Parameter Type Required Description
DF-API-KEY string Y OpenAPI authentication credential for the workspace.
Example: <DF-API-KEY>
How to obtain or enter: Obtain an OpenAPI Key with this operation permission from API Key Management in the target workspace.

Body Request Parameters

Parameter Type Required Description
indexes[*] string Array members should be non-empty strings; the original declaration did not enforce this item by item, and an incorrect type can cause a 500.
Example: default
How to obtain or enter: A single log index UUID/default, or an authorized wksp_source:lgim_index.
roleUUIDs[*] string Use a valid role; do not use an account UUID.
Example: role_example
How to obtain or enter: A role uuid available in this workspace, or a standalone *.
extend.custom_key any Any serializable JSON value; it is not an additional effective condition.
Example: production
How to obtain or enter: Display/edit context defined by the caller; keep it consistent with the actual conditions.
reExprs[*] json Use only name/enable/reExpr where possible; the original declaration did not enforce the structure of array elements, and non-objects can cause a 500.
Example: {"name": "token", "enable": true, "reExpr": "tkn_[0-9A-Za-z]+"}
How to obtain or enter: Each object defines one masking expression.
reExprs[*].name string Optional display name; it is not used as a matching expression, and omitting it does not affect regex matching.
Example: token
How to obtain or enter: A business-defined display name for the regex.
reExprs[*].enable boolean Explicit boolean recommended; if omitted, it is treated as disabled. Disabled regexes must still be syntactically valid.
Example: true
How to obtain or enter: true when it needs to be applied; false when staged but not applied.
reExprs[*].reExpr string Non-empty regex recommended. Currently, an omitted value is checked as an empty string; do not rely on the server to complete a valid expression.
Example: tkn_[0-9A-Za-z]+
How to obtain or enter: The actual sensitive content pattern; in a JSON string, backslashes must be double-escaped.
name string Can be omitted; when omitted/an empty string, an attempt is made to generate it from the calling identity display name and the current Unix seconds. Updates also regenerate it and do not retain the old name. Maximum 64 count units (ASCII/half-width katakana 1, other characters 2); both enabled and disabled rules of the same type participate in duplicate-name checks.
Null allowed: False
Empty string allowed: False
Maximum length: 64
Example: production_only
How to obtain or enter: Named by the business side; first check existing names of the same type from the Log Access Rule List.
desc string Optional, maximum 256 of the same count units; if omitted/an empty string, it is cleared to empty; an update does not preserve the original value.
Null allowed: False
Empty string allowed: True
Maximum length: 256
Example: 仅允许查看生产环境数据。
How to obtain or enter: The business side enters the rule purpose and intended audience.
indexes array Y Array of log index identifiers, required for this module; ["*"] means all available log indexes. It is recommended to use * alone; [] does not mean all. Use a UUID for a regular index, not a name; saving a rule does not create workspace or site authorization.
Null allowed: False
Example: ["default"]
How to obtain or enter: Obtain the uuid from the Log Index List; use default for the default index. For cross-workspace, use the authorized source workspace UUID:index UUID.
roleUUIDs array Y Required array of role UUIDs; ["*"] means all roles; [] matches no roles. Owner is still not subject to data access restrictions. A regular UUID is validated for existence within the scope, but the role status is not guaranteed to be 0; basic query permissions must still be granted separately.
Null allowed: False
Example: ["role_example"]
How to obtain or enter: Obtain the uuid of a role in this workspace from the Role List; use the Workspace Member List to verify members' actual roles.
conditions string Y Required log filter expression; it is not a complete query or outer braces. It is recommended not to exceed 4048 characters. The current logging path does not fully parse according to keyevent's E query rules; a successful save does not guarantee that all subsequent queries can be executed.
Null allowed: False
Example: `env` = 'production'
How to obtain or enter: Construct DQL filter conditions from the actual tags/fields of the target data; first verify with a query on the same source.
extend json Optional arbitrary JSON for display; defaults to {}; there are no uniformly required subkeys or units, and the server does not automatically generate conditions from it. An update replaces it entirely; do not store credentials.
Null allowed: False
Example: {}
How to obtain or enter: The client saves display configuration as needed for its own editor; use {} when not needed.
logic string Y Compatibility display field, usually and/or; required in the create declaration and may be omitted on update. If omitted, an empty string is stored; the actual effective filter uses conditions directly, and changing logic does not rewrite the conditions. Multi-role/multi-rule merging is not controlled by this field.
Null allowed: False
Example: and
How to obtain or enter: Keep it consistent with the condition combination method in the client filter editor.
maskFields string Optional; if omitted, an empty string means field masking is not configured for this rule; omitting it on update clears it. When a field is selected and reExprs=[], non-null values are masked as the entire field with ***; when a non-empty regex list is provided, only enabled regexes are applied; disabling all is not the same as whole-field masking. It is recommended to use ≤256 characters to fit the storage column.
Null allowed: False
Empty string allowed: True
Example: message
How to obtain or enter: Select actual field names from the query results; separate multiple fields with English commas, for example message,user_email; when * selects all, it must be used alone and not mixed with specific fields.
reExprs array Optional; defaults to []; an update replaces it entirely. On save, every regex is validated, including items with enable=false; an invalid regex returns ft.ErrorRegularExpression. Do not use a standalone * to represent any string; use .*. When a selected field has no regex, the entire field is ***; regexes only process matching fragments in string content and replace the matched content with ***. Save validation differs from the execution engine; after a successful save, still verify with a representative query.
Null allowed: False
Example: [{"name": "token", "enable": true, "reExpr": "tkn_[0-9A-Za-z]+"}]
How to obtain or enter: Write a regex executable by Python re according to the sensitive value format, verify it with a masked sample first; use it together with maskFields.

Additional Parameter Notes

Data Notes.*

1. Role Authorization and Access Notes 1. A specified role can only query data within the specified query scope. 2. If a user has multiple roles and one of the user's roles is not among the roles in this rule, this data access rule does not take effect for the user, meaning the query scope is not restricted. 3. Multiple log data access rules in a workspace are logically related with OR.

2. Request Parameter Notes

Parameter type Required Description
name string Y Name
desc String N Description
indexes array Y Log index information. For index authorization from another workspace (workspace authorization is required), use workspace UUID:index UUID, e.g., ["wksp_111:lgim_222", "wksp_333:lgim_444"]
roleUUIDs array Y List of role UUIDs
conditions string N Filter conditions for the actually used data scope, e.g., "device IN ['PC'] and session_has_replay IN ['1']"
extend dict Y Extended field that stores the structured content of conditions for frontend page display, e.g., {"device": [ "PC"], "session_has_replay": [1]}
logic string N Logic field, and/or, used to connect filter conditions
maskFields string N Masked fields; separate multiple fields with commas
reExprs array N Regular expressions, e.g., [{"name":"1111","enable":true,"reExpr":"tkn_[\da-z]*"},{"name":"liuyltest","enable":true,"reExpr":"test"}]

Request Example

curl --request POST 'https://openapi.guance.com/api/v1/logging_query_rule/add' \
  -H 'DF-API-KEY: <DF-API-KEY>' \
  -H 'Content-Type: application/json' \
  --data-raw '{"name":"production_only","desc":"仅允许查看生产环境数据。","indexes":["default"],"roleUUIDs":["role_example"],"conditions":"`env` = '"'"'production'"'"'","extend":{},"logic":"and","maskFields":"message","reExprs":[{"name":"token","enable":true,"reExpr":"tkn_[0-9A-Za-z]+"}]}'

Response

HTTP 200, application/json. The example below shows the main fields that can be read directly.

Field Type Description
content.id integer or null Record ID; the snapshot returned on create before commit may be null; use uuid for subsequent operations.
content.uuid string lqrl_ rule UUID; the two modules share the same entity and identifier.
content.workspaceUUID string Workspace to which this rule belongs, as distinct from the source workspace.
content.status integer 0 enabled, 2 disabled, 3 deleted; reads in this module return only non-deleted records.
content.creator string Creation identity.
content.updator string Most recent updater identity; may be empty initially.
content.createAt integer Creation time in Unix seconds.
content.updateAt integer Update time in Unix seconds; -1 if not updated.
content.deleteAt integer Deletion time in Unix seconds; -1 if not deleted.
content.name string Saved value: Can be omitted; when omitted/an empty string, an attempt is made to generate it from the calling identity display name and the current Unix seconds. Updates also regenerate it and do not retain the old name. Maximum 64 count units (ASCII/half-width katakana 1, other characters 2); both enabled and disabled rules of the same type participate in duplicate-name checks.
content.desc string Saved value: Optional, maximum 256 of the same count units; if omitted/an empty string, it is cleared to empty; an update does not preserve the original value.
content.indexes array Currently saved log index identifier array; ["*"] means all available log indexes; it is still subject to actual source authorization.
content.indexes[] string Saved value: Array members should be non-empty strings; the original declaration did not enforce this item by item, and an incorrect type can cause a 500.
content.roleUUIDs array Currently saved array of applicable role UUIDs; ["*"] means all roles; [] matches no roles; basic permissions must still be granted separately.
content.roleUUIDs[] string Saved value: Use a valid role; do not use an account UUID.
content.conditions string Currently saved log filter expression; this read does not re-run event E query validation.
content.extend json Saved value: Optional arbitrary JSON for display; defaults to {}; there are no uniformly required subkeys or units, and the server does not automatically generate conditions from it. An update replaces it entirely; do not store credentials.
content.extend.custom_key any Saved value: Any serializable JSON value; it is not an additional effective condition.
content.logic string Saved value: Compatibility display field, usually and/or; required in the create declaration and may be omitted on update. If omitted, an empty string is stored; the actual effective filter uses conditions directly, and changing logic does not rewrite the conditions. Multi-role/multi-rule merging is not controlled by this field.
content.maskFields string Saved value: Optional; if omitted, an empty string means field masking is not configured for this rule; omitting it on update clears it. When a field is selected and reExprs=[], non-null values are masked as the entire field with ***; when a non-empty regex list is provided, only enabled regexes are applied; disabling all is not the same as whole-field masking. It is recommended to use ≤256 characters to fit the storage column.
content.reExprs array Saved value: Optional; defaults to []; an update replaces it entirely. On save, every regex is validated, including items with enable=false; an invalid regex returns ft.ErrorRegularExpression. Do not use a standalone * to represent any string; use .*. When a selected field has no regex, the entire field is ***; regexes only process matching fragments in string content and replace the matched content with ***. Save validation differs from the execution engine; after a successful save, still verify with a representative query.
content.reExprs[] json Saved value: Use only name/enable/reExpr where possible; the original declaration did not enforce the structure of array elements, and non-objects can cause a 500.
content.reExprs[].name string Saved value: Optional display name; it is not used as a matching expression, and omitting it does not affect regex matching.
content.reExprs[].enable boolean Saved value: Explicit boolean recommended; if omitted, it is treated as disabled. Disabled regexes must still be syntactically valid.
content.reExprs[].reExpr string Saved value: Non-empty regex recommended. Currently, an omitted value is checked as an empty string; do not rely on the server to complete a valid expression.
content.sources array Compatibility entity field; for log-specific creation, it is saved as an empty array; on update, it is not assigned and existing content is retained. This API does not accept sources input.
content.sources[] string Saved value: A single source interpreted according to the parent type; a non-empty string is recommended.
content.type string Fixed to logging; this log-specific API does not accept type input.
content.regionCode string Currently saved log source site code; a legacy empty string is treated as the current site; it does not indicate that a source authorization was created.
content.declaration object or null Workspace common declaration attached to a non-empty business object; when not configured, it may be null or an empty object; empty objects are not added.
{
  "code": 200,
  "content": {
    "id": null,
    "uuid": "lqrl_example",
    "workspaceUUID": "wksp_example",
    "name": "production_only",
    "desc": "仅允许查看生产环境数据。",
    "type": "logging",
    "indexes": [
      "default"
    ],
    "sources": [],
    "roleUUIDs": [
      "role_example"
    ],
    "conditions": "`env` = 'production'",
    "extend": {},
    "logic": "and",
    "maskFields": "message",
    "reExprs": [
      {
        "name": "token",
        "enable": true,
        "reExpr": "tkn_[0-9A-Za-z]+"
      }
    ],
    "regionCode": "",
    "status": 0,
    "creator": "wsak_example",
    "updator": "",
    "createAt": 1785427200,
    "updateAt": -1,
    "deleteAt": -1,
    "declaration": {}
  },
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

Error Responses

For authentication, rate limiting, and common request errors, see Common Error Definitions.

HTTP Status errorCode Trigger Condition Message or Response Description Resolution
406 ft.ParameterValidationFailed A request field is missing, or a field value violates the declared validation conditions Parameter parsing failed Check the parameter location, field name, type, and value.
400 ft.RequestJsonFormatError Invalid request JSON syntax Request JSON format error Fix the JSON according to content.reason, line, and column.
404 ft.NoInitOtherNodeCfg No available source site address was found when reading or validating remote index/RUM application metadata Other node configuration not initialized An administrator should check the source site configuration, accessible address, and valid cross-workspace authorization, then retry after fixing.
400 ft.NameRepeat A non-deleted rule with the same name of the same type exists in this workspace Name already exists Change the name, or update the existing UUID after verification.
400 ft.ErrorRegularExpression Any regex is invalid, including disabled items Regular expression error Fix all reExpr values, then submit; do not use a standalone *.
400 ft.InvalidRoleUUID The given role UUID is not within the allowed workspace scope, or the role identifier is invalid Invalid role UUID: {} Obtain a valid identifier from the current workspace role list; when all roles are needed, explicitly use the wildcard configuration supported on this page, and do not enter an account UUID.
400 ft.InvalidLoggingIndex The regular index in the resolved current-site source workspace does not exist or has been deleted Invalid index:{} Use a valid index UUID/default and verify authorization.
400 ft.InvalidRegionDataQueryRuleIndex The indexes in this log rule mix multiple sites, or the index site does not match the source site Invalid index information for site {} Configure by site separately, and verify the source authorization and site of each log index.
500 ft.InternalServerError Array item shape does not match, field exceeds storage length, ordinary downstream 5xx, database failure, or post-commit cache failure Internal error Check the structure and length described in this document, read the current configuration to confirm whether it has been persisted, then decide whether to retry; provide the traceId.

Feedback

Is this page helpful?