Repository navigation
Conversation
Lambda writes monthly_requests and request_duration_ms together from Invocations and Duration, so a missing duration is not filled with the catalog default. NAT writes monthly_data_processed_gb from bytes in, summing availability zones only when the gateway-level metric is empty. Signed-off-by: Atsushi Sakashita <ats@saks.industries>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 3 of the staged plan in
docs/design/usage-sync.md(c3xdev#97): Lambda and NAT gateway quantities from CloudWatch. Stacked on #7 (fork copy of c3xdev#119) so this diff is only this stage.What it measures
aws_lambda_function, the keysresources/aws/aws_lambda_function.tomlreads for invocations and duration:monthly_requestsfromInvocations(Sum), the count over the window expressed per 30 days. The default--days 30is the measured total.seriesis the same rate per calendar month.request_duration_msfromDuration(Sum, milliseconds) divided byInvocations(Sum). That is the invocation-weighted average, and it is not scaled to 30 days.seriesis the same average for each month. A month with invocations but no Duration points is omitted from the duration series.FunctionNameonly.Resource=$LATESTwould drop aliases and published versions.InitDurationis cold start and the catalog has no key for it, so it is not added.request_duration_msto 100 ms, which would become a real cost oncemonthly_requestsis set.aws_nat_gateway, the keyresources/aws/aws_nat_gateway.tomlreads for data processed:monthly_data_processed_gbfromBytesInFromSource+BytesInFromDestination(Sum), converted with 1 GB = 2^30 bytes, then expressed per 30 days. Bytes out the other side are the same flows and are not added. A 1 GB upload is billed as 1 GB.NatGatewayId. That series is used, and availability zones are not also summed.ListMetrics(no metric name) finds zones whose dimensions are exactlyNatGatewayIdandAvailabilityZone. Those zones are summed. Any other dimension shape is ignored.monthly_inter_az_gbis not emitted: the catalog uses it for a hypothetical consolidation and defaults it to 0.Names come from state, else a literal:
function_namefor Lambda,idfor a NAT gateway. A NATidis computed, so without--statethe gateway is listed and not guessed.Checked against the design
usage syncloads credentials, through the SDK default chain. Calls stay read-onlyGetMetricDataandListMetrics. No new SDK module: stillconfigandcloudwatch.monthly_inter_az_gb, no sum of a zonal total plus its zones, no dimension shape other than the ones above.Emitsincludes the new keys, and the catalog-key test checks every one.Local checks
go build ./...,go vet ./...,go test ./..., andgo test -race ./internal/usagesync/... ./cmd/c3x/pass. golangci-lint v2.15.0 reports 0 issues.