Skip to content

opensite-ai/opensite-skills / aws-observability

aws-observability

Unverified

Builds, configures, debugs, and optimizes AWS observability - operator-symptom questions and detecting Omni vs classic CloudWatch. CloudWatch on an already-reporting service: Log Insights, metric/composite/anomaly alarms, custom metrics/EMF, dashboards, X-Ray/ADOT tracing, canaries, CloudTrail, Dynamic Instrumentation (live breakpoints/snapshots), the Application Signals service map, and fleet health views. CloudWatch Omni on an existing Space: SQL over logs and traces, PromQL over metrics, Omni dashboards, Omni alerts, context graph for root cause, programmatic/IaC access (API/SDK/CLI/CloudFormation), driving Omni from a coding agent or skills, and evaluating AI agent quality from traces - on-demand and online scoring of live traffic, readback, custom evaluators. For first-time setup - creating an Omni Space, granting access, ingestion, or ADOT instrumentation for Application Signals (ServiceEvents, CI/CD metadata) or Omni - use setting-up-cloudwatch-observability. Not for app logging or threat detection.

FileKindSize
.aws-skill-metadataother18 B
SKILL.mdskill md28.3 KB
assets/cloudwatch/alarm-template.tsscript3.9 KB
assets/cloudwatch/otel-config.yamlconfig1.9 KB
references/cloudwatch-omni/agent-evaluation.mdmarkdown98.9 KB
references/cloudwatch-omni/alerts.mdmarkdown103.3 KB
references/cloudwatch-omni/concepts.mdmarkdown28.8 KB
references/cloudwatch-omni/context-graph.mdmarkdown29.2 KB
references/cloudwatch-omni/dashboards.mdmarkdown75.5 KB
references/cloudwatch-omni/programmatic-access.mdmarkdown8.6 KB
references/cloudwatch-omni/query/promql-metrics.mdmarkdown63.9 KB
references/cloudwatch-omni/query/sql-logs-traces.mdmarkdown43.0 KB
references/cloudwatch-omni/query/views.mdmarkdown12.7 KB
references/cloudwatch/alarms.mdmarkdown11.5 KB
references/cloudwatch/cloudtrail.mdmarkdown5.3 KB
references/cloudwatch/dashboards.mdmarkdown5.8 KB
references/cloudwatch/dynamic-instrumentation.mdmarkdown39.4 KB
references/cloudwatch/dynamic-instrumentation/breakpoint-creation.mdmarkdown16.3 KB
references/cloudwatch/dynamic-instrumentation/call-tree-and-directions.mdmarkdown5.7 KB
references/cloudwatch/dynamic-instrumentation/snapshot-parsing.mdmarkdown4.2 KB
references/cloudwatch/log-insights.mdmarkdown7.0 KB
references/cloudwatch/metrics.mdmarkdown7.4 KB
references/cloudwatch/synthetics.mdmarkdown6.5 KB
references/cloudwatch/tracing.mdmarkdown9.4 KB
references/cloudwatch/troubleshooting.mdmarkdown7.5 KB
scripts/cloudwatch-omni/capture_dataset_from_traces.pyscript19.2 KB
scripts/cloudwatch-omni/evaluate_traces.pyscript41.8 KB
scripts/cloudwatch-omni/test_evaluate_traces.pyscript12.0 KB
scripts/cloudwatch/di_app_signals_client.pyscript3.3 KB
scripts/cloudwatch/di_capture.pyscript8.5 KB
scripts/cloudwatch/di_constants.pyscript560 B
scripts/cloudwatch/di_crud_rendering.pyscript13.1 KB
scripts/cloudwatch/di_crud_tools.pyscript28.8 KB
scripts/cloudwatch/di_error_translation.pyscript5.6 KB
scripts/cloudwatch/di_formatting.pyscript992 B
scripts/cloudwatch/di_gateway.pyscript7.0 KB
scripts/cloudwatch/di_instrumentation.pyscript13.0 KB
scripts/cloudwatch/di_location.pyscript15.3 KB
scripts/cloudwatch/di_logs_client.pyscript4.2 KB
scripts/cloudwatch/di_region.pyscript2.0 KB
scripts/cloudwatch/di_result.pyscript2.0 KB
scripts/cloudwatch/di_session.pyscript2.0 KB
scripts/cloudwatch/di_snapshot_parsing.pyscript11.4 KB
scripts/cloudwatch/di_snapshot_queries.pyscript2.4 KB
scripts/cloudwatch/di_snapshot_rendering.pyscript12.5 KB
scripts/cloudwatch/di_snapshot_tools.pyscript12.0 KB
scripts/cloudwatch/di_snapshots.pyscript12.8 KB
scripts/cloudwatch/di_status_assessment.pyscript4.7 KB
scripts/cloudwatch/di_status_rendering.pyscript11.8 KB
scripts/cloudwatch/di_status_tools.pyscript13.0 KB
scripts/cloudwatch/di_validation.pyscript11.2 KB

