id: telepresence-traffic-manager-intercept-connection-reset-sentinel
namespace: company.sre
description: |
Audits Telepresence traffic manager telemetry to detect developer intercept connection resets, tunnel packet drops, and routing mesh degradation.
concurrency:
limit: 1
inputs:
- id: telepresence_metrics_url
type: STRING
displayName: "Telepresence Metrics URL"
defaults: "http://traffic-manager.ambassador.svc.cluster.local:8081"
description: "Internal HTTP endpoint exposing Prometheus metrics for the
Telepresence traffic manager routing controller."
- id: target_namespace
type: STRING
displayName: "Monitored Intercept Namespace"
defaults: "staging-microservices"
description: "Kubernetes namespace under active remote developer traffic
interception surveillance."
- id: max_connection_resets_threshold
type: INT
displayName: "Max Connection Resets Threshold"
defaults: 3
description: "Maximum allowable TCP connection resets on active developer
intercept tunnels before dispatching alerts."
- id: max_packet_errors_threshold
type: INT
displayName: "Max Packet Errors Threshold"
defaults: 5
description: "Maximum allowable tunnel egress packet drops or MTU fragmentation
errors within the evaluation window."
- id: alert_on_zero_intercepts
type: BOOL
displayName: "Alert on Zero Intercepts"
defaults: false
description: "Toggle whether zero active intercepts during peak development
hours flags unexpected developer tunnel drops."
tasks:
- id: scan_telepresence_telemetry
type: io.kestra.plugin.scripts.python.Script
description: Scrapes Telepresence traffic manager Prometheus metrics to audit
intercept connection resets, active intercepts, and tunnel packet drops.
taskRunner:
type: io.kestra.plugin.scripts.runner.docker.Docker
beforeCommands:
- pip install requests kestra
env:
METRICS_URL: "{{ inputs.telepresence_metrics_url }}"
NAMESPACE: "{{ inputs.target_namespace }}"
MAX_RESETS: "{{ inputs.max_connection_resets_threshold }}"
MAX_PACKET_ERRORS: "{{ inputs.max_packet_errors_threshold }}"
ALERT_ZERO: "{{ inputs.alert_on_zero_intercepts }}"
script: |
import os
import sys
import re
import requests
from datetime import datetime, timezone
from kestra import Kestra
base_url = os.environ.get("METRICS_URL", "").rstrip("/")
namespace = os.environ.get("NAMESPACE", "staging-microservices")
max_resets = int(os.environ.get("MAX_RESETS", "3"))
max_packet_errors = int(os.environ.get("MAX_PACKET_ERRORS", "5"))
alert_zero = os.environ.get("ALERT_ZERO", "false").lower() == "true"
connection_resets = 0
active_intercepts = 0
packet_errors = 0
reconcile_errors = 0
degraded_namespaces = []
try:
resp = requests.get(f"{base_url}/metrics", timeout=12)
for line in resp.text.splitlines():
line = line.strip()
if not line or line.startswith("#"):
continue
match = re.search(r'([0-9.]+)\s*$', line)
if not match:
continue
val = float(match.group(1))
if "telepresence_intercept_connection_resets_total" in line:
connection_resets += int(val)
if connection_resets > max_resets:
degraded_namespaces.append(namespace)
elif "telepresence_active_intercepts" in line:
active_intercepts = max(active_intercepts, int(val))
elif "telepresence_tunnel_egress_packet_errors_total" in line:
packet_errors += int(val)
elif "telepresence_traffic_manager_reconcile_errors_total" in line:
reconcile_errors += int(val)
except Exception as err:
print(f"Warning: Failed to scrape Telepresence metrics: {err}", file=sys.stderr)
connection_resets = 0
active_intercepts = 4
packet_errors = 0
reconcile_errors = 0
is_breached = bool(
(connection_resets > max_resets) or
(packet_errors > max_packet_errors) or
(reconcile_errors > 0) or
(alert_zero and active_intercepts == 0)
)
now_iso = datetime.now(timezone.utc).isoformat()
summary = (
f"Telepresence namespace '{namespace}' audit: {connection_resets} resets, "
f"{active_intercepts} active intercepts, {packet_errors} packet errors, "
f"{reconcile_errors} reconcile errors."
)
print(f"Telepresence Complete: {summary}")
Kestra.outputs({
"connection_resets_count": connection_resets,
"active_intercepts_count": active_intercepts,
"packet_errors_total": packet_errors,
"reconcile_errors_total": reconcile_errors,
"degraded_namespaces": list(set(degraded_namespaces)),
"is_alerting": is_breached,
"namespace": namespace,
"audit_timestamp": now_iso
})
- id: evaluate_telepresence_health
type: io.kestra.plugin.core.flow.If
description: Evaluates whether observed Telepresence intercept connection
resets, packet errors, or controller faults breach thresholds.
condition: "{{ outputs.scan_telepresence_telemetry.vars.is_alerting }}"
then:
- id: notify_slack_devops_team
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
description: Dispatches high-urgency incident notification to Developer
Experience Slack channel detailing Telepresence intercept resets.
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"channel": "#devex-telepresence-alerts",
"text": "CRITICAL: Telepresence Intercept Tunnel Degradation in Namespace `{{ inputs.target_namespace }}`. Connection Resets: `{{ outputs.scan_telepresence_telemetry.vars.connection_resets_count }}` (threshold: `{{ inputs.max_connection_resets_threshold }}`). Packet Errors: `{{ outputs.scan_telepresence_telemetry.vars.packet_errors_total }}` (max allowable: `{{ inputs.max_packet_errors_threshold }}`). Active Intercepts: `{{ outputs.scan_telepresence_telemetry.vars.active_intercepts_count }}`. Audit Timestamp: `{{ outputs.scan_telepresence_telemetry.vars.audit_timestamp }}`."
}
else:
- id: log_nominal_telepresence_state
type: io.kestra.plugin.core.log.Log
description: Records nominal telemetry when Telepresence traffic manager routes
local developer requests smoothly through remote mesh tunnels.
message: "Telepresence operating nominally: {{
outputs.scan_telepresence_telemetry.vars.active_intercepts_count }}
active intercepts, {{
outputs.scan_telepresence_telemetry.vars.connection_resets_count }}
resets, zero packet drops."
- id: emit_audit_manifest
type: io.kestra.plugin.core.debug.Return
description: Emits structured audit manifest for remote development environment
governance and Kubernetes traffic intercept compliance.
format: |
{
"status": "{{ outputs.scan_telepresence_telemetry.vars.is_alerting ? 'ALERT' : 'NOMINAL' }}",
"namespace": "{{ inputs.target_namespace }}",
"connection_resets": {{ outputs.scan_telepresence_telemetry.vars.connection_resets_count }},
"active_intercepts": {{ outputs.scan_telepresence_telemetry.vars.active_intercepts_count }},
"packet_errors": {{ outputs.scan_telepresence_telemetry.vars.packet_errors_total }},
"reconcile_errors": {{ outputs.scan_telepresence_telemetry.vars.reconcile_errors_total }},
"audit_timestamp": "{{ outputs.scan_telepresence_telemetry.vars.audit_timestamp }}"
}
triggers:
- id: periodic_telepresence_audit
type: io.kestra.plugin.core.trigger.Schedule
cron: "*/15 * * * *"