optscale icon indicating copy to clipboard operation
optscale copied to clipboard

Last seen is in the future

Open ffaraone opened this issue 2 months ago • 5 comments

Describe the bug We noticed that, for many resources, the "last seen" date is in the future. For the majority of them, the last seen is set to the day after today. Looking at mongodb resources collection, we found resources like:

 {
    _id: '2e9acf30-f638-41b0-9e2b-c898a236a051',
    first_seen: 1677628800,
    region: 'eu-north-1',
    resource_type: 'Snapshot',
    service_name: 'AmazonEC2',
    _last_seen_date: ISODate('2025-11-02T00:00:00.000Z'),
    _first_seen_date: ISODate('2023-03-01T00:00:00.000Z'),
    active: true,
    created_at: 1693029581,
    last_seen: 1762048809,
    deleted_at: 0
  }

To Reproduce Steps to reproduce the behavior:

  1. Go to Resources
  2. Click on: filter by last seen today
  3. Scroll down to: resources table
  4. See: last seen in the future

Expected behavior "last seen" shouldn't be in the future

Screenshots

Image

ffaraone avatar Oct 30 '25 08:10 ffaraone

@ffaraone can you please check raw expenses on the resource details page for those resources? do you see any records about expenses in the future?

maxb-hystax avatar Oct 30 '25 09:10 maxb-hystax

Image sorry, I forgot that UI doesn't allow you to set date range past today. then, please take a look on raw_expenses collection in MongoDB and check for the future expenses there, like:

db.raw_expenses.find({"cloud_account_id": <cloud_account_id>, "resource_id": <cloud_resource_id>, "start_date": {$gte: ISODate('2025-10-30T00:00:00.000Z')}})

maxb-hystax avatar Oct 30 '25 09:10 maxb-hystax

I checked an Azure virtual machine scale set with "last seen" set to tomorrow and it doesn't have expenses in the future (db.raw_expenses.find({"cloud_account_id": "266dc482-1577-446e-8642-f15393a39797", "resource_id": "b7d741fb-347a-4510-be06-734e9d91058f", "start_date": {$gte: ISODate('2025-10-31T00:00:00.000Z')}})). We also see items like "Global-SoftwareUsage-Contracts" whose last seen date appears to be set to the contract expiration date, or VM snapshots whose last seen date appears to be set to the end of the retention period.

ffaraone avatar Oct 31 '25 08:10 ffaraone

Hi @ffaraone! Suppose you've used OptScale resource id instead of cloud_resource_id in your query ("resource_id": "b7d741fb-347a-4510-be06-734e9d91058f"). cloud_resource_id represents an id of resource in Azure cloud, it usually looks like /subscriptions/<subscription>/resourcegroups/<rg>/providers/microsoft.compute/virtualmachinescalesets/<id>. You may get it from resource details page: Image

nk-hystax avatar Oct 31 '25 10:10 nk-hystax

Hi @nk-hystax! Yes I used the Optscale resource id in this query:

(db.raw_expenses.find({"cloud_account_id": "266dc482-1577-446e-8642-f15393a39797", "resource_id": "b7d741fb-347a-4510-be06-734e9d91058f", "start_date": {$gte: ISODate('2025-10-31T00:00:00.000Z')}})).

Furthermore, looks like that for resources like in the following screenshot:

Image

The last_seen attribute is set with the contract end date, and if so, IMO, it confuses clients.

ffaraone avatar Nov 04 '25 10:11 ffaraone