All skills
apollographql avatar

/apollo-router

@f13ff34 official
by Apollo GraphQLapollographql/skills115 stars
13

Version-aware guide for configuring and running Apollo Router for federated GraphQL supergraphs. Generates correct YAML for both Router v1.x and v2.x. Use this skill when: (1) setting up Apollo Router to run a supergraph, (2) configuring routing, headers, or CORS, (3) implementing custom plugins (Rhai scripts or coprocessors), (4) configuring telemetry (tracing, metrics, logging), (5) troubleshooting Router performance or connectivity issues, (6) securing the graph with JWT, declarative field-level authorization directives, or persisted-query safelisting, (7) managing router.yaml as version-controlled config with CI/CD validation.

Use this Skill: https://skilld.dev/gh/apollographql/skills/apollo-router

This session only. Nothing lands on disk.

referencestelemetry.md

≈1.5k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Router Telemetry

Configure logging, metrics, and tracing with OpenTelemetry-compatible exporters.

Telemetry Overview

The Router supports three types of telemetry:

Type Description Exporters
Logs Structured event logging stdout, file
Metrics Numerical measurements Prometheus, OTLP, Datadog
Traces Distributed request tracing Jaeger, Zipkin, OTLP, Datadog

Basic Configuration

telemetry:
  exporters:
    logging:
      stdout:
        enabled: true
        format: json

    metrics:
      prometheus:
        enabled: true
        listen: 127.0.0.1:9090
        path: /metrics

    tracing:
      otlp:
        enabled: true
        endpoint: http://collector:4317

Logging

Stdout Logging

telemetry:
  exporters:
    logging:
      stdout:
        enabled: true
        format: json  # or "text" for human-readable

Log Level

Set via environment variable:

APOLLO_ROUTER_LOG=debug router

Or in configuration:

telemetry:
  exporters:
    logging:
      stdout:
        enabled: true
      common:
        service_name: my-router

Log levels: off, error, warn, info, debug, trace

Metrics

Prometheus

telemetry:
  exporters:
    metrics:
      prometheus:
        enabled: true
        listen: 127.0.0.1:9090
        path: /metrics

Access metrics at http://localhost:9090/metrics.

Common metrics:

  • apollo_router_http_requests_total - Request count
  • apollo_router_http_request_duration_seconds - Latency histogram
  • apollo_router_cache_hit_count - Cache hit/miss

Response Cache Metrics (v2.6.0+)

Metric Description
apollo.router.operations.response_cache.fetch Time to fetch from cache
apollo.router.operations.response_cache.insert Time to insert into cache
apollo.router.operations.response_cache.invalidation.entry Entries invalidated
apollo.router.cache.redis.commands_executed Total Redis commands
apollo.router.cache.redis.errors Redis errors by type

Full metrics reference and telemetry config: response-caching.md

OTLP Metrics

telemetry:
  exporters:
    metrics:
      otlp:
        enabled: true
        endpoint: http://collector:4317
        protocol: grpc  # or "http"

Datadog Metrics

telemetry:
  exporters:
    metrics:
      datadog:
        enabled: true
        endpoint: https://api.datadoghq.com

Set DD_API_KEY environment variable.

Tracing

OTLP (OpenTelemetry)

telemetry:
  exporters:
    tracing:
      otlp:
        enabled: true
        endpoint: http://collector:4317
        protocol: grpc

      common:
        service_name: apollo-router

Jaeger

telemetry:
  exporters:
    tracing:
      jaeger:
        enabled: true
        agent:
          endpoint: localhost:6831

Or via collector:

telemetry:
  exporters:
    tracing:
      jaeger:
        enabled: true
        collector:
          endpoint: http://jaeger:14268/api/traces

Zipkin

telemetry:
  exporters:
    tracing:
      zipkin:
        enabled: true
        endpoint: http://zipkin:9411/api/v2/spans

Datadog

telemetry:
  exporters:
    tracing:
      datadog:
        enabled: true
        endpoint: http://localhost:8126

Sampling

Control trace sampling rate:

telemetry:
  exporters:
    tracing:
      common:
        sampler: 0.5  # Sample 50% of requests

      # Or always sample
      # sampler: always_on

      # Or never sample
      # sampler: always_off

Custom Attributes

Add custom attributes to spans:

