Skip to main content

API - associate alert ids with tenant ids

Thread needs solution
Beginner
Posts: 1
Comments: 0

Hello all,

I am a bit on the lose, I try to automate alerting into our monitoring system.

I get alerts and tenants just fine via api, but I cant figure out how to associate them. Alerts have 

id, activityId, planId or resourceId. But neither of them is associable with the id from the tenants.

Curentlly for testing I have two tenants and one alert.

 

tenant with id 5f8662b2-b056-4698-a007-a9ea4505564d has the alert triggered.

Any way to get them matched?

Or is there way to add the tenant name in the alert?

 

tenants

{
  "items": [
    {
      "language": "en-US",
      "created_at": "2021-08-11T11:50:34",
      "brand_id": 53431,
      "id": "5f8662b2-b056-4698-a007-a9ea4505564d",
      "pricing_mode": "production",
      "version": 7,
      "kind": "customer",
      "updated_at": "2021-10-19T12:03:51",
      "customer_type": "default",
      "customer_id": null,
      "contacts": [],
      "parent_id": "96149462-ba69-4803-b7fa-008841eafd5f",
      "mfa_status": "disabled",
      "brand_uuid": "4bc0679a-af0c-44b2-9af2-298837a24238",
      "ancestral_access": true,
      "default_idp_id": "11111111-1111-1111-1111-111111111111",
      "internal_tag": null,
      "owner_id": null,
      "name": "01684",
      "update_lock": {
        "owner_id": null,
        "enabled": false
      },
      "enabled": true,
      "has_children": false,
      "deleted_at": null,
      "contact": {
        "industry": null,
        "email_confirmed": null,
        "title": null,
        "country": null,
        "phone": null,
        "zipcode": null,
        "organization_size": null,
        "firstname": "",
        "city": null,
        "lastname": "",
        "address1": null,
        "address2": null,
        "state": null,
        "created_at": "2021-08-11T11:50:34+00:00",
        "aan": "16839830",
        "updated_at": "2021-08-11T12:29:42+00:00",
        "email": "",
        "id": "41bbe809-bc55-4d81-9f14-91582778d082",
        "website": null
      }
    },
    {
      "language": "en_US",
      "created_at": "2019-12-06T07:26:42",
      "brand_id": 53431,
      "id": "dc9a5bab-1ce1-4c49-9692-719d453fa577",
      "pricing_mode": "production",
      "version": 9,
      "kind": "customer",
      "updated_at": "2021-10-19T12:03:40",
      "customer_type": "default",
      "customer_id": null,
      "contacts": [],
      "parent_id": "96149462-ba69-4803-b7fa-008841eafd5f",
      "mfa_status": "disabled",
      "brand_uuid": "4bc0679a-af0c-44b2-9af2-298837a24238",
      "ancestral_access": true,
      "default_idp_id": "11111111-1111-1111-1111-111111111111",
      "internal_tag": null,
      "owner_id": null,
      "name": "04254",
      "update_lock": {
        "owner_id": null,
        "enabled": false
      },
      "enabled": true,
      "has_children": false,
      "deleted_at": null,
      "contact": {
        "industry": null,
        "email_confirmed": null,
        "title": null,
        "country": null,
        "phone": null,
        "zipcode": null,
        "organization_size": null,
        "firstname": "",
        "city": null,
        "lastname": "",
        "address1": null,
        "address2": null,
        "state": null,
        "created_at": "2019-12-06T07:26:42+00:00",
        "aan": "06921537",
        "updated_at": "2021-06-12T02:22:34+00:00",
        "email": "",
        "id": "5ef5c7ae-c224-11ea-9c5b-001c422b92e4",
        "website": null
      }
    }
  ],
  "timestamp": "2021-10-07T10:52:50"
}

 

alerts

