Skip to content

Asset merge

Host Agent data enriches or creates Assets in the tenant/site scope. Implemented in ingestor/internal/domain/hostinventory/asset_merge.go (HostMergeService) — in the Ingestor repo, not Backend — called after a host_inventory snapshot is persisted. Ingestor writes directly to assets/asset_network_interfaces/asset_merge_review_queue in the same Azure SQL database Backend uses; Backend still owns those tables’ schema (migrations) and reads them for its own Assets UI, it just isn’t the one writing agent-merge data into them.

  1. For each snapshot, match network_interfaces[].mac against asset_network_interfaces for existing Assets in the same tenant + site as the host agent.
  2. Single match → update Asset fields: has_agent: true, agent_host_id, agent_last_seen_at, agent_version.
  3. No match → create a new Asset with source: host_agent, using a default device_type (code = 'server') and the OS name as the asset name.
  4. Multi-NIC conflict (MACs map to more than one existing Asset) → written to asset_merge_review_queue — no silent merge.

Asset merge failures are logged but don’t fail the ingest request — a snapshot is still stored/acknowledged even if the merge step errors.

sequenceDiagram
    participant Host as Host Agent / Edge proxy
    participant Ing as Ingestor
    participant DB as Azure SQL

    Host->>Ing: POST /v1/ingest (kind: host_inventory)
    Ing->>DB: Store blob + upsert host_inventory_snapshots
    Ing->>DB: Lookup asset_network_interfaces by MAC + tenant + site
    alt Single match
        Ing->>DB: UPDATE assets SET has_agent=1, agent_host_id, ...
    else No match
        Ing->>DB: INSERT assets (source='host_agent') + asset_network_interfaces
    else Multi match
        Ing->>DB: INSERT asset_merge_review_queue
    end
  • The pre-existing single assets.mac_address column and the new asset_network_interfaces table are not kept in sync — regular (non-host-agent) asset create/edit flows don’t populate asset_network_interfaces, so only host-agent-created/merged assets have it populated today.
  • No dedicated UI yet for reviewing asset_merge_review_queue entries — check the table directly.
SymptomCheck
Duplicate assetsMulti-NIC conflict — check asset_merge_review_queue
Asset not updatingHost’s site vs. Asset’s site mismatch (enrollment secret was generated for a different site)
New asset has wrong device typeMerge always defaults to device_types.code = 'server' — edit manually if wrong