telemetry:
  instrumentation:
    spans:
      router:
        attributes:
          # Static attribute
          environment:
            static_value: production

          # From request header
          client_id:
            request_header: x-client-id

          # From response header
          cache_status:
            response_header: x-cache-status

Trace Context Propagation

telemetry:
  exporters:
    tracing:
      propagation:
        # W3C Trace Context (default)
        trace_context: true

        # Jaeger propagation
        jaeger: true

        # Zipkin B3
        zipkin: true

        # Datadog
        datadog: true

GraphOS Studio

Send telemetry to GraphOS Studio:

telemetry:
  apollo:
    client_name_header: apollographql-client-name
    client_version_header: apollographql-client-version

Requires APOLLO_KEY and APOLLO_GRAPH_REF environment variables.

Complete Example

telemetry:
  apollo:
    client_name_header: apollographql-client-name
    client_version_header: apollographql-client-version

  exporters:
    logging:
      stdout:
        enabled: true
        format: json

    metrics:
      prometheus:
        enabled: true
        listen: 0.0.0.0:9090
        path: /metrics

    tracing:
      otlp:
        enabled: true
        endpoint: http://otel-collector:4317
        protocol: grpc

      common:
        service_name: apollo-router
        sampler: 0.1  # 10% sampling

      propagation:
        trace_context: true

  instrumentation:
    spans:
      router:
        attributes:
          environment:
            static_value: ${env.ENVIRONMENT:-development}
          client:
            request_header: x-client-id

Docker Compose Example

version: "3.8"
services:
  router:
    image: ghcr.io/apollographql/router:latest
    ports:
      - "4000:4000"
      - "9090:9090"
    environment:
      - APOLLO_ROUTER_LOG=info
    volumes:
      - ./router.yaml:/etc/router/router.yaml
      - ./supergraph.graphql:/etc/router/supergraph.graphql

  prometheus:
    image: prom/prometheus
    ports:
      - "9091:9090"
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml

  jaeger:
    image: jaegertracing/all-in-one
    ports:
      - "16686:16686"
      - "6831:6831/udp"

Source: SKILL.md on GitHub

2 warnings16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    The skill is a configuration generator and guide for Apollo Router. It implements robust security best practices by default, including environment variable interpolation for sensitive data, disabling developmental features (introspection/sandbox) in production, and providing a validation checklist. No malicious patterns, data exfiltration, or unauthorized command execution risks were found.

  • Socket16d

    1 alert: gptAnomaly

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer7mo

    26/26 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at f13ff34. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 4 months ago
What it can do
Runs commands
metadata
{
  "author": "apollographql",
  "version": "2.5.0"
}
All 1 allowed tools
Bash(router:*) Bash(./router:*) Bash(rover:*) Bash(curl:*) Bash(docker:*) Read Write Edit Glob Grep
Other metadata
compatibility
Linux/macOS/Windows. Requires a composed supergraph schema from Rover or GraphOS.
  • apollo-router
  • graphql
  • federation
  • routing
  • yaml
  • telemetry
  • authentication
  • cors

README badge

README badge for apollographql/skills/apollo-router

Generates version-aware Apollo Router configuration (v1.x or v2.x) for federated GraphQL supergraphs, handling routing, authentication, CORS, telemetry, and connectors. Use this skill to set up Router with JWT auth, traffic shaping, operation limits, or to troubleshoot connectivity and performance issues.

Generated from the current SKILL.md.

Does this skill support both Router v1 and v2?
Yes. The skill generates version-correct YAML for both v1.x and v2.x, which have incompatible config schemas. You must select your target version before generating any config.
Can I use this skill to configure Connectors?
Yes, but only for Router v2. Connectors (REST API integration) are a v2-only feature available in GA. The skill will not offer Connectors as an option if you select v1.
What do I need before I can run the generated config?
You need either a composed `supergraph.graphql` file from Rover or GraphOS access via `APOLLO_KEY` and `APOLLO_GRAPH_REF`. The skill assumes you have reachable subgraphs and will validate the config against the Router binary if available.
Does this skill help with response caching?
Yes, but only for Router v2.6.0 and later. The skill requires you to identify which subgraphs serve user-specific data and how you identify users before generating cache config, to prevent data leakage.
Will the skill validate my generated config?
Yes. After generating or editing config, the skill runs a checklist and attempts to validate against `router config validate` if the Router CLI is available. It will report pass/fail for each checklist item.

Generated from the current SKILL.md. These answers refresh after source changes.