-
Notifications
You must be signed in to change notification settings - Fork 401
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
Feature request: ability to remove 'environment' dimension from metrics #5368
Comments
Hi @bml1g12! Thanks for raising this issue. I'm trying to reproduce this error and I'm having trouble. Can you help me understand this issue a bit more? I'm using this code import os
from aws_lambda_powertools import Metrics
from aws_lambda_powertools.metrics import MetricUnit
from aws_lambda_powertools.utilities.typing import LambdaContext
API_METRICS_SERVICE = Metrics(service="cci-call-panel-api", namespace="x")
API_METRICS_SERVICE.clear_default_dimensions() # remove default "environment" dimension
API_METRICS_SERVICE.set_default_dimensions(
aws_region=os.environ.get("REGION", "ap-northeast-1"),
stage=os.environ.get("NODE_ENV", "unknown")
)
@API_METRICS_SERVICE.log_metrics # ensures metrics are flushed upon request completion/failure
def lambda_handler(event: dict, context: LambdaContext):
API_METRICS_SERVICE.add_metric(name="SuccessfulBooking", unit=MetricUnit.Count, value=1) And the output doesn't contain the
Thanks. |
Oh dear, I'm terribly sorry, After seeing your post I realise this dimension is being added within some in-house middleware we're using to our handlers! So this issue can be closed |
|
No problem at all! Ping us if you need any additional help. |
Use case
This is a quite related to #3917
I've been using the https://github.com/aws-powertools/powertools-lambda-typescript/
I'm using "@aws-lambda-powertools/metrics": "^2.8.0" on the JS side, which is up to date at time of writing. I wanted to log from python to the same metric. That JS library does not by default add an 'environment' dimension (or at least if it does, I've removed it in the way I'm operating with it)
Whereas it seems in this library in Python there is always an 'environment' dimension even when explicitly calling clear_default_dimensions().
I should note I'm using a little old version of the library (
aws-lambda-powertools==2.30.2
) as it's not trivial for me to upgrade (would need to update a lot of repos using that layer) - so please feel free to close this issue if it's an issue already resolved.Solution/User Experience
environment
is always added as a default dimension, and make behaviour consistent with the JS library.Alternative solutions
I can maybe edit my Javascript repo to add this dimension...but the problem is that I think cloudwatch metrics are fairly immutable, so I would lose historical data of that metric if I made a new metric with this dimension.
Acknowledgment
The text was updated successfully, but these errors were encountered: