Telemetry allows Kibana features to have usage tracked in the wild. The general term "telemetry" refers to multiple things:
- Integrating with the telemetry service to express how to collect usage data (Collecting).
- Sending a payload of usage data up to Elastic's telemetry cluster.
- Viewing usage data in the Kibana instance of the telemetry cluster (Viewing).
This plugin is responsible for sending usage data to the telemetry cluster. For collecting usage data, use the usageCollection
plugin
The setup
function exposes the following interface:
getTelemetryUrl: () => Promise<URL>
: An async function that resolves into the telemetry Url used to send telemetry. The url is wrapped with node's URL constructor. Here is an example on how to grab the url origin:Note that the telemetry URL is a kibana.yml configuration hence it is recommended to call theconst telemetryUrl = await getTelemetryUrl(); > telemetryUrl.origin; // 'https://telemetry.elastic.co'
getTelemetryUrl
everytime before using the actual url.
The start
function exposes the following interface:
async getIsOptedIn(): Promise<boolean>
: An async function that resolves intotrue
if the user has opted into send Elastic usage data. Resolves tofalse
if the user explicitly opted out of sending usage data to Elastic or did not choose to opt-in or out yet after a minor or major upgrade (only when previously opted out).
To use the exposed plugin start and setup contracts:
- Make sure
telemetry
is in youroptionalPlugins
in thekibana.json
file:
// <plugin>/kibana.json
{
"id": "...",
"optionalPlugins": ["telemetry"]
}
- Use the exposed contracts:
// <plugin>/server/plugin.ts
import { TelemetryPluginsStart } from '../telemetry/server`;
interface MyPluginStartDeps {
telemetry?: TelemetryPluginsStart;
}
class MyPlugin {
public async start(
core: CoreStart,
{ telemetry }: MyPluginStartDeps
) {
const isOptedIn = await telemetry?.getIsOptedIn();
...
}
}