Ship every Gemini CLI session — token usage, tool calls, API requests, model routing decisions, agent runs, and prompt logs — directly into Coralogix using Gemini CLI's built-in OpenTelemetry support.
No wrappers. No code changes to your projects. Gemini CLI emits OTLP natively; you just point it at your Coralogix ingress endpoint.
Gemini CLI ships the full OpenTelemetry SDK and emits logs, metrics, and traces when GEMINI_TELEMETRY_ENABLED=true is set. This folder provides:
activate.sh— exports all required env vars into your shell in one step.env— stores your Coralogix API key and endpoint (git-ignored)settings.json.example— optional.gemini/settings.jsonalternative to env vars
Gemini CLI's settings.json has no headers field. Instead, Gemini CLI constructs its OTLP exporters without hardcoded headers, so the standard OTEL_EXPORTER_OTLP_HEADERS env var is read as gRPC metadata by the underlying @opentelemetry/exporter-*-otlp-grpc packages. activate.sh sets this variable automatically with three values:
authorization=Bearer <key>— authenticates the requestcx-application-name=<name>— routes data to the correct Coralogix applicationcx-subsystem-name=<name>— routes data to the correct Coralogix subsystem
Gemini CLI emits logs, metrics, and traces via OTLP. For the full signal reference — event names, metric names, attributes, and trace span structure — see the Gemini CLI telemetry documentation.
Once data is flowing, metrics appear in Metrics Explorer (search gemini_cli), logs in Logs, and traces in Tracing filtered by service name gemini-cli.
npm install -g @google/gemini-cliRun gemini and choose Sign in with Google when prompted, or set a Gemini API key:
# Option A: Google account (free tier — 60 req/min, 1000 req/day)
gemini # follow browser OAuth flow
# Option B: API key
export GEMINI_API_KEY="your-key-from-aistudio.google.com"
geminicp .env.example .envOpen .env and fill in:
CX_API_KEY=<your-send-your-data-api-key>
CX_OTLP_ENDPOINT=https://ingress.eu1.coralogix.com
CX_APPLICATION_NAME=gemini-cli
CX_SUBSYSTEM_NAME=gemini-cli-sessions
Find your Send-Your-Data API key under Settings → API Keys in your Coralogix tenant.
OTLP ingress by region:
| Domain | OTLP endpoint |
|---|---|
us1.coralogix.com |
https://ingress.us1.coralogix.com |
us2.coralogix.com |
https://ingress.us2.coralogix.com |
eu1.coralogix.com |
https://ingress.eu1.coralogix.com |
eu2.coralogix.com |
https://ingress.eu2.coralogix.com |
ap1.coralogix.com |
https://ingress.ap1.coralogix.com |
ap2.coralogix.com |
https://ingress.ap2.coralogix.com |
ap3.coralogix.com |
https://ingress.ap3.coralogix.com |
source activate.sh
geminiactivate.sh exports all OTEL variables into your current shell. It must be sourced (not executed) so the variables persist. Re-run it in each new terminal, or see the persistent setup below.
Add the following to ~/.zshrc (or ~/.bashrc) so every terminal automatically has telemetry enabled:
if [ -f "$HOME/path/to/gemini-cli/.env" ]; then
set -a; source "$HOME/path/to/gemini-cli/.env"; set +a
fi
export GEMINI_TELEMETRY_ENABLED=true
export GEMINI_TELEMETRY_TARGET=local
export GEMINI_TELEMETRY_OTLP_PROTOCOL=grpc
export GEMINI_TELEMETRY_OTLP_ENDPOINT="${CX_OTLP_ENDPOINT}"
export OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer ${CX_API_KEY},cx-application-name=${CX_APPLICATION_NAME},cx-subsystem-name=${CX_SUBSYSTEM_NAME}"
export OTEL_RESOURCE_ATTRIBUTES="cx.application.name=${CX_APPLICATION_NAME},cx.subsystem.name=${CX_SUBSYSTEM_NAME}"Then reload:
source ~/.zshrcInstead of env vars, you can configure the endpoint in ~/.gemini/settings.json. Copy settings.json.example and update the endpoint to match your region:
cp settings.json.example ~/.gemini/settings.jsonNote:
settings.jsonhas noheadersfield, soOTEL_EXPORTER_OTLP_HEADERSmust still be set as an env var for authentication to work — even when using this file.
After running a session, check that telemetry arrived in Coralogix:
- Logs — Go to Logs and filter by application name
gemini-cliand subsystem namegemini-cli-sessions. Search forlogRecord.body:"CLI configuration loaded."to find the startup config event emitted at the beginning of every session. - Metrics — Go to Metrics Explorer and search for
gemini-cli. Token usage and API request metrics appear within one export interval (~10 seconds). - Traces — Go to Tracing and filter by service name
gemini-cli.
Note on sensitive data in telemetry:
activate.shsetsGEMINI_TELEMETRY_LOG_PROMPTS=falseto suppress thepromptfield ingemini_cli.user_promptevents. This does not suppress all content from telemetry. Be aware of the following:
-pflag: When usinggemini -p "your prompt", the prompt appears inprocess.command_argsresource attributes regardless ofLOG_PROMPTS— the OTel Node.js SDK captures all process arguments automatically. Use interactive mode (gemini, then type your prompt) to keep prompt content out of telemetry.- Tool and skill commands: The
gemini_cli.tool_callevent includes afunction_argsattribute containing the full arguments passed to each tool — this includes shell commands, file paths, and any content passed to native tools or MCP tools.- Slash commands: The
gemini_cli.slash_commandevent logs every slash command with itscommandandsubcommandvalues.- Full conversation content: When
GEMINI_TELEMETRY_LOG_PROMPTS=true, thegen_ai.client.inference.operation.detailslog event and trace spans includegen_ai.input.messagesandgen_ai.output.messagescontaining the full conversation history — including tool call responses such as file contents and directory listings read during the session.- System instructions: The
gen_ai.system_instructionsattribute ingen_ai.client.inference.operation.detailscontains the full Gemini CLI system prompt, including internal sub-agent descriptions and skill file paths. This is emitted regardless ofLOG_PROMPTS.- Machine identity: Resource attributes
host.name,host.id, andprocess.ownerare attached to every event and identify the machine and OS user running Gemini CLI.
coralogix-gemini-cli-dashboard.json is a ready-to-import Coralogix dashboard covering all Gemini CLI telemetry signals.
- In Coralogix, go to Dashboards and click New Dashboard → Import.
- Upload
coralogix-gemini-cli-dashboard.json. - The dashboard loads immediately — no further configuration needed.
| Section | Panels |
|---|---|
| Overview | Sessions (24h), Total Tokens (24h), Input Tokens (24h), Output Tokens (24h), API Errors (24h), Tool Success Rate (24h) |
| Session activity | Sessions over time, Model distribution |
| Token usage & efficiency | Token volume by type, Token volume by model, Cache token ratio %, Thought tokens over time, Avg tokens per session |
| API performance | API requests per minute, API latency p50/p90/p99, Error rate over time, Errors by type, Status code distribution |
| Tool usage | Tool calls over time, Top tools by call count, Tool success rate by function, Tool latency by function, Decision breakdown (accept/reject/auto_accept/modify), MCP vs native split |
| File operations | File operations over time by type, Lines changed over time |
The Agent runs and Resilience & errors section stubs are included and ready to extend once you have agent or retry data flowing.
Coralogix inserts the OTel unit into the Prometheus metric name on ingestion. The actual names differ from the OTel spec names:
| OTel metric | Prometheus name in Coralogix |
|---|---|
gemini_cli.session.count |
gemini_cli_session_count_total |
gemini_cli.token.usage |
gemini_cli_token_usage_total |
gemini_cli.api.request.count |
gemini_cli_api_request_count_total |
gemini_cli.api.request.latency |
gemini_cli_api_request_latency_ms_{bucket,sum,count,max,min} |
gemini_cli.tool.call.count |
gemini_cli_tool_call_count_total |
gemini_cli.tool.call.latency |
gemini_cli_tool_call_latency_ms_{bucket,sum,count,max,min} |
gemini_cli.model_routing.latency |
gemini_cli_model_routing_latency_ms_{bucket,sum,count,max,min} |
gemini_cli.file.operation.count |
gemini_cli_file_operation_count_total |
gemini_cli.lines.changed |
gemini_cli_lines_changed_total |
Log events use $d.logRecord.attributes['event.name'] for the event name (not the body). Common DataPrime filter pattern:
source logs | filter $d.logRecord.attributes['event.name'] == 'gemini_cli.api_error'
For the full list of Gemini CLI telemetry configuration variables, see the Gemini CLI configuration reference.