scripts/cloudwatch/di_status_assessment.py

View on GitHub
"""Consolidated status assessment for dynamic instrumentation.

The "consolidated status check" answers a single question — *what is the
high-level state of this instrumentation right now?* — by querying three
status signals (ACTIVE, READY, ERROR) in priority order over a time window.

This module owns:

* The **time-window policy.** ACTIVE events are only meaningful after the
  instrumentation was created, so the ACTIVE query window is clamped to
  ``max(created_at, requested_start)``. READY and ERROR are checked against
  the full requested window.
* The **check ordering.** ACTIVE wins; otherwise READY wins; otherwise the
  ERROR check decides between ERROR and PENDING.
* The **verdict shape.** Returns a sealed sum type that the renderer
  dispatches on, instead of leaking three different argument tuples to
  three different renderers.

I/O lives in the caller. ``assess`` takes a ``check_status`` callable so
the policy can be tested without touching boto3.
"""

from dataclasses import dataclass
from datetime import datetime, timezone
from typing import Callable, List, Optional, Tuple, Union

# A single check call: (status_label, start, end) → (has_events, events, error_or_None).
# Matches the existing ``_check_status_with_time_range`` shape.
CheckStatus = Callable[[str, datetime, datetime], Tuple[bool, List[dict], Optional[str]]]


@dataclass(frozen=True)
class TimeWindow:
    """The four ISO-formatted time strings every consolidated renderer needs."""

    created_at: str
    requested_start: str
    active_query_start: str
    query_end: str


@dataclass(frozen=True)
class _StatusCheckResult:
    has_events: bool
    events: List[dict]
    error: Optional[str]


@dataclass(frozen=True)
class Active:
    """ACTIVE events were found in the (clamped) ACTIVE window."""

    active: _StatusCheckResult


@dataclass(frozen=True)
class Ready:
    """ACTIVE not confirmed, but READY events were found."""

    active: _StatusCheckResult
    ready: _StatusCheckResult


@dataclass(frozen=True)
class ErrorOrPending:
    """Neither ACTIVE nor READY confirmed.

    The ERROR check decides between ERROR and PENDING based on whether
    ``error.has_events`` is true.
    """

    active: _StatusCheckResult
    ready: _StatusCheckResult
    error: _StatusCheckResult


Verdict = Union[Active, Ready, ErrorOrPending]


def _check_result(
    check: CheckStatus, status: str, start: datetime, end: datetime
) -> _StatusCheckResult:
    has_events, events, error = check(status, start, end)
    return _StatusCheckResult(has_events=has_events, events=events, error=error)


def _format_iso(value: datetime) -> str:
    return value.astimezone(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")


def assess(
    *,
    created_at: datetime,
    requested_start: datetime,
    query_end: datetime,
    check_status: CheckStatus,
) -> Tuple[Verdict, TimeWindow]:
    """Run the consolidated status assessment.

    The caller is responsible for:

    * Parsing ISO inputs into ``datetime`` objects (string parsing is an input
      concern, not policy).
    * Verifying ``query_end > requested_start`` before calling — that error
      message is owned by the tool layer.
    * Providing a ``check_status`` callable that issues the AWS query.

    Returns a ``(verdict, time_window)`` pair. The renderer dispatches on
    the verdict type; both verdict and time_window are passed to the
    renderer.
    """
    requested_start_utc = requested_start.astimezone(timezone.utc)
    query_end_utc = query_end.astimezone(timezone.utc)
    created_at_utc = created_at.astimezone(timezone.utc)
    active_query_start_utc = max(created_at_utc, requested_start_utc)

    time_window = TimeWindow(
        created_at=_format_iso(created_at_utc),
        requested_start=_format_iso(requested_start_utc),
        active_query_start=_format_iso(active_query_start_utc),
        query_end=_format_iso(query_end_utc),
    )

    if query_end_utc > active_query_start_utc:
        active = _check_result(check_status, "ACTIVE", active_query_start_utc, query_end_utc)
    else:
        active = _StatusCheckResult(
            has_events=False,
            events=[],
            error=(
                "Skipped: ACTIVE query window is empty after applying created_at clamp "
                f"(start={time_window.active_query_start}, end={time_window.query_end})"
            ),
        )

    if active.has_events:
        return Active(active=active), time_window

    ready = _check_result(check_status, "READY", requested_start_utc, query_end_utc)
    if ready.has_events:
        return Ready(active=active, ready=ready), time_window

    error = _check_result(check_status, "ERROR", requested_start_utc, query_end_utc)
    return ErrorOrPending(active=active, ready=ready, error=error), time_window
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall