cdk-monitoring-constructs
cdk-monitoring-constructs copied to clipboard
metricFactory.createMetricSearch doesn't support empty dimension map
Feature scope
MetricFactory
Describe your suggested feature
Declaring CustomMetricGroup as following:
{
title: 'Test',
metrics: [
metricFactory.createMetricSearch(
'query',
{ dummyDim: undefined as any as string },
MetricStatistic.SUM,
) as MathExpression,
],
},
Which generates a graph with following search query:
SEARCH('{test_namespace,dummyDim} EligibleEvent', 'Sum', 60)
As far as I can tell, there is no way to omit the DimensionMap. When I emit the metric, I don't associate any dimension, so I need to associate a dummy dimension, which is a little hacky.
Nit: Also unrelated issue, createMetricSearch returns IMetric, which is incompatible with what the MonitoringFacade expects (Metric | MathExpression) resulting in me needing to cast the return into a MathExpression.
Related code snippet: https://github.com/cdklabs/cdk-monitoring-constructs/blob/e7aa66bc3a051a46bc28d674f7e6bca6f4195a6a/lib/common/metric/MetricFactory.ts#L148-L185