mirror of
https://github.com/Sea-Haven-Industries/procurement-ingest.git
synced 2026-10-07 16:08:54 +00:00
Emit ParseMethod-only EMF set so fallback alarm can fire
The fallback-rate alarm queries the ParseOutcome series keyed on ParseMethod alone, but the emitter published only the joint (ParseMethod, TemplateId) dimension set. CloudWatch materializes exactly the listed dimension sets and does not auto-aggregate, so the alarm's series never received data: it evaluated a constant 0 and could never page on template-drift coverage collapse. Publish both ["ParseMethod"] and ["ParseMethod","TemplateId"] and update the EMF regression test to assert both sets are present.
This commit is contained in:
parent
aa490f9b33
commit
fcee3b9c78
2 changed files with 16 additions and 4 deletions
|
|
@ -149,13 +149,20 @@ def emit_parse_metric(method, template_id, reason_code, work_order_id):
|
||||||
Zero-latency (no PutMetricData API call): the extraction path is async and
|
Zero-latency (no PutMetricData API call): the extraction path is async and
|
||||||
the role already has logs:PutLogEvents. ParseMethod/TemplateId are the only
|
the role already has logs:PutLogEvents. ParseMethod/TemplateId are the only
|
||||||
promoted (dimensioned) fields to keep cardinality low; ReasonCode and
|
promoted (dimensioned) fields to keep cardinality low; ReasonCode and
|
||||||
work_order_id ride along as Logs-Insights-queryable properties."""
|
work_order_id ride along as Logs-Insights-queryable properties.
|
||||||
|
|
||||||
|
Two dimension sets are published: ["ParseMethod"] (aggregated across all
|
||||||
|
template ids -- the series the fallback-rate alarm queries) AND
|
||||||
|
["ParseMethod", "TemplateId"] (per-template breakdown for Logs Insights /
|
||||||
|
dashboards). CloudWatch materializes only the exact dimension sets listed
|
||||||
|
here and does NOT auto-aggregate, so the alarm's single-dimension query
|
||||||
|
would receive no data unless ["ParseMethod"] is emitted explicitly."""
|
||||||
emf = {
|
emf = {
|
||||||
"_aws": {
|
"_aws": {
|
||||||
"CloudWatchMetrics": [
|
"CloudWatchMetrics": [
|
||||||
{
|
{
|
||||||
"Namespace": METRIC_NAMESPACE,
|
"Namespace": METRIC_NAMESPACE,
|
||||||
"Dimensions": [["ParseMethod", "TemplateId"]],
|
"Dimensions": [["ParseMethod"], ["ParseMethod", "TemplateId"]],
|
||||||
"Metrics": [{"Name": METRIC_NAME, "Unit": "Count"}],
|
"Metrics": [{"Name": METRIC_NAME, "Unit": "Count"}],
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -165,8 +165,13 @@ def test_emit_parse_metric_writes_emf(capsys):
|
||||||
assert emf["TemplateId"] == "update_plaintext"
|
assert emf["TemplateId"] == "update_plaintext"
|
||||||
assert emf["ReasonCode"] == "ok"
|
assert emf["ReasonCode"] == "ok"
|
||||||
assert emf["ParseOutcome"] == 1
|
assert emf["ParseOutcome"] == 1
|
||||||
dims = emf["_aws"]["CloudWatchMetrics"][0]["Dimensions"][0]
|
dims = emf["_aws"]["CloudWatchMetrics"][0]["Dimensions"]
|
||||||
assert dims == ["ParseMethod", "TemplateId"]
|
# Two dimension sets must be published: the ParseMethod-only aggregate that
|
||||||
|
# the fallback-rate alarm queries, AND the per-template breakdown. Without
|
||||||
|
# the ["ParseMethod"] set the alarm's single-dimension series never receives
|
||||||
|
# data and can never fire (regression guard for the coverage-collapse alarm).
|
||||||
|
assert ["ParseMethod"] in dims
|
||||||
|
assert ["ParseMethod", "TemplateId"] in dims
|
||||||
assert (
|
assert (
|
||||||
emf["_aws"]["CloudWatchMetrics"][0]["Namespace"] == "Seahaven/WorkorderIngest"
|
emf["_aws"]["CloudWatchMetrics"][0]["Namespace"] == "Seahaven/WorkorderIngest"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue