Cloudwatch error after setting up our lambda function with CDK construct
olivierpichon opened this issue · 3 comments
Expected Behavior
We use the datadog-cdk-construct to instrument our lambda functions. Most of our logs look like this:
START RequestId: ba4d56aa-cb23-468a-960b-5df98d09e9df Version: $LATEST
2022-01-05T10:27:51.431Z ba4d56aa-cb23-468a-960b-5df98d09e9df INFO [dd.trace_id=7576945396481994720 dd.span_id=7576945396481994720] DATADOG TRACER CONFIGURATION - {
"date": "2022-01-05T10:27:51.430Z",
"os_name": "Linux",
"os_version": "4.14.252-207.481.amzn2.x86_64",
"architecture": "x64",
"version": "1.1.2",
"lang": "nodejs",
"lang_version": "14.18.1",
"enabled": true,
"service": "...",
"agent_url": "http://127.0.0.1:8126",
"debug": false,
"sample_rate": 1,
"sampling_rules": [],
"tags": {
"_dd.origin": "lambda",
"service": "..."
},
"log_injection_enabled": true,
"runtime_metrics_enabled": false,
"integrations_loaded": [
"dns",
"net",
"pg",
"http",
"https",
"http2"
]
}
2022-01-05T10:27:52.491Z ba4d56aa-cb23-468a-960b-5df98d09e9df INFO [dd.trace_id=2744288801532801835 dd.span_id=2744288801532801835] Success
END RequestId: ba4d56aa-cb23-468a-960b-5df98d09e9df
And data is pushed correctly to datadog. We would expect no errors showing up.
Actual Behavior
Quite regularly we get errors in the cloudwatch logs of our newly instrumented lambda function that look like this:
LOGS Name: datadog-agent State: Subscribed Types: [platform,function,extension]
2022-01-05T10:26:42.652Z undefined ERROR {
"status": "error",
"message": "datadog:api key not configured, see https://dtdg.co/sls-node-metrics"
}
EXTENSION Name: datadog-agent State: Ready Events: [INVOKE,SHUTDOWN]
We do provide API KEY, via apiKeySecretArn (see below). So not quite sure what does this error means.
Steps to Reproduce the Problem
datadog = new Datadog(scope, id, {
addLayers: true,
nodeLayerVersion: 66,
extensionLayerVersion: 15,
site: "datadoghq.com",
enableDatadogTracing: true,
apiKeySecretArn: ...
});
datadog.addLambdaFunctions([<LAMBDA_FUNCTIONS>]);
All the CDK construct does is to set the DD_API_KEY_SECRET_ARN
env variable. It looks like datadog-lambda-js
does not behave well when this is set instead of the usual API key.
Specifications
- Datadog Lambda Layer version: 66
- Node version: 14
NB: this bug was already submitted here DataDog/datadog-cdk-constructs#80 and I was advised to move it here.
hi @olivierpichon - thanks! We'll need to modify the logic to not check for an API key if this library is used in contexts where it won't need the API key. I'll update this issue and close with a PR when it's ready.
Thanks a lot @astuyve 💯