Datadog and Grafana dashboards (community)

Two importable dashboards and three Datadog monitor templates for the OTLP data Shield KYA already exports. They are community dashboards kept in this repo. They are not an official Datadog integration, Marketplace tile, or Grafana plugin.

File What it is
integrations/datadog/kya-dashboard.json Datadog dashboard (ordered layout, template variables service, env, hosted_service)
integrations/datadog/monitors.json Three monitor bodies: DENY spike, never-list hit, no decision spans for 30 minutes
integrations/grafana/kya-dashboard.json Grafana dashboard (schemaVersion 42, Grafana 12.3 or newer) with ${DS_TEMPO} and ${DS_PROMETHEUS} import inputs
integrations/otlp-fields.json Every span attribute and metric name the dashboards may use, read from the emitting code

The files are not in the npm package. Take them from the GitHub repo; they are in the public repo from the first release that includes them.

What the panels read

The decision-span and connected-mode names below were captured from a real kya run (see How the field list is checked). The hosted-only names were not captured: they are read from the hosted plane source.

Decision spans (service.name=shield-kya-cli, one span per decision, see otlp.md):

Connected mode only: the kya.client.evaluate.latency histogram, tagged verdict and host. Panels: decision mix and evaluate latency p50 / p95. It is recorded only when the CLI calls the hosted plane evaluate API with KYA_OTLP_ENDPOINT set, and the CLI exports metrics every 15 seconds without a flush on exit. In practice that means a connected, long-lived MCP gate or gateway. Hooks always evaluate offline and never emit it; offline and keyless gates never emit it either.

Hosted only (hosted plane with KYA_OTLP_ENABLED=true): decision counters (kya.policy.deny, kya.policy.require_approve, kya.policy.approve_granted, kya.evaluate.count), evaluate latency (kya.evaluate.latency, kya.evaluate.max_ms), kill latency against its SLO (kya.kill.last_ms, kya.kill.slo_ms), and PII redaction hits (kya.redaction.hits). These names come from the hosted plane source. They are not in the captured fixture.

Send KYA data to Datadog

Run a Datadog Agent with OTLP ingest, or an OpenTelemetry Collector with the datadog exporter, on the same host. Keep DD_API_KEY on the Agent or Collector, not in the KYA process. The sample Collector config is otel-collector-kya.yaml.

# Verdict spans (OSS CLI). Long-lived MCP gate / gateway exports every verdict.
export KYA_OTLP_EXPORT_ENDPOINT=http://127.0.0.1:4318
# Evaluate-latency metric (OSS CLI, connected mode only).
export KYA_OTLP_ENDPOINT=http://127.0.0.1:4318

.kya/config.json works too: { "otlpExport": { "endpoint": "http://127.0.0.1:4318" } }. For the hosted plane, see otlp.md, Hosted plane.

Import the dashboard with POST /api/v1/dashboard and the file as the body, or create an empty dashboard and use Configure > Import dashboard JSON (this overwrites that dashboard). Create each entry of monitors.json with POST /api/v1/monitor, one body per call. Add your notification handle to each message first.

Datadog setup the dashboard needs:

  1. A custom APM retention filter on service:shield-kya-cli. Span widgets and trace-analytics monitors only see indexed spans. Datadog states that Analytics monitors evaluate only spans kept by custom retention filters, not the intelligent retention filter.
  2. Facets for @kya.verdict, @kya.reason_code, @kya.host, @kya.mode and @gen_ai.tool.name are recommended so they show in the Trace Explorer facet panel and group-by pickers (Datadog facets doc below).
  3. Delta temporality is not available from the CLI. The CLI histogram is cumulative. Datadog converts cumulative histograms to distributions from the second point onward and recommends delta, so the first export after a CLI start is not counted.
  4. Percentiles on the distribution kya.client.evaluate.latency must be enabled in the metric settings for the p50 / p95 panel.
  5. The env template variable only filters when your Agent or Collector adds an env tag (KYA does not set deployment.environment).