{
  "items": [
    {
      "id": "3B73F331-3F78-49D5-99F4-929A44F33FCC",
      "type": "BackupFinishedWithWarnings",
      "details": {
        "activity": {
          "id": "329D1770-BC2D-4D5D-BC35-2F023A5D03AA"
        },
        "activityId": "329D1770-BC2D-4D5D-BC35-2F023A5D03AA",
        "backupLocations": [
          {
            "name": "",
            "type": "cloud"
          }
        ],
        "backupSourcesType": "files",
        "finishTime": 1634602630,
        "planId": "814145B7-5D05-4A93-AAA5-4A46597C262C",
        "planName": "PC Data",
        "resourceId": "F4F99230-0483-4045-BA52-0D8A5996C868",
        "resourceName": "User-PC",
        "startTime": 1634602520,
        "warning": {
          "code": 20119654,
          "fields": {
            "$module": "agent_protection_addon_vsa64_27493",
            "unresolvedItems": ....."
          },
          "src": {
            "file": "d:\\2149\\enterprise\\managers\\gtob\\protection\\agent_engine\\backup_job.cpp",
            "func": "Gtob::Protection::`anonymous-namespace'::CreateErrorBasedOnKeyType",
            "line": 222,
            "tag": "0xc37471ceffa1825d"
          },
          "suberror": {},
          "text": "Selected files or folders were not found: .....",
          "types": {
            "$module": "A",
            "unresolvedItems": "W"
          }
        },
        "warningMessage": {
          "code": "ProtectionUnresolvedFilesLocal",
          "context": {
            "cause_str": "Selected files or folders were not found: .....",
            "effect_str": "Selected files or folders were not found: .....",
            "unresolvedItems": "....."
          },
          "domain": "Common",
          "kbLink": {
            "build": 20457,
            "lineTag": "0xC37471CEFFA1825D",
            "os": "Windows",
            "product": "",
            "serCode": "BackupFinishedWithWarnings+0x01330066",
            "version": "15.0"
          },
          "reason": "ProtectionUnresolvedFilesLocal",
          "serCode": "0x01330066"
        },
        "warningsMoreover": 0
      },
      "createdAt": "2021-10-19T00:17:10Z",
      "_source": "4ECB24B6-66FE-4303-8903-D5564419D188",
      "_sourceTimeStamp": 79536,
      "severity": "warning",
      "receivedAt": "2021-08-26T07:23:22.400262814Z",
      "updatedAt": "2021-10-19T00:17:33.638995317Z",
      "tenant": {
        "id": "3307633",
        "locator": "/1/42998/61749/61752/121832/1012203/3307630/3307633/"
      }
    }
  ],
  "paging": {
    "cursors": {}
  }
}

 

Best regards

Elmar

0 Users found this helpful
Acronis engineer
Posts: 0
Comments: 58

Hello Elmar,

Thank you for your post, an interesting topic coming around quite often recently.

Alerts, Agents and Tasks APIs are still using the legacy numeric ID in their APIs, respectively in the responses of various endpoints we have numeric IDs.

In your example response from GET /alerts, focus at the "tenant" object:

"tenant": {
        "id": "3307633",
        "locator": "/1/42998/61749/61752/121832/1012203/3307630/3307633/"
      }

The user itself as entity is a unit tenant, we have the term "tenant" for all entities like partners, folders, customers, units (organizational units) and users. The "id" could be the numeric ID of the personal group ID of the user (different from the numeric user's ID or UUID), this is equal to the personal_tenant_id value of the user. The expected tenant kind in the GET /alerts “tenant.id” field can be of the customer tenant, unit tenant (organizational unit tenant) and personal unit tenant (of the user) as alert owner.

We should work with GET /api/1/groups/{tenant numeric ID from alert 'tenant.id' field ==> 3307633 in your case} to find the relation to the customer tenant. The enumeration in the response of GET /api/1/groups/{group_id}, for “kind”: 40 is the customer tenant, and for “kind”: 50 is the personal unit tenant of the user or the organizational unit tenant. I am just not aware how to distinguish personal unit from organizational unit as both have the same kind in APIv1.

The suggested way is to check if this group is a customer tenant or personal unit tenant by "kind" field's value and search by "parent_id" in the hierarchy upwards in the latter case (personal unit), by calling above call recursively.

For example if you have “kind”: 40 then it is the customer tenant itself, get the 'uuid' value from the same response, this is your customer tenant. And if “kind”: 50, then call GET /api/1/groups/{group_id} again with the value from "parent_id" and from next response again the 'uuid' is your customer tenant. In the case where it is the organizational unit tenant it will be the 'uuid' from the same response where “kind”: 50 but with APIv1 we can't distinguish it. If you always need the customer tenant above the unit tenant, then you will not need to think of this problem.

We are planning to deprecate APIv1, and also because of that migrate and completely remove the numeric IDs from the API and work with 'uuids' only. I have no clear ETA for this, but it should not happen before end of 2022.

I hope this has been useful.