Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track usage by BotInstanceID #51540

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

strideynet
Copy link
Contributor

@strideynet strideynet commented Jan 28, 2025

Part of https://github.com/gravitational/cloud/issues/11855

As per RFD0166 - https://github.com/gravitational/cloud/pull/11766

Blocked on https://github.com/gravitational/cloud/pull/11852 merging to keep prehog protos in sync.

Example submitted report:

{
  "userActivity": [
    {
      "reportUuid": "Ybg2ByrsRI+wPGupVu7URw==",
      "clusterName": "+ZO2wFwFwUwJY1KktgC1CipsYhhOYFeC5heNuZ+SjeE=",
      "reporterHostid": "71t3oKtnW66IjxoSq13ejal7cR1ycv5tTjGB/Xn4ALk=",
      "startTime": "2025-01-29T13:45:00Z",
      "records": [
        {
          "userName": "8Bq+CCVzADXtgnj30ZNSF/f4uyqaAlFXp1ao5TxWiCU=",
          "userKind": "USER_KIND_BOT",
          "spiffeSvidsIssued": "3",
          "botJoins": "1",
          "certificatesIssued": "4"
        },
        {
          "userName": "5Hq3LdWDOcM6IMkbjjcS9APZD0YWwlW4zViWgKFTEmo=",
          "userKind": "USER_KIND_HUMAN",
          "logins": "1",
          "certificatesIssued": "1"
        }
      ]
    }
  ],
  "resourcePresence": [
    {
      "reportUuid": "sgYcjoR7Rq+KGVvN9Vg+bg==",
      "clusterName": "+ZO2wFwFwUwJY1KktgC1CipsYhhOYFeC5heNuZ+SjeE=",
      "reporterHostid": "71t3oKtnW66IjxoSq13ejal7cR1ycv5tTjGB/Xn4ALk=",
      "startTime": "2025-01-29T13:00:00Z",
      "resourceKindReports": [
        {
          "resourceKind": "RESOURCE_KIND_APP_SERVER",
          "resourceIds": [
            "15992637790899819489"
          ]
        },
        {
          "resourceKind": "RESOURCE_KIND_NODE",
          "resourceIds": [
            "12563749572309375983"
          ]
        }
      ]
    }
  ],
  "botInstanceActivity": [
    {
      "reportUuid": "YJxrZA86SWWQiNIETyzxAg==",
      "clusterName": "+ZO2wFwFwUwJY1KktgC1CipsYhhOYFeC5heNuZ+SjeE=",
      "reporterHostid": "71t3oKtnW66IjxoSq13ejal7cR1ycv5tTjGB/Xn4ALk=",
      "startTime": "2025-01-29T13:00:00Z",
      "records": [
        {
          "botInstanceId": "0hRudVK6RaFWy+omhvmcYICxrCdG4Qrb+llkLB61zos=",
          "botUserName": "8Bq+CCVzADXtgnj30ZNSF/f4uyqaAlFXp1ao5TxWiCU=",
          "botJoins": "1",
          "spiffeSvidsIssued": "3",
          "certificatesIssued": "4"
        }
      ]
    }
  ]
}

Only backporting to v17/v16 as BotInstance functionality is not present in v15.

@strideynet strideynet changed the title Strideynet/bot instance activity Track usage by BotInstanceID Jan 28, 2025
@strideynet strideynet force-pushed the strideynet/bot-instance-activity branch from b3108ed to 3d542ff Compare January 29, 2025 10:23
@strideynet strideynet added do-not-merge backport/branch/v16 backport/branch/v17 no-changelog Indicates that a PR does not require a changelog entry labels Jan 29, 2025
@strideynet strideynet marked this pull request as ready for review January 29, 2025 14:56
Comment on lines +192 to 196
// Put submission lock in place - whilst this is by-name for
// "user activity reports", it can be considered to protect resource
// presence and bot instance activity too.
debugPayload := fmt.Sprintf("%v %q", time.Now().Round(0), c.HostID)
if err := svc.createUserActivityReportsLock(ctx, submitLockDuration, []byte(debugPayload)); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could rename the method to be more general and move the comment to the lock name const instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants