Reference

Repair data after an upgrade

The background operations OpenCTI runs to repair data consistency after an upgrade, how they are scheduled, and how to estimate, run or stop them.

OpenCTIFor platform engineers and administrators

The data sanity manager is a background process that repairs data when a new version of OpenCTI changes how data is computed, for example how two entities are recognized as the same. After an upgrade, it is why some entities get merged without anyone asking. This page lists its operations, how they run, what they write to the logs, and the API calls that let you estimate, schedule or stop them.

How operations run

UPGRADEMANAGERDATACONTROLNew versionBrings new operationsData sanity managerEvery 10 minutes, one nodeKnowledgeRepaired once per operationHealth screenData > Health > OperationsGraphQL APIEstimate, schedule, stop
  1. New version → Data sanity manager: operations to run
  2. Data sanity manager → Knowledge: estimate, then repair
  3. Health screen → Data sanity manager: schedule a run
  4. GraphQL API → Data sanity manager: dry run, run
How the data sanity manager repairs data after an upgrade
  • The manager runs on the platform nodes every 10 minutes by default, one node at a time: a lock keeps two nodes from running it together.
  • Every operation is of type run_once: the manager runs it once, at its first cycle after the upgrade that brings it. It logs the estimated impact first, then applies the changes. It does not run it again unless you schedule a new run.
  • An operation still marked as running after 24 hours, for example because the node restarted, is considered stale and runs again at the next cycle.
  • A failure is recorded with its message, and the next operations still run.
  • An operation whose result cannot be recorded stays marked as running: later cycles skip it until it turns stale. Stop it to release it sooner.
Key (environment variable)DefaultEffect
data_sanity_manager:enabled (DATA_SANITY_MANAGER__ENABLED)trueTurns the manager off. The operations an upgrade brings then wait until it is on again
data_sanity_manager:interval (DATA_SANITY_MANAGER__INTERVAL)600000Time between two cycles, in milliseconds. A scheduled run waits up to this long
data_sanity_manager:stale_running_threshold (DATA_SANITY_MANAGER__STALE_RUNNING_THRESHOLD)86400000 (not in default.json)Time, in milliseconds, after which a run still marked as running is considered stale. An invalid value falls back to the default with a warning

The configuration reference lists them with the other managers.

Operations

Case sensitive Duplicated ID

IdentifiercaseSensitiveDuplicatedId
Typerun_once
Entity typesAttack Pattern, Course of Action

OpenCTI used to tell entities apart by case, so Phishing and phishing could exist as two attack patterns. The identifier is now computed without case, so these entities are duplicates. The operation recomputes the identifier of every Attack Pattern and Course of Action, groups the entities that now share one, and merges each group into a single entity.

The entity kept is the one with the most relationships, then the oldest, so the fewest relationships move. Relationships, markings, labels and STIX identifiers of the others are kept on it. A group that fails to merge is logged and skipped; the rest of the run goes on.

Follow and control operations

With the GraphQL API

The same actions exist in the GraphQL API, as the GraphQL schema reference lists them, with a token of a user who has Bypass all capabilities. Every call takes the identifier of the operation.

CallKindDoes
dataSanityOperationsQueryLists the operations with their state and last run
dataSanityOperationDryRun(operation_name)QueryReturns estimated_impact, a count per entity type, without changing data
dataSanityOperationRequestRun(operation_name)MutationSchedules a run for the next cycle
dataSanityOperationStop(operation_name)MutationMarks the operation as done and cancels a scheduled run. It does not interrupt a run in progress

Estimate before you schedule: the dry run counts what a run would change, per entity type, and changes nothing. Stop an operation that a node restart left running when you do not want it to start again by itself once it turns stale, for example during a migration window; schedule it again with dataSanityOperationRequestRun when you are ready. dataSanityOperations then returns last_run_success: false and last_run_message: "Operation stopped manually" for it.

For example, to estimate the impact of the duplicate merge:

query {
  dataSanityOperationDryRun(operation_name: "caseSensitiveDuplicatedId") {
    estimated_impact {
      key
      count
    }
  }
}

Follow operations in the logs

Every line of the manager in the platform logs starts with [DATA_SANITY_MANAGER]. The ones to watch after an upgrade:

MessageMeans
Estimating run_once impact before actual runThe estimate, logged with its result before any change
Executing data sanity operationThe run starts, with the operation identifier
Data sanity operation completed successfullyThe run ended, with executionTimeMs
Operation marked as running but considered stale (warning)A run left running for longer than data_sanity_manager:stale_running_threshold is allowed to run again
MessageMeans
Data sanity operation failed (warning)The run stopped on an error, given in cause
Data sanity operation result could not be recorded (error)The run ended but its state was not saved: the operation stays marked as running

A run you schedule with dataSanityOperationRequestRun logs the same messages, the estimate included.

The merge operation also logs its progress per entity type: the number of entities evaluated, the number of groups to merge, and each merge, so that you can follow a long run on a large platform.

What's next

NextMap CSV files to knowledge
OpenCTI
Cyber threat intelligence as a knowledge graph: ingest, analyze, automate, share.

Published

Overview