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

feat(cloudquery-usage): Track CloudQuery plugin usage #1394

Merged
merged 2 commits into from
Jan 27, 2025

Conversation

akash1810
Copy link
Member

@akash1810 akash1810 commented Jan 25, 2025

What does this change and why?

Creates a new AWS Lambda that tracks plugin usage per day by calling the GetTeamUsageSummary endpoint and storing the results in a new database table cloudquery_plugin_usage.

By default, yesterday's data is collected. This can be overridden by setting the START_DATE and END_DATE environment variables, enabling us to backfill data.

The contents of this table will look something like this:

timestamp name metric value
2025-01-23 00:00:00.000000 cloudquery/source/aws paid_rows 1234
2025-01-23 00:00:00.000000 cloudquery/source/fastly paid_rows 12
2025-01-23 00:00:00.000000 cloudquery/source/github paid_rows 567
2025-01-23 00:00:00.000000 cloudquery/source/snyk paid_rows 89
2025-01-24 00:00:00.000000 cloudquery/source/aws paid_rows 1240
2025-01-24 00:00:00.000000 cloudquery/source/fastly paid_rows 12
2025-01-24 00:00:00.000000 cloudquery/source/github paid_rows 570
2025-01-24 00:00:00.000000 cloudquery/source/snyk paid_rows 89

This allows us to monitor our daily usage to ensure we do not breach our contract.

Unfortunately, the API does not return the version of the plugin used. This would be helpful as, when looking through the data, we can see a big spike from 04 July 2024, which can be attributed to #1153.

How has it been verified?

I've deployed to CODE and ran the lambda to backfill data from 01 Jan 2024 to now.

@akash1810 akash1810 force-pushed the aa/cloudquery-usage branch 2 times, most recently from bd1757b to 444a02e Compare January 25, 2025 10:29
@akash1810 akash1810 force-pushed the aa/cloudquery-usage branch from 444a02e to 49af7cb Compare January 25, 2025 10:42
@@ -57,3 +57,5 @@ ENABLE_MESSAGING=false
INTERACTIVES_COUNT=3

STACK=deploy

CQ_API_KEY_PATH=/CODE/deploy/service-catalogue/cloudquery-api-key
Copy link
Member Author

Choose a reason for hiding this comment

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

Locally, use the API key for CODE.

@@ -1,3 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
# It should be added in your version-control system (e.g., Git)
Copy link
Member Author

Choose a reason for hiding this comment

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

This file is generated by Prisma. This must be the first time creating a migration since #1389.

@akash1810 akash1810 marked this pull request as ready for review January 25, 2025 11:22
@akash1810 akash1810 requested review from a team as code owners January 25, 2025 11:22
Creates a new service that writes to a new database table `cloudquery_plugin_usage`
tracking the number of paid rows are synced per plugin, per day.
@akash1810 akash1810 force-pushed the aa/cloudquery-usage branch from 49af7cb to bed5ea1 Compare January 26, 2025 09:20
@akash1810 akash1810 merged commit 635ffee into main Jan 27, 2025
7 checks passed
@akash1810 akash1810 deleted the aa/cloudquery-usage branch January 27, 2025 13:58
@akash1810
Copy link
Member Author

By default, yesterday's data is collected. This can be overridden by setting the START_DATE and END_DATE environment variables, enabling us to backfill data.

I've just ran a backfill of PROD from 01 Jan 2024 to now (26 Jan 2025).

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

Successfully merging this pull request may close these issues.

2 participants