Send KYA data to Grafana

The Grafana dashboard reads spans from Tempo with TraceQL and metrics from Prometheus (or Mimir / Grafana Cloud) with PromQL. Point the same env vars at an OpenTelemetry Collector or Grafana Alloy that forwards traces to Tempo and metrics to Prometheus:

export KYA_OTLP_EXPORT_ENDPOINT=http://127.0.0.1:4318   # spans -> Tempo
export KYA_OTLP_ENDPOINT=http://127.0.0.1:4318          # metric -> Prometheus (connected mode only)

Import: Dashboards > New > Import, upload grafana/kya-dashboard.json, then pick your Tempo and Prometheus data sources for the DS_TEMPO and DS_PROMETHEUS inputs. The HTTP API works too: POST /api/dashboards/import with the file as dashboard and both inputs set (without them, Grafana refuses the import with missing dashboard input variable DS_TEMPO). The service variable defaults to shield-kya-cli, and hosted_job defaults to shield-agent (the hosted plane’s spring.application.name).

Grafana setup the dashboard needs:

  1. Tempo 2.8 or newer with TraceQL metrics enabled. On Tempo 2.x, turn on the local-blocks processor (metrics_generator.processor.local_blocks and processors: [local-blocks] in the overrides). Tempo 3.x removed that processor (Tempo 3.1.0 does not start with those config keys) and serves TraceQL metrics without extra config. Every span panel uses count_over_time(), and the top-N panels use topk(10), which older Tempo versions reject.
  2. Prometheus naming. The PromQL assumes the Prometheus OTLP receiver default, UnderscoreEscapingWithSuffixes: dots become underscores, unit ms adds _milliseconds, histograms get _bucket / _sum / _count, and service.name becomes the job label. So kya.client.evaluate.latency is queried as kya_client_evaluate_latency_milliseconds_bucket{job="shield-kya-cli"}. Grafana Cloud and the Collector / Alloy Prometheus exporters add these suffixes. Self-hosted Mimir’s OTLP endpoint drops unit suffixes by default (otel_metric_suffixes_enabled is false), so the latency and evaluate-count panels come back empty there: route OTLP through a Collector or Alloy, enable otel_metric_suffixes_enabled, or remove _milliseconds from those queries. If your pipeline keeps UTF-8 names, adjust the queries too.
  3. File provisioning. Grafana provisioning does not fill the import inputs. A provisioned copy of the file loads, but its panels ask for the data source ${DS_TEMPO} and fail with Data source not found. Before you provision the file, replace ${DS_TEMPO} and ${DS_PROMETHEUS} with the uids of your data sources, for example sed -e 's/\${DS_TEMPO}/my-tempo-uid/g' -e 's/\${DS_PROMETHEUS}/my-prom-uid/g'.

Honest limits

How the field list is checked

pnpm test runs test/dashboards.test.ts, which:

  1. parses every file and checks the required top-level keys for each format;
  2. rejects unscoped TraceQL attributes (.kya.verdict), Datadog span facets without @, and hard-coded values (decisions, modes, hosts, the reason codes the panels filter on) that KYA does not emit;
  3. extracts every span attribute and metric name from the Datadog, TraceQL and PromQL queries and fails if one is not in integrations/otlp-fields.json;
  4. checks that otlp-fields.json matches the attribute keys in src/otel/exporter.ts and the histogram in src/otel.ts;
  5. checks that every OSS name a dashboard uses appears in test/fixtures/otlp-capture.json. That fixture holds the OTLP/JSON bodies a real kya serve-mcp --stdio run sent to a local receiver: ALLOW, REQUIRE_APPROVE, a never-list DENY for postgres__drop_table, a PLANE_UNREACHABLE DENY, and the evaluate-latency metric.

Run it alone with node scripts/validate-dashboards.mjs.

Sources