drupal / ai_observability_opentel_recipe
Enables Drupal AI observability + OpenTelemetry and points them at an OTLP collector (pairs with the ddev-drupal-ai-observability DDEV add-on). No AI provider, no agents.
Package info
git.drupalcode.org/project/ai_observability_opentel_recipe.git
Type:drupal-recipe
pkg:composer/drupal/ai_observability_opentel_recipe
Requires
- drupal/ai: ^1.4
- drupal/core: ^10.3 || ^11
- drupal/opentelemetry: ^1.0@beta
This package is auto-updated.
Last update: 2026-07-28 15:57:40 UTC
README
Enables and configures the Drupal-side half of the AI observability setup:
- Modules:
ai+ai_observability,opentelemetry+opentelemetry_metrics+opentelemetry_logs. - Config: points
opentelemetry.settingsat the OTLP collector (http://grafana-alloy:4318,http/protobuf) and switches onai_observability's OpenTelemetry export (spans + metrics).
It pairs with the
ddev-drupal-ai-observability
DDEV add-on, which provides the receiving Grafana/Tempo/Mimir/Loki/Alloy stack
and the dashboards. Install the add-on first; then every AI request your site
makes shows up in Grafana.
What it deliberately does NOT do
- No AI provider — install and configure one yourself (e.g.
drupal/ai_provider_openai) including its API key (use the Key module with an env-var provider; never commit keys). - No agents — the agent dashboards light up once you install
drupal/ai_agents(≥ 1.4) and create agents; nothing here depends on it. No prompt/response storage —
otel_spans_store_input/_outputstay off (privacy default). The Grafana Message flow panel needs them:drush cset ai_observability.settings otel_spans_store_input true -y drush cset ai_observability.settings otel_spans_store_output true -y⚠️ This stores prompt/response text (truncated ~1 KB) in your traces.
Zero-to-running with the one-line installer
This repo ships a .drupalaibp/ directory for the
one_line_installer
(drupalaibp) with two named configs that build the whole project — DDEV +
Drupal + the
ddev-drupal-ai-observability
Grafana stack + this recipe:
--config | What it builds |
|---|---|
base | The observability pipeline only. No AI provider, by design — pick your own; the first request it makes shows up traced, metered, and priced in Grafana. |
demo | Everything in base plus AI API Explorer + AI Agents, prompts for OpenAI / Anthropic / Gemini / Mistral / Fireworks keys (each optional — blank skips that provider entirely), and creates a demo agent + subagent so the AI Agent Sessions dashboard has a parent → subagent trace to show. |
# Grab the .drupalaibp/ configs into a fresh launch directory:
git clone https://git.drupalcode.org/project/ai_observability_opentel_recipe.git
mkdir my-ai-site && cp -a ai_observability_opentel_recipe/.drupalaibp my-ai-site/
cd my-ai-site
# Build the base observability site …
bash <(curl -fsSL https://project.pages.drupalcode.org/one_line_installer/drupalaibp) --config base
# … or the full provider + demo-agent build:
bash <(curl -fsSL https://project.pages.drupalcode.org/one_line_installer/drupalaibp) --config demo
Because there is more than one config, you must name one with --config
(a bare run picks interactively). After a demo build, populate the dashboard:
ddev drush agents:run observability_demo_agent # type a topic e.g. "sea otters", Ctrl+C to exit
How the two configs are wired
.drupalaibp/base.json/.drupalaibp/demo.json— the named configs..drupalaibp/setup_demo.sh— aprovision_from_config_donehook (demo only, runs in the web container). For each provider whose key you entered itcomposer requires the module, enables it, creates a Key entity (env provider — the key value stays in.ddev/.env, never in config), points<module>.settings:api_keyat it, then sets a default chat model from the first configured provider. It also creates the two demo agents viadrush. Providers with a blank key are skipped entirely.
| Provider | Question env var | Module | Provider id |
|---|---|---|---|
| OpenAI | OPENAI_API_KEY | ai_provider_openai | openai |
| Anthropic | ANTHROPIC_API_KEY | ai_provider_anthropic | anthropic |
| Google Gemini | GEMINI_API_KEY | gemini_provider | gemini |
| Mistral | MISTRAL_API_KEY | ai_provider_mistral | mistral |
| Fireworks AI | FIREWORKSAI_API_KEY | fireworksai | fireworks |
Apply (recipe only, on an existing site)
The modules must be present in the codebase first (recipes don't run Composer):
ddev composer require drupal/ai_observability_opentel_recipe
ddev drush recipe:apply /var/www/html/recipes/ai_observability_opentel_recipe
ddev drush cr
(Requiring the recipe via Composer pulls drupal/ai and
drupal/opentelemetry in for you — its composer.json declares both.)
After applying
- Install + configure an AI provider and set default models at
/admin/config/ai/settings. - Make an AI call — then open Grafana at
https://<project>.ddev.site:3000and check the AI Requests — Overview dashboard. - Optional:
drupal/ai_agentsfor the agent-session dashboards, andddev sync-model-pricesfor live cost pricing.
Customizing the endpoint
Not on DDEV / different collector? Override after applying:
drush cset opentelemetry.settings endpoint 'http://my-collector:4318' -y