tpmjs/packages/tools/official/monitoring-gap-analysis/README.md
Ajax Davis 5d2096fb5d feat: add 100+ official TPMJS tools
Implements a comprehensive suite of AI SDK v6 tools across multiple categories:

- Research (5): page-brief, compare-pages, source-credibility, claim-checklist, timeline-from-text
- Web (10): fetch-text, links-catalog, extract-meta, extract-json-ld, redirect-trace, sitemap-read, rss-read, table-extract, robots-policy, url-normalize
- Data (15): csv-parse, csv-stringify, json-repair, json-schema-validate, yaml-parse, yaml-stringify, text-chunk, normalize-whitespace, dedupe-by-key, pivot, rows-filter, rows-sort, rows-group-aggregate, rows-join, schema-infer
- Doc (12): toc-generate, glossary-build, faq-from-text, executive-brief, decision-record-adr, prd-outline, acceptance-criteria, style-rewrite
- Eng (12): diff-text-unified, env-var-docs-generate, dependency-audit-lite, conventional-commit-suggest, markdown-lint-basic, test-case-generate, stacktrace-parse, release-notes, changelog-entry, release-checklist
- Security (7): redact-secrets, secret-scan-text, url-risk-heuristic, csp-compose, hardening-checklist-web, access-control-matrix, data-classification-heuristic
- Stats (9): effect-size-suite, bootstrap-ci, permutation-test, multiple-testing-adjust, linear-regression-ols, logistic-regression, time-series-decompose-lite, anomaly-detect-mad
- Ops (7): slo-draft, runbook-draft, postmortem-draft, postmortem-action-extractor, error-log-triage, coverage-tracker, monitoring-gap-analysis
- Agent (15): prompt-to-workflow-skeleton, workflow-validate-io, workflow-explain, workflow-cost-estimate, tool-call-accuracy-score, eval-fixture-build, guardrail-policy-draft, workflow-auto-repair, tool-selection-plan, novelty-score-workflow, workflow-variant-generate, config-normalize, recipe-*
- Utility (8): base64-encode, base64-decode, hash-text, regex-extract, template-render, date-parse, json-path-query, url-parse
- HTML (3): html-sanitize, html-to-markdown, markdown-to-html

All tools follow AI SDK v6 pattern with tool() and jsonSchema<T>().

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 22:55:56 +10:00

5.2 KiB
Raw Blame History

@tpmjs/tools-monitoring-gap-analysis

Analyze monitoring coverage gaps across services and endpoints to identify missing metrics, alerts, or logs with prioritized recommendations.

Installation

npm install @tpmjs/tools-monitoring-gap-analysis

Usage

import { monitoringGapAnalysisTool } from '@tpmjs/tools-monitoring-gap-analysis';

// Analyze monitoring coverage
const result = await monitoringGapAnalysisTool.execute({
  services: [
    {
      name: 'API Gateway',
      hasMetrics: true,
      hasAlerts: true,
      hasLogs: true
    },
    {
      name: 'Payment Service',
      hasMetrics: true,
      hasAlerts: false,
      hasLogs: true
    },
    {
      name: 'Email Worker',
      hasMetrics: false,
      hasAlerts: false,
      hasLogs: false
    },
    {
      name: 'User Service',
      hasMetrics: true,
      hasAlerts: true,
      hasLogs: false
    }
  ]
});

console.log(result.coverageScore); // 58
console.log(result.summary);
// "Analyzed 4 services with 58% overall monitoring coverage. Found 5 gaps across 3 services, including 1 critical gap requiring immediate attention."

console.log(result.gaps);
// [
//   {
//     service: "Email Worker",
//     gapType: "critical",
//     severity: "critical",
//     description: "Service has no monitoring coverage",
//     impact: "Cannot detect outages..."
//   },
//   ...
// ]

console.log(result.recommendations);
// [
//   {
//     priority: "high",
//     category: "metrics",
//     title: "Implement metrics collection for unmonitored services",
//     description: "Deploy metric exporters...",
//     affectedServices: ["Email Worker"]
//   },
//   ...
// ]

Input

  • services (array, required): Array of service objects with:
    • name (string): Service name
    • hasMetrics (boolean): Whether metrics collection is configured
    • hasAlerts (boolean): Whether alerting is configured
    • hasLogs (boolean): Whether log collection is configured

Output

Returns an object with:

  • gaps (array): Identified monitoring gaps, each containing:
    • service (string): Service name
    • gapType ('metrics' | 'alerts' | 'logs' | 'critical'): Type of gap
    • severity ('critical' | 'high' | 'medium'): Gap severity
    • description (string): What is missing
    • impact (string): Business/operational impact
  • recommendations (array): Prioritized recommendations, each containing:
    • priority ('high' | 'medium' | 'low'): Action priority
    • category ('metrics' | 'alerts' | 'logs' | 'infrastructure'): Recommendation type
    • title (string): Short recommendation title
    • description (string): Detailed implementation guidance
    • affectedServices (array): List of services this applies to
  • coverageScore (number): Overall coverage score 0-100 (based on % of services with complete monitoring)
  • summary (string): Human-readable analysis summary
  • metadata (object):
    • totalServices: Number of services analyzed
    • servicesWithGaps: Number of services with at least one gap
    • criticalGaps: Number of critical severity gaps
    • analyzedAt: ISO timestamp
    • coverageBreakdown: Coverage percentages by type (metrics, alerts, logs)

Features

  • Severity Classification: Gaps are classified as critical, high, or medium based on impact
  • Smart Recommendations: Prioritized, actionable recommendations grouped by category
  • Coverage Scoring: 0-100 score based on complete monitoring coverage (metrics + alerts + logs)
  • Coverage Breakdown: See coverage percentages by monitoring type
  • Critical Gap Detection: Services with zero monitoring are flagged as critical
  • Infrastructure Recommendations: Suggests platform-level improvements when many services lack monitoring

Gap Severity Logic

  • Critical: Service has NO monitoring coverage at all (no metrics, alerts, or logs)
  • High: Missing critical monitoring component (metrics or alerts)
  • Medium: Missing logs (when metrics/alerts exist)

Coverage Score Calculation

Score = (Total monitoring components present) / (Total services × 3) × 100

Each service can have up to 3 components (metrics, alerts, logs). A service with all three counts as 100% covered.

Example Scenarios

Well-monitored Infrastructure

// All services fully monitored
const result = await monitoringGapAnalysisTool.execute({
  services: [
    { name: 'API', hasMetrics: true, hasAlerts: true, hasLogs: true },
    { name: 'DB', hasMetrics: true, hasAlerts: true, hasLogs: true }
  ]
});
// coverageScore: 100
// gaps: []

Partial Monitoring (Common)

// Some gaps across services
const result = await monitoringGapAnalysisTool.execute({
  services: [
    { name: 'API', hasMetrics: true, hasAlerts: true, hasLogs: false },
    { name: 'Worker', hasMetrics: true, hasAlerts: false, hasLogs: false }
  ]
});
// coverageScore: 50
// gaps: 3 (1 medium for API logs, 2 high for Worker alerts/logs)

Critical Gaps

// Unmonitored service
const result = await monitoringGapAnalysisTool.execute({
  services: [
    { name: 'Legacy Service', hasMetrics: false, hasAlerts: false, hasLogs: false }
  ]
});
// coverageScore: 0
// gaps: 1 critical
// recommendations: High priority infrastructure setup

License

MIT