Repository navigation
Expand file tree
/
Copy pathexample.config.js
More file actions
290 lines (239 loc) · 12.6 KB
/
Copy pathexample.config.js
File metadata and controls
290 lines (239 loc) · 12.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
/**
* Example configuration for preflight.
*
* Use this as a reference when creating ~/.newrelic-preflight/config.json.
* The config file must be valid JSON — copy individual fields you want to set
* and omit the JS comments. Every field is optional except licenseKey and accountId.
*
* Load priority: CLI flags > environment variables > config file > defaults.
* Environment variable names are noted inline for each field.
*/
export default {
// ── Required ──────────────────────────────────────────────────────────────
// New Relic ingest license key (40-char hex + NRAL suffix).
// Env: NEW_RELIC_LICENSE_KEY
licenseKey: 'YOUR_LICENSE_KEY_NRAL',
// Or read it from a secret store instead of keeping it in this file.
// argv array, absolute executable path, no shell. Runs once at startup.
// Precedence: env var > *Command > plaintext value. Same for nrApiKeyCommand
// and digestWebhookUrlCommand. See docs/ADVANCED.md § Secret Helper Commands.
licenseKeyCommand: [
'/usr/bin/security',
'find-generic-password',
'-a',
'preflight',
'-s',
'preflight-license-key',
'-w',
],
// New Relic account ID (1–12 decimal digits).
// Env: NEW_RELIC_ACCOUNT_ID
accountId: 'YOUR_ACCOUNT_ID',
// ── Identity ──────────────────────────────────────────────────────────────
// Developer identifier stamped on every NR event.
// Normalised to lowercase with underscores (e.g. "John Doe" → "john_doe").
// Falls back to $USER → $USERNAME → git config user.name → "unknown".
// Env: NEW_RELIC_AI_MCP_DEVELOPER
developer: 'jane_doe',
// User-defined team label (e.g. 'platform-eng') stamped on every NR event as team_id
// for cross-developer queries. Not your NR account ID — a free-form slug you choose.
// Env: NEW_RELIC_AI_TEAM_ID
teamId: 'my-team',
// Project identifier. Auto-derived from git remote if omitted.
// Env: NEW_RELIC_AI_PROJECT_ID
projectId: 'my-project',
// Organisation identifier for org-level grouping.
// Env: NEW_RELIC_AI_ORG_ID
orgId: 'my-org',
// ── Budget caps (optional — null disables the cap) ─────────────────────
// Maximum spend per session in USD before a budget warning is emitted.
// Env: NEW_RELIC_AI_SESSION_BUDGET_USD
sessionBudgetUsd: 5.0,
// Maximum spend per calendar day in USD before a budget warning event is emitted.
// Env: NEW_RELIC_AI_DAILY_BUDGET_USD
dailyBudgetUsd: 20.0,
// Maximum spend over a rolling 7 days in USD before a budget warning event is emitted.
// Env: NEW_RELIC_AI_WEEKLY_BUDGET_USD
weeklyBudgetUsd: 100.0,
// ── Personal alert thresholds ─────────────────────────────────────────────
// Used by: preflight deploy-alerts --developer <name>
// Defaults: dailyCostUsd: 2, sessionCostUsd: 0.50, efficiencyScoreMin: 40, stuckLoopCountMax: 2
alerts: {
personal: {
dailyCostUsd: 2,
sessionCostUsd: 0.5,
efficiencyScoreMin: 40,
stuckLoopCountMax: 2,
},
},
// ── Security ──────────────────────────────────────────────────────────────
// When true, recordContent is forced off, so literal file contents, command output, and
// agent text are never sent to New Relic, whatever recordContent says. Use it where content
// must never leave the machine. Do not bypass it.
// See PRIVACY.md (highSecurity).
// Env: NEW_RELIC_AI_HIGH_SECURITY (true/false)
// Default: false
highSecurity: false,
// When true, literal file contents, command output, and agent text are included in NR events
// (and written to the local buffer). Content may contain secrets and proprietary code.
// Credential-pattern redaction runs first, but it matches known secret formats only. It is
// pattern-based, not data-loss prevention, so it does not catch other sensitive code or text.
// Review what the AI assistant reads and runs before enabling this. See PRIVACY.md (recordContent).
// Forced off when highSecurity is true.
// Env: NEW_RELIC_AI_MCP_RECORD_CONTENT (true/false)
// Default: false
recordContent: false,
// When true, the nr_observe_install_hooks MCP tool may rewrite
// ~/.claude/settings.json. Off by default: any connected MCP client can call
// the tool. Each install is recorded in the audit trail. See docs/ADVANCED.md.
// Env: NEW_RELIC_AI_ALLOW_HEADLESS_INSTALL (true/false)
// Default: false
allowHeadlessInstall: false,
// ── Storage ───────────────────────────────────────────────────────────────
// Root directory for local storage (sessions, buffer, weekly summaries).
// Env: NEW_RELIC_AI_MCP_STORAGE_PATH
// Default: ~/.newrelic-preflight
storagePath: '~/.newrelic-preflight',
// Auto-purge session files older than this many days. null = keep forever.
// Env: NEW_RELIC_AI_RETAIN_SESSIONS_DAYS
retainSessionsDays: 30,
// ── Harvest intervals ─────────────────────────────────────────────────────
// How often to flush buffered events to NR (milliseconds). Min: 100, Max: 3600000.
// Env: NEW_RELIC_AI_MCP_HARVEST_EVENTS_MS
// Default: 5000
harvestEventsMs: 5000,
// How often to flush aggregated metrics to NR (milliseconds). Min: 100, Max: 3600000.
// Env: NEW_RELIC_AI_MCP_HARVEST_METRICS_MS
// Default: 60000
harvestMetricsMs: 60000,
// ── Connectivity ──────────────────────────────────────────────────────────
// New Relic region. Auto-detected from license key prefix; override only if needed.
// Env: NEW_RELIC_HOST (null = US default, "eu" = EU, "gov" = FedRAMP)
// Default: null (US)
collectorHost: null,
// HTTP port for proxy mode.
// Env: NEW_RELIC_AI_MCP_PORT
// Default: 9847
port: 9847,
// Log level for stderr output.
// Env: NEW_RELIC_AI_MCP_LOG_LEVEL ("debug" | "info" | "warn" | "error")
// Default: "info"
logLevel: 'info',
// ── OTLP/HTTP transport (optional — for Datadog, Grafana Cloud, etc.) ───────
// OTLP/HTTP endpoint URL. When set, telemetry is also exported via OTLP.
// For New Relic OTLP endpoints:
// US: https://otlp.nr-data.net
// EU: https://otlp.eu01.nr-data.net
// For other backends (Datadog, Grafana Cloud, Honeycomb), use their OTLP endpoint.
// Env: OTEL_EXPORTER_OTLP_ENDPOINT
// Default: null (disabled)
otlpEndpoint: null,
// Additional HTTP headers for OTLP exporter (e.g., authentication).
// For New Relic OTLP, use: { "api-key": "<NR_LICENSE_KEY>" }
// For Datadog, use: { "dd-api-key": "<DATADOG_API_KEY>" }
// Env: OTEL_EXPORTER_OTLP_HEADERS (comma-separated key=value pairs, e.g. "api-key=xxx,other=yyy")
// Default: {}
otlpHeaders: {},
// Transport mode when otlpEndpoint is configured.
// - 'nr-events-api' (default): NR Events API + Metric API only
// - 'otlp': OTLP/HTTP only (requires otlpEndpoint)
// - 'both': NR Events API + OTLP simultaneously
// Env: NEW_RELIC_AI_TRANSPORT
// Default: "nr-events-api"
transport: 'nr-events-api',
// ── OTLP receiver (proxy mode only — receives OTel spans from local apps) ───
// Enable a local OTLP/HTTP receiver on the proxy. Any app pointing at
// http://localhost:<otlpReceiverPort> will have its spans enriched with the
// current coding session context and forwarded to New Relic.
// Env: NR_AI_OTLP_RECEIVER_ENABLED (true/false)
// Default: false
otlpReceiverEnabled: false,
// Port for the local OTLP/HTTP receiver.
// Env: NR_AI_OTLP_RECEIVER_PORT
// Default: 4318
otlpReceiverPort: 4318,
// Where to forward received spans. Defaults to the NR US OTLP endpoint when
// licenseKey is present. Set to null to receive and enrich only (no forward).
// Env: NR_AI_OTLP_FORWARD_ENDPOINT
otlpForwardEndpoint: 'https://otlp.nr-data.net',
// HTTP headers added to every forwarded OTLP request.
// Defaults to { 'api-key': licenseKey } when licenseKey is present.
// Env: NR_AI_OTLP_FORWARD_HEADERS (comma-separated key=value pairs)
otlpForwardHeaders: { 'api-key': 'YOUR_LICENSE_KEY_NRAL' },
// ── Companion mode (running alongside Claude Code's built-in OTel) ─────────
// Set this when your org also enables Claude Code's built-in OTel export —
// both paths share the same session_id (Claude Code's session.id), so a
// blended "org AI spend" dashboard would otherwise double the true cost.
// When true, Preflight suppresses its own ai.cost.* gauges (cost, tokens,
// cache, cost per line of code) and tags cost-bearing Claude Code events
// with cost_authority: 'external' instead of dropping them, so the two
// sources can still be reconciled. See docs/ADVANCED.md.
// Env: NR_AI_COMPANION_MODE (true/false)
// Default: false
companionMode: false,
// ── NR User API key (for team queries and deploying dashboards/alerts) ───────
// User API key (NRAK-...). Used for team summary queries and deploying dashboards/alerts.
// It carries its user's permissions across every account that user can reach:
// use a minimally privileged user, or leave it unset (the MCP server only
// needs it for nr_observe_get_team_summary).
// Env: NEW_RELIC_API_KEY
nrApiKey: 'NRAK-XXXXXXXXXXXXXXXXXXXXXXXXXX',
// Read nrApiKey from a secret store instead (see licenseKeyCommand above).
nrApiKeyCommand: ['/opt/homebrew/bin/op', 'read', 'op://Private/Preflight/nr-api-key'],
// ── Weekly digest ─────────────────────────────────────────────────────────
// Slack incoming webhook URL for weekly cost/efficiency digest.
// Env: NEW_RELIC_AI_DIGEST_WEBHOOK_URL
digestWebhookUrl: 'https://hooks.slack.com/services/TXXXXXXXX/BXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX',
// Read digestWebhookUrl from a secret store instead (see licenseKeyCommand above).
digestWebhookUrlCommand: [
'/usr/local/bin/vault',
'kv',
'get',
'-field=webhook_url',
'secret/preflight',
],
// ── Local dashboard mode ───────────────────────────────────────────────────
//
// `mode` controls what destinations receive your AI-coding telemetry:
//
// 'cloud' — ship every event to New Relic. Existing behaviour.
// Requires `licenseKey` and `accountId`.
// 'local' — (default) keep all data on your machine. The MCP server boots an
// embedded HTTP dashboard at http://127.0.0.1:7777 and does
// NOT send anything to NR. `licenseKey` is optional.
// 'both' — do both. Useful as a transition aid.
//
// Env: NR_AI_MODE
// Default: "local" — a licenseKey with no explicit mode is rejected at
// startup (opt-in export), not silently treated as cloud.
// mode: 'cloud',
//
// dashboard: {
// port: 7777, // local HTTP port for the dashboard
// host: '127.0.0.1', // non-loopback values are warned and overridden
// openOnStart: false,
// },
// ── Model ─────────────────────────────────────────────────────────────────
// AI model identifier stamped on NR events when not inferred from tool calls.
// Env: NEW_RELIC_AI_MODEL
// Default: "claude-sonnet-4-6"
model: 'claude-sonnet-4-6',
// ── Proxy upstreams (proxy mode only) ─────────────────────────────────────
// Used when running: preflight proxy --port 9847
// Env: NEW_RELIC_AI_MCP_PROXY_UPSTREAMS (JSON array string)
proxyUpstreams: [
// HTTP upstream example:
{
name: 'my-http-server',
transportType: 'http',
url: 'http://localhost:3000/mcp',
},
// Stdio upstream example:
{
name: 'my-stdio-server',
transportType: 'stdio',
command: '/usr/local/bin/my-mcp-server',
args: ['--flag', 'value'],
},
],
};