Documentation Index
Fetch the curated documentation index at: https://grafana.com/llms.txt
Fetch the complete documentation index at: https://grafana.com/llms-full.txt
Use this file to discover all available pages before exploring further.
STOP! If you are an AI agent or LLM, read this before continuing. This is the HTML version of a Grafana documentation page. Always request the Markdown version instead - HTML wastes context. Get this page as Markdown: https://grafana.com/docs/grafana-cloud/monitor-applications/frontend-observability/instrument/console-instrumentation.md (append .md) or send Accept: text/markdown to https://grafana.com/docs/grafana-cloud/monitor-applications/frontend-observability/instrument/console-instrumentation/. For the curated documentation index, use https://grafana.com/llms.txt. For the complete documentation index, use https://grafana.com/llms-full.txt.
Capture console logs
Logs are critical for troubleshooting errors because they provide context and detail into what’s happening in your application.
The console instrumentation replaces the browser’s console with a custom implementation that collects all logs, so whenever console.error (for example) is called, the message is sent as a log to the collector.
Console instrumentation helps you to:
- Determine the context and the root cause of errors
- Capture messages emitted by the application or the libraries it uses
- Monitor your application and determine that it is working as expected
Because the console instrumentation can offer helpful context when you troubleshoot errors, it is recommended that you keep this instrumentation enabled. However, enabling log collection for all log levels captures a lot of data that is sent to Grafana Cloud which can increase cost and result in verbose data.
By default, the following log levels are disabled. Only enable them if required:
console.debugconsole.traceconsole.log
How to use the console instrumentation
The following console instrumentation is enabled by default. No additional configuration is required.
initializeFaro({
url: 'https://my-domain.my-tld/collect/{app-key}',
app: {
name: 'my-app',
},
});Note
If you overwrite the
instrumentationsarray when you initialize the Grafana Faro Web SDK, you must manually include the console instrumentation.
To manually include the console instrumentation, use the following getWebInstrumentations helper function.
initializeFaro({
url: 'https://my-domain.my-tld/collect/{app-key}',
app: {
name: 'my-app',
},
instrumentations: [
...getWebInstrumentations({
// Optional, if you want to disable the console instrumentation
captureConsole: false,
}),
],
});Use the Faro config to configure the Console instrumentation.
initializeFaro({
url: 'https://my-domain.my-tld/collect/{app-key}',
app: {
name: 'my-app',
},
consoleInstrumentation: {
consoleErrorAsLog: true,
// Optional, if you want to collect all levels
captureConsoleDisabledLevels: [],
// Optional, if you want to disable only some levels
captureConsoleDisabledLevels: [LogLevel.DEBUG, LogLevel.TRACE],
},
});Was this page helpful?
Related resources from Grafana Labs


