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_gateway.py

View on GitHub
"""Gateway to the AWS application-signals API.

The single seam where dynamic-instrumentation tools touch botocore. Each
operation here issues one boto3 call, wraps any raised exception in a
``GatewayError``, and lets the caller render the failure through
``render_error``. Tool functions never import ``botocore.exceptions`` — that
contract belongs to this module.
"""

from typing import Any, Dict, Mapping, Optional, Sequence

from botocore.exceptions import BotoCoreError, ClientError
from di_app_signals_client import get_application_signals_client
from di_error_translation import render_client_error, translate_aws_error


class GatewayError(Exception):
    """Wraps any exception raised by an application-signals call.

    The original exception is preserved on ``original_exc`` so callers can
    pass the gateway error through ``render_error`` without losing the
    botocore-specific data ``render_client_error`` needs.
    """

    def __init__(self, original_exc: BaseException):
        """Wrap ``original_exc``, preserving it for later rendering."""
        super().__init__(str(original_exc))
        self.original_exc = original_exc


# The full set of application-signals client methods these tools are allowed to call. The
# wrapper functions below pass only these hardcoded names, but ``_call`` validates against
# this frozen set before dispatch so the seam cannot be turned into an arbitrary-method
# dispatcher by any (future) caller. ``_bind_method`` then selects the bound method by LITERAL
# attribute access (one ``if`` per op) — never ``getattr(client, name)`` — so there is no
# string-driven dispatch. The two are kept in lockstep by the gateway sync-guard test.
_ALLOWED_OPERATIONS = frozenset(
    {
        "create_instrumentation_configuration",
        "list_instrumentation_configurations",
        "get_instrumentation_configuration",
        "delete_instrumentation_configuration",
        "batch_delete_instrumentation_configurations",
        "get_instrumentation_configuration_status",
    }
)


def _bind_method(client: Any, method_name: str):
    """Return the bound boto3 client method for ``method_name`` via literal attribute access.

    boto3 client methods are generated dynamically per client instance, so they cannot be
    bound as a static dict at import time the way our own module functions can. Instead each
    allowlisted op is reached by a hardcoded attribute name (``client.create_instrumentation_
    configuration`` etc.), never ``getattr(client, method_name)``. ``method_name`` has already
    been checked against ``_ALLOWED_OPERATIONS`` by ``_call``, so the final ``raise`` is
    unreachable; it keeps the allowlist and these branches in sync (asserted by the tests).
    """
    if method_name == "create_instrumentation_configuration":
        return client.create_instrumentation_configuration
    if method_name == "list_instrumentation_configurations":
        return client.list_instrumentation_configurations
    if method_name == "get_instrumentation_configuration":
        return client.get_instrumentation_configuration
    if method_name == "delete_instrumentation_configuration":
        return client.delete_instrumentation_configuration
    if method_name == "batch_delete_instrumentation_configurations":
        return client.batch_delete_instrumentation_configurations
    if method_name == "get_instrumentation_configuration_status":
        return client.get_instrumentation_configuration_status
    raise ValueError(f"Disallowed application-signals operation: {method_name!r}")


def _call(method_name: str, **kwargs: Any) -> Dict[str, Any]:
    if method_name not in _ALLOWED_OPERATIONS:
        raise ValueError(f"Disallowed application-signals operation: {method_name!r}")
    client = get_application_signals_client()
    method = _bind_method(client, method_name)
    try:
        return method(**kwargs)
    except (BotoCoreError, ClientError) as exc:
        # Narrow on purpose: these two cover the full botocore exception
        # surface (``ClientError`` for service-side errors, ``BotoCoreError``
        # for credentials/connection/timeout failures). Programming errors
        # (``AttributeError`` from a typo, ``TypeError`` from a bad kwarg)
        # propagate unwrapped so they surface as themselves in tracebacks
        # instead of masquerading as AWS failures.
        raise GatewayError(exc) from exc


def create_instrumentation_configuration(**kwargs: Any) -> Dict[str, Any]:
    """Call ``CreateInstrumentationConfiguration`` through the gateway."""
    return _call("create_instrumentation_configuration", **kwargs)


def list_instrumentation_configurations(**kwargs: Any) -> Dict[str, Any]:
    """Call ``ListInstrumentationConfigurations`` through the gateway."""
    return _call("list_instrumentation_configurations", **kwargs)


def get_instrumentation_configuration(**kwargs: Any) -> Dict[str, Any]:
    """Call ``GetInstrumentationConfiguration`` through the gateway."""
    return _call("get_instrumentation_configuration", **kwargs)


def delete_instrumentation_configuration(**kwargs: Any) -> Dict[str, Any]:
    """Call ``DeleteInstrumentationConfiguration`` through the gateway."""
    return _call("delete_instrumentation_configuration", **kwargs)


def batch_delete_instrumentation_configurations(**kwargs: Any) -> Dict[str, Any]:
    """Call ``BatchDeleteInstrumentationConfigurations`` through the gateway."""
    return _call("batch_delete_instrumentation_configurations", **kwargs)


def get_instrumentation_configuration_status(**kwargs: Any) -> Dict[str, Any]:
    """Call ``GetInstrumentationConfigurationStatus`` through the gateway."""
    return _call("get_instrumentation_configuration_status", **kwargs)


def render_error(
    err: GatewayError,
    *,
    action: str,
    attempted_label: str = "ATTEMPTED PARAMETERS:",
    attempted: Optional[Mapping[str, object]] = None,
    possible_causes: Optional[Sequence[str]] = None,
    troubleshooting: Optional[Sequence[str]] = None,
    trailer: Optional[str] = None,
) -> str:
    """Render a ``GatewayError`` using the appropriate error template.

    Callers that want tailored prose for a ``ClientError`` pass
    ``possible_causes`` / ``troubleshooting`` / ``trailer``; those flow
    through ``render_client_error``. Callers that pass none of those — and
    every non-``ClientError`` exception regardless — fall through to
    ``translate_aws_error``, which carries its own canned bullets per
    exception type. This preserves the per-tool rendering contract that
    existed before tools were routed through the gateway.
    """
    exc = err.original_exc
    has_tailored_prose = bool(possible_causes or troubleshooting or trailer)
    if isinstance(exc, ClientError) and has_tailored_prose:
        return render_client_error(
            exc,
            action=action,
            attempted_label=attempted_label,
            attempted=attempted,
            possible_causes=possible_causes,
            troubleshooting=troubleshooting,
            trailer=trailer,
        )
    return translate_aws_error(exc, action=action, context=attempted)
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