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

Support for default dimensions #147

Open
DahShahar opened this issue Mar 6, 2023 · 1 comment
Open

Support for default dimensions #147

DahShahar opened this issue Mar 6, 2023 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@DahShahar
Copy link

Hi, sorry in advance if this is already something supported by the library and I couldn't find it.

What?

I'm trying to override the default dimensions to remove things that aren't useful to me, such as LogGroup and ServiceType.

I can't find a way to actually do this. I see from the Configuration in the README that I can set namespace which is also useful, but not enough.

I thought there'd be a similar way to handle Dimensions, but there aren't. Ideally, I'd like to be able to create a single MetricsLogger in my application and wire it in as needed. That logger should always have the dimensions I want as baseline, and some methods might add more.

I recognize that this wouldn't work for an environment variable configuration, but how about something like:

const { Configuration } = require("aws-embedded-metrics");

Configuration.dimensions = [{
    version: 'N+1' // Latest Lambda Version specific
  },
  {}  // Whole fleet metrics
];

This would allow me to alarm on both the "latest" Lambda version specific metrics, and the fleet as a whole as I'd be emitting metrics for both at the same rate. This is especially useful during deployments as I want to see how the newest version is doing.

An alternative would be to open up the constructor of the MetricsLogger. I see that it is technically public today, but we don't have access to the EnvironmentProvider (again, as far as I am able to tell).

Let me know what you think, and if there's already a way to do this I apologize in advance.

@markkuhn markkuhn added the question Further information is requested label Mar 7, 2023
@markkuhn markkuhn self-assigned this Mar 7, 2023
@markkuhn
Copy link
Contributor

markkuhn commented Mar 7, 2023

You can override default dimensions by using the setDimensions function.

From the documentation:

setDimensions(Record<String, String> | Record<String, String>[] dimensions, boolean useDefault)

Explicitly override all dimensions. This will remove the default dimensions unless the useDefault parameter is set to true (defaults to false).

// Overwrites custom dimensions - keeps default dimensions
setDimensions({Operation: "Aggregator"}, true)

// Overwrites custom dimensions - removes default dimensions
setDimensions([
  { Operation: "Aggregator" },
  { Operation: "Aggregator", DeviceType: "Actuator" }
])

Custom dimensions cannot be set in the configuration. You must do this in the MetricLogger.

Let me know if this answers your question.

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

No branches or pull requests

2 participants